mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
pbox wip
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
<!DOCTYPE btexdoc SYSTEM "btexdoc.dtd">
|
<!DOCTYPE btexdoc SYSTEM "btexdoc.dtd">
|
||||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||||
<cover>
|
<cover>
|
||||||
<title>The Way to Mastery of<br />Lorem Ipsum</title>
|
<title>The Way to Mastery of<br/>Lorem Ipsum</title>
|
||||||
<subtitle>Or, How To Write and Publish a Book</subtitle>
|
<subtitle>Or, How To Write and Publish a Book</subtitle>
|
||||||
<author>Terran Publishing</author>
|
<author>Terran Publishing</author>
|
||||||
<edition>Test Edition</edition>
|
<edition>Test Edition</edition>
|
||||||
</cover>
|
</cover>
|
||||||
|
|
||||||
<tocpage><tableofcontents /></tocpage>
|
<tocpage><tableofcontents/></tocpage>
|
||||||
|
|
||||||
<manuscript>
|
<manuscript>
|
||||||
<part>The Book</part>
|
<part>The Book</part>
|
||||||
@@ -18,14 +18,14 @@
|
|||||||
|
|
||||||
<section hide="1">What Qualifies as a Book</section>
|
<section hide="1">What Qualifies as a Book</section>
|
||||||
|
|
||||||
<p><index id="the book" />Under the book typesetting system, a Book is a collection of texts typesetted for an improved
|
<p><index id="the book"/>Under the book typesetting system, a Book is a collection of texts typesetted for an improved
|
||||||
legibility, enumerable pages, with insertion of other helpful resources such as illustrations
|
legibility, enumerable pages, with insertion of other helpful resources such as illustrations
|
||||||
and <a href="hyperlink">hyperlinks</a>.</p>
|
and <a href="hyperlink">hyperlinks</a>.</p>
|
||||||
<p>Books are considered as bound and always presented in two pages for reading.</p>
|
<p>Books are considered as bound and always presented in two pages for reading.</p>
|
||||||
|
|
||||||
<chapter>Writing a Book Using a Typewriter</chapter>
|
<chapter>Writing a Book Using a Typewriter</chapter>
|
||||||
|
|
||||||
<p><index id="typewriter" />Typewriter allows quick scribbling of the words in convenient manners, just click on them and get
|
<p><index id="typewriter"/>Typewriter allows quick scribbling of the words in convenient manners, just click on them and get
|
||||||
writing!</p>
|
writing!</p>
|
||||||
<p>But it comes with big downsides: you cannot type in multiple writing systems, cannot have defined
|
<p>But it comes with big downsides: you cannot type in multiple writing systems, cannot have defined
|
||||||
chapters and sections, cannot include any illustrations, no hyperlinks, and of course, ragged texts.</p>
|
chapters and sections, cannot include any illustrations, no hyperlinks, and of course, ragged texts.</p>
|
||||||
@@ -37,21 +37,21 @@
|
|||||||
<p>Professional-looking texts, with all the benefits of a real Book can be made, or even mass-produced
|
<p>Professional-looking texts, with all the benefits of a real Book can be made, or even mass-produced
|
||||||
easily with the help of publishers.</p>
|
easily with the help of publishers.</p>
|
||||||
<p>To have your precious texts to be printed, you must send your manuscripts to a publisher, and the
|
<p>To have your precious texts to be printed, you must send your manuscripts to a publisher, and the
|
||||||
manuscript must be written in a special language: the <btex />.</p>
|
manuscript must be written in a special language: the <btex/>.</p>
|
||||||
<p><btex /> allows concise description of the entire shape of your book, any style the book typesetting
|
<p><btex/> allows concise description of the entire shape of your book, any style the book typesetting
|
||||||
system can support can be described and printing presses will produce the papers accordingly.
|
system can support can be described and printing presses will produce the papers accordingly.
|
||||||
You can even try to mimic the look and feel of papers created using a typewriter, if you want to.</p>
|
You can even try to mimic the look and feel of papers created using a typewriter, if you want to.</p>
|
||||||
|
|
||||||
|
|
||||||
<part>The <btex /></part>
|
<part>The <btex/></part>
|
||||||
|
|
||||||
<chapter>Introduction</chapter>
|
<chapter>Introduction</chapter>
|
||||||
|
|
||||||
<p><index id="btex language" /><btex /> is a markup language based on XML, with a resemblance of the <latex />.
|
<p><index id="btex language"/><btex/> is a markup language based on XML, with a resemblance of the <latex/>.
|
||||||
<btex /> abstracts away the meticulous styling and typesetting configurations, so you can focus on
|
<btex/> abstracts away the meticulous styling and typesetting configurations, so you can focus on
|
||||||
actually writing your texts than debugging the <latex /> macros. This does come with a downside of
|
actually writing your texts than debugging the <latex/> macros. This does come with a downside of
|
||||||
not being able to change the given style.</p>
|
not being able to change the given style.</p>
|
||||||
<p><btex /> document is divided up to five parts: the <a href="btexdoc">Style Declaration</a>, the
|
<p><btex/> document is divided up to five parts: the <a href="btexdoc">Style Declaration</a>, the
|
||||||
<a href="cover">Cover</a>, the <a href="table of contents">Table of Contents</a>, the
|
<a href="cover">Cover</a>, the <a href="table of contents">Table of Contents</a>, the
|
||||||
<a href="manuscript">Manuscript</a>, and the <a href="index page">Index Page</a>, of which the
|
<a href="manuscript">Manuscript</a>, and the <a href="index page">Index Page</a>, of which the
|
||||||
Style Declaration and the Manuscript are the mandatory parts.</p>
|
Style Declaration and the Manuscript are the mandatory parts.</p>
|
||||||
@@ -59,14 +59,14 @@
|
|||||||
|
|
||||||
<chapter>The Style Declaration</chapter>
|
<chapter>The Style Declaration</chapter>
|
||||||
|
|
||||||
<p><index id="btexdoc" />The Style Declaration is the very first line of a <btex /> document. Its syntax is as follows:</p>
|
<p><index id="btexdoc"/>The Style Declaration is the very first line of a <btex/> document. Its syntax is as follows:</p>
|
||||||
|
|
||||||
<pbox>
|
<pbox align="left" class="code">
|
||||||
<index id="btexdoc (tag)" />
|
<index id="btexdoc (tag)"/>
|
||||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||||
</pbox>
|
</pbox>
|
||||||
|
|
||||||
<p>The <code>btexdoc</code> tag takes three attributes:<br />
|
<p>The <code>btexdoc</code> tag takes three attributes:<br/>
|
||||||
<code>cover</code>, <code>inner</code> and <code>papersize</code>.</p>
|
<code>cover</code>, <code>inner</code> and <code>papersize</code>.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>cover</code> — changes the style of the cover. Possible values: <code>hardcover</code>, <code>none</code></li>
|
<li><code>cover</code> — changes the style of the cover. Possible values: <code>hardcover</code>, <code>none</code></li>
|
||||||
@@ -76,19 +76,19 @@
|
|||||||
|
|
||||||
<chapter>The Cover</chapter>
|
<chapter>The Cover</chapter>
|
||||||
|
|
||||||
<p><index id="cover" />The Cover defines the text on the cover of the book. If your text has no cover, this part can be omitted. Its syntax is as follows:</p>
|
<p><index id="cover"/>The Cover defines the text on the cover of the book. If your text has no cover, this part can be omitted. Its syntax is as follows:</p>
|
||||||
<pbox>
|
<pbox align="left" class="code">
|
||||||
<index id="cover (tag)" />
|
<index id="cover (tag)"/>
|
||||||
<index id="title (tag)" />
|
<index id="title (tag)"/>
|
||||||
<index id="subtitle (tag)" />
|
<index id="subtitle (tag)"/>
|
||||||
<index id="author (tag)" />
|
<index id="author (tag)"/>
|
||||||
<index id="edition (tag)" />
|
<index id="edition (tag)"/>
|
||||||
<cover>
|
<cover>
|
||||||
<title>Title of your book</title>
|
<title>Title of your book</title>
|
||||||
<subtitle>Subtitle if necessary</subtitle>
|
<subtitle>Subtitle if necessary</subtitle>
|
||||||
<author>Who wrote this book</author>
|
<author>Who wrote this book</author>
|
||||||
<edition>Edition information if necessary</edition>
|
<edition>Edition information if necessary</edition>
|
||||||
</cover>
|
</cover>
|
||||||
</pbox>
|
</pbox>
|
||||||
<p>Only the <code>title</code> tag is mandatory. Cover texts will be printed using a special font that has wider
|
<p>Only the <code>title</code> tag is mandatory. Cover texts will be printed using a special font that has wider
|
||||||
gaps between characters. The title text will be printed in a double-size.</p>
|
gaps between characters. The title text will be printed in a double-size.</p>
|
||||||
@@ -96,59 +96,59 @@
|
|||||||
|
|
||||||
<chapter>The Table of Contents</chapter>
|
<chapter>The Table of Contents</chapter>
|
||||||
|
|
||||||
<p><index id="table of contents" />The contents of the Table of Contents is filled in automatically by reading through your manuscript;
|
<p><index id="table of contents"/>The contents of the Table of Contents is filled in automatically by reading through your manuscript;
|
||||||
parts, chapters and sections will be added. Its syntax is as follows:</p>
|
parts, chapters and sections will be added. Its syntax is as follows:</p>
|
||||||
|
|
||||||
<pbox>
|
<pbox align="left" class="code">
|
||||||
<index id="tocpage (tag)" />
|
<index id="tocpage (tag)"/>
|
||||||
<tocpage title="Custom page name if necessary"><tableofcontents /></tocpage>
|
<tocpage title="Custom page name if necessary"><tableofcontents/></tocpage>
|
||||||
</pbox>
|
</pbox>
|
||||||
|
|
||||||
<p>The optional <code>title</code> attribute allows a custom name can be given to this page.
|
<p>The optional <code>title</code> attribute allows a custom name can be given to this page.
|
||||||
If unspecified, the default name is “Table of Contents”.</p>
|
If unspecified, the default name is “Table of Contents”.</p>
|
||||||
<p>The tag <code><tableofcontents /></code> is an internal tag used by the typesetter.</p>
|
<p>The tag <code><tableofcontents/></code> is an internal tag used by the typesetter.</p>
|
||||||
|
|
||||||
|
|
||||||
<chapter>The Manuscript</chapter>
|
<chapter>The Manuscript</chapter>
|
||||||
|
|
||||||
<p><index id="manuscript" /><index id="tags" />This is the part where you actually write your body texts in. The body text can have the following tags:</p>
|
<p><index id="manuscript"/><index id="tags"/>This is the part where you actually write your body texts in. The body text can have the following tags:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><index id="part (tag)" /><code>part</code> — inserts part separation page to your book</li>
|
<li><index id="part (tag)"/><code>part</code> — inserts part separation page to your book</li>
|
||||||
<li><index id="chapter (tag)" /><index id="section (tag)" /><code>chapter</code>, <code>section</code> — inserts a new chapter/section. If an alternative name is required on the Table of Contents, the <code>alt</code> attribute can be used. If the chapter/section needs to be hidden on the Table of Contents, add the <code>hide="1"</code> attribute. If the chapter must start on a new page, simply add <code>newpage</code> in front of the chapter tag</li>
|
<li><index id="chapter (tag)"/><index id="section (tag)"/><code>chapter</code>, <code>section</code> — inserts a new chapter/section. If an alternative name is required on the Table of Contents, the <code>alt</code> attribute can be used. If the chapter/section needs to be hidden on the Table of Contents, add the <code>hide="1"</code> attribute. If the chapter must start on a new page, simply add <code>newpage</code> in front of the chapter tag</li>
|
||||||
<li><index id="p (tag)" /><code>p</code> — inserts a new paragraph. The body texts must be written inside this tag. All paragraphs will have a 16-pixel indentation, with the following exceptions: first <code>p</code> of the part/chapter/section; first <code>p</code> after <code>br</code>, <code>newpage</code>, <code>pbox</code>, <code>ul</code>, <code>ol</code> or <code>anonbreak</code></li>
|
<li><index id="p (tag)"/><code>p</code> — inserts a new paragraph. The body texts must be written inside this tag. All paragraphs will have a 16-pixel indentation, with the following exceptions: first <code>p</code> of the part/chapter/section; first <code>p</code> after <code>br</code>, <code>newpage</code>, <code>pbox</code>, <code>ul</code>, <code>ol</code> or <code>anonbreak</code></li>
|
||||||
<li><index id="span (tag)" /><code>span</code> — allows changing the colour of the texts. The colour must be specified in the <code>colour</code> attribute. Six-digit hex code, three-digit hex code and CSS Colors Level 4 named colours are supported. Note that all the colours will be rounded to the nearest three-digit hex code</li>
|
<li><index id="span (tag)"/><code>span</code> — allows changing the colour of the texts. The colour must be specified in the <code>colour</code> attribute. Six-digit hex code, three-digit hex code and CSS Colors Level 4 named colours are supported. Note that all the colours will be rounded to the nearest three-digit hex code</li>
|
||||||
<li><index id="emph (tag)" /><code>emph</code> — is a special case of the <code>span</code> tag. The resulting text will be <emph>red</emph></li>
|
<li><index id="emph (tag)"/><code>emph</code> — is a special case of the <code>span</code> tag. The resulting text will be <emph>red</emph></li>
|
||||||
<li><index id="itemname (tag)" /><code>itemname</code> — is a special case of the <code>span</code> tag used to highlight the name of the ingame item. The resulting text will be <itemname>blue</itemname></li>
|
<li><index id="itemname (tag)"/><code>itemname</code> — is a special case of the <code>span</code> tag used to highlight the name of the ingame item. The resulting text will be <itemname>blue</itemname></li>
|
||||||
<li><index id="targetname (tag)" /><code>targetname</code> — is a special case of the <code>span</code> tag used to highlight the name of an arbitrary target or goals. The resulting text will be <targetname>green</targetname></li>
|
<li><index id="targetname (tag)"/><code>targetname</code> — is a special case of the <code>span</code> tag used to highlight the name of an arbitrary target or goals. The resulting text will be <targetname>green</targetname></li>
|
||||||
<li><index id="code (tag)" /><code>code</code> — is a special case of the <code>span</code> tag used to highlight the code element in-line. The resulting text will be <code>surrounded in a grey box</code></li>
|
<li><index id="code (tag)"/><code>code</code> — is a special case of the <code>span</code> tag used to highlight the code element in-line. The resulting text will be <code>surrounded in a grey box</code></li>
|
||||||
<li><index id="br (tag)" /><code>br</code> — self-closing tag; inserts an anonymous line break</li>
|
<li><index id="br (tag)"/><code>br</code> — self-closing tag; inserts an anonymous line break</li>
|
||||||
<li><index id="newpage (tag)" /><code>newpage</code> — self-closing tag; inserts an anonymous page break</li>
|
<li><index id="newpage (tag)"/><code>newpage</code> — self-closing tag; inserts an anonymous page break</li>
|
||||||
<li><index id="anonbreak (tag)" /><code>anonbreak</code> — self-closing tag; inserts a paragraph break in the text. The break will be in a form of a long straight line on the centre of the text. Useful for typesetting novels</li>
|
<li><index id="anonbreak (tag)"/><code>anonbreak</code> — self-closing tag; inserts a paragraph break in the text. The break will be in a form of a long straight line on the centre of the text. Useful for typesetting novels</li>
|
||||||
<li><index id="pbox (tag)" /><code>pbox</code> — is a paragraph box that holds a text in a grey box, a style similar to the <code>code</code> tag</li>
|
<li><index id="pbox (tag)"/><code>pbox</code> — is a paragraph box that holds a text in a grey box, a style similar to the <code>code</code> tag</li>
|
||||||
<li><index id="ul (tag)" /><index id="li (tag)" /><code>ul</code> — starts an unordered list. List elements are defined using the <code>li</code> tag</li>
|
<li><index id="ul (tag)"/><index id="li (tag)"/><code>ul</code> — starts an unordered list. List elements are defined using the <code>li</code> tag</li>
|
||||||
<li><index id="ol (tag)" /><code>ol</code> — starts an ordered list. List elements are defined using the <code>li</code> tag</li>
|
<li><index id="ol (tag)"/><code>ol</code> — starts an ordered list. List elements are defined using the <code>li</code> tag</li>
|
||||||
<li><index id="fullpagebox (tag)" /><code>fullpagebox</code> — is used to typeset its child tags into a box that fills an entire page, with its contents centred on the page. Must be used after the <code>newpage</code></li>
|
<li><index id="fullpagebox (tag)"/><code>fullpagebox</code> — is used to typeset its child tags into a box that fills an entire page, with its contents centred on the page. Must be used after the <code>newpage</code></li>
|
||||||
<li><index id="btex (tag)" /><code>btex</code> — self-closing tag; inserts an inline form of the <btex /> logo in the text</li>
|
<li><index id="btex (tag)"/><code>btex</code> — self-closing tag; inserts an inline form of the <btex/> logo in the text</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Self-closing tags have no child tags. To use a self-closing tag, simply do <code><tagname /></code>.</p>
|
<p>Self-closing tags have no child tags. To use a self-closing tag, simply do <code><tagname/></code>.</p>
|
||||||
|
|
||||||
|
|
||||||
<section>Hyperlinking</section>
|
<section>Hyperlinking</section>
|
||||||
|
|
||||||
<p><index id="hyperlink" />Hyperlinks can be defined using <code>index</code> and <code>a</code> tags.</p>
|
<p><index id="hyperlink"/>Hyperlinks can be defined using <code>index</code> and <code>a</code> tags.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><index id="index (tag)" /><code>index</code> — will define a target for a link. Indices require a unique identifier to work as a link, and the identifier must be defined in the <code>id</code> attribute</li>
|
<li><index id="index (tag)"/><code>index</code> — will define a target for a link. Indices require a unique identifier to work as a link, and the identifier must be defined in the <code>id</code> attribute</li>
|
||||||
<li><index id="a (tag)" /><code>a</code> — will make its child texts to be clickable. The link target (index identifier) must be defined in the <code>href</code> attribute</li>
|
<li><index id="a (tag)"/><code>a</code> — will make its child texts to be clickable. The link target (index identifier) must be defined in the <code>href</code> attribute</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<chapter>The Index Page</chapter>
|
<chapter>The Index Page</chapter>
|
||||||
|
|
||||||
<p><index id="index page" />The contents of the Index Page is filled in automatically by reading through your manuscript.
|
<p><index id="index page"/>The contents of the Index Page is filled in automatically by reading through your manuscript.
|
||||||
All the usage of <code>index</code> tags will be shown here. Its syntax is as follows:</p>
|
All the usage of <code>index</code> tags will be shown here. Its syntax is as follows:</p>
|
||||||
|
|
||||||
<pbox>
|
<pbox align="left" class="code">
|
||||||
<index id="indexpage (tag)" />
|
<index id="indexpage (tag)"/>
|
||||||
<indexpage title="Custom page name if necessary"><tableofindices /></indexpage>
|
<indexpage title="Custom page name if necessary"><tableofindices/></indexpage>
|
||||||
</pbox>
|
</pbox>
|
||||||
|
|
||||||
<p>The optional <code>title</code> attribute allows a custom name can be given to this page. If unspecified,
|
<p>The optional <code>title</code> attribute allows a custom name can be given to this page. If unspecified,
|
||||||
@@ -157,18 +157,18 @@
|
|||||||
|
|
||||||
<chapter>Ending the Document</chapter>
|
<chapter>Ending the Document</chapter>
|
||||||
|
|
||||||
<p>The <btex /> document must begin with the opening <code>btexdoc</code> tag, and therefore must
|
<p>The <btex/> document must begin with the opening <code>btexdoc</code> tag, and therefore must
|
||||||
end with a matching closing tag. Simply write away <code></btexdoc></code> and the
|
end with a matching closing tag. Simply write away <code></btexdoc></code> and the
|
||||||
document is finished.</p>
|
document is finished.</p>
|
||||||
|
|
||||||
|
|
||||||
<chapter>Conclusion</chapter>
|
<chapter>Conclusion</chapter>
|
||||||
|
|
||||||
<p>The finished book description using <btex /> can be sent to a publisher, and if there are no errors
|
<p>The finished book description using <btex/> can be sent to a publisher, and if there are no errors
|
||||||
on your submission, the printed books of specified number of copies will be delivered to your
|
on your submission, the printed books of specified number of copies will be delivered to your
|
||||||
location within a reasonable amount of business days. Happy writing!</p>
|
location within a reasonable amount of business days. Happy writing!</p>
|
||||||
|
|
||||||
<newpage />
|
<newpage/>
|
||||||
|
|
||||||
<fullpagebox>
|
<fullpagebox>
|
||||||
<p><span colour="#666">this page is intentionally left blank</span></p>
|
<p><span colour="#666">this page is intentionally left blank</span></p>
|
||||||
@@ -176,5 +176,5 @@
|
|||||||
|
|
||||||
</manuscript>
|
</manuscript>
|
||||||
|
|
||||||
<indexpage><tableofindices /></indexpage>
|
<indexpage><tableofindices/></indexpage>
|
||||||
</btexdoc>
|
</btexdoc>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,178 +1,21 @@
|
|||||||
|
<!DOCTYPE btexdoc SYSTEM "btexdoc.dtd">
|
||||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||||
<cover>
|
|
||||||
<title>The Way to Mastery of<br />Lorem Ipsum</title>
|
|
||||||
<subtitle>Or, How To Write and Publish a Book</subtitle>
|
|
||||||
<author>Terran Publishing</author>
|
|
||||||
<edition>Test Edition</edition>
|
|
||||||
</cover>
|
|
||||||
|
|
||||||
<tocpage><tableofcontents /></tocpage>
|
|
||||||
|
|
||||||
<manuscript>
|
<manuscript>
|
||||||
<part>The Book</part>
|
|
||||||
|
|
||||||
<chapter>What Is a Book</chapter>
|
|
||||||
|
|
||||||
<p>This example book is written to give readers the example of the Book Language.</p>
|
|
||||||
|
|
||||||
<section hide="1">What Qualifies as a Book</section>
|
|
||||||
|
|
||||||
<p><index id="the book" />Under the book typesetting system, a Book is a collection of texts typesetted for an improved
|
|
||||||
legibility, enumerable pages, with insertion of other helpful resources such as illustrations
|
|
||||||
and <a href="hyperlink">hyperlinks</a>.</p>
|
|
||||||
<p>Books are considered as bound and always presented in two pages for reading.</p>
|
|
||||||
|
|
||||||
<chapter>Writing a Book Using a Typewriter</chapter>
|
|
||||||
|
|
||||||
<p><index id="typewriter" />Typewriter allows quick scribbling of the words in convenient manners, just click on them and get
|
|
||||||
writing!</p>
|
|
||||||
<p>But it comes with big downsides: you cannot type in multiple writing systems, cannot have defined
|
|
||||||
chapters and sections, cannot include any illustrations, no hyperlinks, and of course, ragged texts.</p>
|
|
||||||
<p>Typed papers are considered as non-bound and only one page at a time will be presented.</p>
|
|
||||||
<p>All in all, you cannot write a true Book using a typewriter.</p>
|
|
||||||
|
|
||||||
<chapter>Writing a Book with Publishers and Printing Presses</chapter>
|
|
||||||
|
|
||||||
<p>Professional-looking texts, with all the benefits of a real Book can be made, or even mass-produced
|
|
||||||
easily with the help of publishers.</p>
|
|
||||||
<p>To have your precious texts to be printed, you must send your manuscripts to a publisher, and the
|
|
||||||
manuscript must be written in a special language: the <btex />.</p>
|
|
||||||
<p><btex /> allows concise description of the entire shape of your book, any style the book typesetting
|
|
||||||
system can support can be described and printing presses will produce the papers accordingly.
|
|
||||||
You can even try to mimic the look and feel of papers created using a typewriter, if you want to.</p>
|
|
||||||
|
|
||||||
|
|
||||||
<part>The <btex /></part>
|
|
||||||
|
|
||||||
<chapter>Introduction</chapter>
|
|
||||||
|
|
||||||
<p><index id="btex language" /><btex /> is a markup language based on XML, with a resemblance of the <latex />.
|
|
||||||
<btex /> abstracts away the meticulous styling and typesetting configurations, so you can focus on
|
|
||||||
actually writing your texts than debugging the <latex /> macros. This does come with a downside of
|
|
||||||
not being able to change the given style.</p>
|
|
||||||
<p><btex /> document is divided up to five parts: the <itemname>Style Declaration</itemname>, the
|
|
||||||
<itemname>Cover</itemname>, the <itemname>Table of Contents</itemname>, the
|
|
||||||
<itemname>Manuscript</itemname>, and the <itemname>Index Page</itemname>. Of which the
|
|
||||||
Style Declaration and the Manuscript is the mandatory parts.</p>
|
|
||||||
|
|
||||||
|
|
||||||
<chapter>The Style Declaration</chapter>
|
<chapter>The Style Declaration</chapter>
|
||||||
|
<p>Terrarum version <var id="terrarumver" />. The transaction fee is <bucks><var id="bucks" /></bucks></p>
|
||||||
<p><index id="btexdoc" />The Style Declaration is the very first line of a <btex /> document. Its syntax is as follows:</p>
|
<p><index id="btexdoc" />The Style Declaration is the very first line of a <btex /> document. Its syntax is as follows:</p>
|
||||||
|
<p>The <code>btexdoc</code> tag takes one attribute: <code>cover</code>.</p>
|
||||||
<pbox>
|
<p>The <code>btexdoc</code> tag takes two attributes: <code>cover</code> and <code>inner</code>.</p>
|
||||||
<index id="btexdoc (tag)" />
|
|
||||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
|
||||||
</pbox>
|
|
||||||
|
|
||||||
<p>The <code>btexdoc</code> tag takes three attributes: <code>cover</code>, <code>inner</code> and <code>papersize</code>.</p>
|
<p>The <code>btexdoc</code> tag takes three attributes: <code>cover</code>, <code>inner</code> and <code>papersize</code>.</p>
|
||||||
<ul>
|
<p>Test with excessive white spaces !!</p>
|
||||||
<li><code>cover</code> — changes the style of the cover. Possible values: <code>hardcover</code>, <code>none</code></li>
|
|
||||||
<li><code>inner</code> — changes the style of the body. Possible values: <code>standard</code>, <code>typewriter</code></li>
|
|
||||||
<li><code>papersize</code> — defines the size of the paper. Possible values: <code>standard</code></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<chapter>The Cover</chapter>
|
|
||||||
|
|
||||||
<p><index id="cover" />The Cover defines the text on the cover of the book. If your text has no cover, this part can be omitted. Its syntax is as follows:</p>
|
|
||||||
<pbox>
|
<pbox>
|
||||||
<index id="cover (tag)" />
|
A Callout!
|
||||||
<index id="title (tag)" />
|
|
||||||
<index id="subtitle (tag)" />
|
|
||||||
<index id="author (tag)" />
|
|
||||||
<index id="edition (tag)" />
|
|
||||||
<cover>
|
|
||||||
<title>Title of your book</title>
|
|
||||||
<subtitle>Subtitle if necessary</subtitle>
|
|
||||||
<author>Who wrote this book</author>
|
|
||||||
<edition>Edition information if necessary</edition>
|
|
||||||
</cover>
|
|
||||||
</pbox>
|
</pbox>
|
||||||
<p>Only the <code>title</code> tag is mandatory. Cover texts will be printed using a special font that has wider
|
<p>Another paragraph, another Lorem Ipsum. Eget duis at tellus at urna. Eget sit amet tellus cras adipiscing enim eu. Sit amet tellus cras adipiscing enim eu turpis egestas. Aliquam faucibus purus in massa tempor. Eget nullam non nisi est sit amet. Eu ultrices vitae auctor eu augue ut lectus. Tortor at auctor urna nunc.Quam lacus suspendisse faucibus interdum posuere lorem ipsum.</p>
|
||||||
gaps between characters. The title text will be printed in a double-size.</p>
|
<pbox align="left" class="code">
|
||||||
|
Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph Long Pbox paragraph
|
||||||
|
|
||||||
<chapter>The Table of Contents</chapter>
|
|
||||||
|
|
||||||
<p><index id="table of contents" />The contents of the Table of Contents is filled in automatically by reading through your manuscript;
|
|
||||||
parts, chapters and sections will be added. Its syntax is as follows:</p>
|
|
||||||
|
|
||||||
<pbox>
|
|
||||||
<index id="tocpage (tag)" />
|
|
||||||
<tocpage title="Custom page name if necessary"><tableofcontents /></tocpage>
|
|
||||||
</pbox>
|
</pbox>
|
||||||
|
<p>Yet another paragraph, another Lorem Ipsum. Eget duis at tellus at urna. Eget sit amet tellus cras adipiscing enim eu. Sit amet tellus cras adipiscing enim eu turpis egestas. Aliquam faucibus purus in massa tempor. Eget nullam non nisi est sit amet. Eu ultrices vitae auctor eu augue ut lectus. Tortor at auctor urna nunc.Quam lacus suspendisse faucibus interdum posuere lorem ipsum.</p>
|
||||||
<p>The optional <code>title</code> attribute allows a custom name can be given to this page.
|
|
||||||
If unspecified, the default name is “Table of Contents”.</p>
|
|
||||||
<p>The tag <code><tableofcontents /></code> is an internal tag used by the typesetter.</p>
|
|
||||||
|
|
||||||
|
|
||||||
<chapter>The Manuscript</chapter>
|
|
||||||
|
|
||||||
<p><index id="manuscript" /><index id="tags" />This is the part where you actually write your body texts in. The body text can have the following tags:</p>
|
|
||||||
<ul>
|
|
||||||
<li><index id="part (tag)" /><code>part</code> — inserts part separation page to your book</li>
|
|
||||||
<li><index id="chapter (tag)" /><index id="section (tag)" /><code>chapter</code>, <code>section</code> — inserts a new chapter/section. If an alternative name is required on the Table of Contents, the <code>alt</code> attribute can be used. If the chapter/section needs to be hidden on the Table of Contents, add the <code>hide="1"</code> attribute. If the chapter must start on a new page, simply add <code>newpage</code> in front of the chapter tag</li>
|
|
||||||
<li><index id="p (tag)" /><code>p</code> — inserts a new paragraph. The body texts must be written inside this tag. All paragraphs will have a 16-pixel indentation, with the following exceptions: first <code>p</code> of the part/chapter/section; first <code>p</code> after <code>br</code>, <code>newpage</code>, <code>pbox</code>, <code>ul</code>, <code>ol</code> or <code>anonbreak</code></li>
|
|
||||||
<li><index id="span (tag)" /><code>span</code> — allows changing the colour of the texts. The colour must be specified in the <code>colour</code> attribute. Six-digit hex code, three-digit hex code and CSS Colors Level 4 named colours are supported. Note that all the colours will be rounded to the nearest three-digit hex code</li>
|
|
||||||
<li><index id="emph (tag)" /><code>emph</code> — is a special case of the <code>span</code> tag. The resulting text will be <emph>red</emph></li>
|
|
||||||
<li><index id="itemname (tag)" /><code>itemname</code> — is a special case of the <code>span</code> tag used to highlight the name of the ingame item. The resulting text will be <itemname>blue</itemname></li>
|
|
||||||
<li><index id="targetname (tag)" /><code>targetname</code> — is a special case of the <code>span</code> tag used to highlight the name of an arbitrary target or goals. The resulting text will be <targetname>green</targetname></li>
|
|
||||||
<li><index id="code (tag)" /><code>code</code> — is a special case of the <code>span</code> tag used to highlight the code element in-line. The resulting text will be <code>surrounded in a grey box</code></li>
|
|
||||||
<li><index id="br (tag)" /><code>br</code> — self-closing tag; inserts an anonymous line break</li>
|
|
||||||
<li><index id="newpage (tag)" /><code>newpage</code> — self-closing tag; inserts an anonymous page break</li>
|
|
||||||
<li><index id="anonbreak (tag)" /><code>anonbreak</code> — self-closing tag; inserts a paragraph break in the text. The break will be in a form of a long straight line on the centre of the text. Useful for typesetting novels</li>
|
|
||||||
<li><index id="pbox (tag)" /><code>pbox</code> — is a paragraph box that holds a text in a grey box, a style similar to the <code>code</code> tag</li>
|
|
||||||
<li><index id="ul (tag)" /><index id="li (tag)" /><code>ul</code> — starts an unordered list. List elements are defined using the <code>li</code> tag</li>
|
|
||||||
<li><index id="ol (tag)" /><code>ol</code> — starts an ordered list. List elements are defined using the <code>li</code> tag</li>
|
|
||||||
<li><index id="fullpagebox (tag)" /><code>fullpagebox</code> — is used to typeset its child tags into a box that fills an entire page, with its contents centred on the page. Must be used after the <code>newpage</code></li>
|
|
||||||
<li><index id="btex (tag)" /><code>btex</code> — self-closing tag; inserts an inline form of the <btex /> logo in the text</li>
|
|
||||||
</ul>
|
|
||||||
<p>Self-closing tags have no child tags. To use a self-closing tag, simply do <code><tagname /></code>.</p>
|
|
||||||
|
|
||||||
|
|
||||||
<section>Hyperlinking</section>
|
|
||||||
|
|
||||||
<p><index id="hyperlink" />Hyperlinks can be defined using <code>index</code> and <code>a</code> tags.</p>
|
|
||||||
<ul>
|
|
||||||
<li><index id="index (tag)" /><code>index</code> — will define a target for a link. Indices require a unique identifier to work as a link, and the identifier must be defined in the <code>id</code> attribute</li>
|
|
||||||
<li><index id="a (tag)" /><code>a</code> — will make its child texts to be clickable. The link target (index identifier) must be defined in the <code>href</code> attribute</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<chapter>The Index Page</chapter>
|
|
||||||
|
|
||||||
<p><index id="index page" />The contents of the Index Page is filled in automatically by reading through your manuscript.
|
|
||||||
All the usage of <code>index</code> tags will be shown here. Its syntax is as follows:</p>
|
|
||||||
|
|
||||||
<pbox>
|
|
||||||
<index id="indexpage (tag)" />
|
|
||||||
<indexpage title="Custom page name if necessary"><tableofindices /></indexpage>
|
|
||||||
</pbox>
|
|
||||||
|
|
||||||
<p>The optional <code>title</code> attribute allows a custom name can be given to this page. If unspecified,
|
|
||||||
the default name is “Index”.</p>
|
|
||||||
|
|
||||||
|
|
||||||
<chapter>Ending the Document</chapter>
|
|
||||||
|
|
||||||
<p>The <btex /> document must begin with the opening <code>btexdoc</code> tag, and therefore must
|
|
||||||
end with a matching closing tag. Simply write away <code></btexdoc></code> and the
|
|
||||||
document is finished.</p>
|
|
||||||
|
|
||||||
|
|
||||||
<chapter>Conclusion</chapter>
|
|
||||||
|
|
||||||
<p>The finished book description using <btex /> can be sent to a publisher, and if there are no errors
|
|
||||||
on your submission, the printed books of specified number of copies will be delivered to your
|
|
||||||
location within a reasonable amount of business days. Happy writing!</p>
|
|
||||||
|
|
||||||
<newpage />
|
|
||||||
|
|
||||||
<fullpagebox>
|
|
||||||
<p><span colour="#666">this page is intentionally left blank</span></p>
|
|
||||||
</fullpagebox>
|
|
||||||
|
|
||||||
</manuscript>
|
</manuscript>
|
||||||
|
|
||||||
<indexpage><tableofindices /></indexpage>
|
|
||||||
</btexdoc>
|
</btexdoc>
|
||||||
|
|||||||
30
btexdoc.dtd
30
btexdoc.dtd
@@ -1,6 +1,12 @@
|
|||||||
<!ENTITY nbsp " ">
|
<!ENTITY nbsp " ">
|
||||||
<!ENTITY money "¤">
|
<!ENTITY money "¤">
|
||||||
|
|
||||||
|
<!ENTITY % ULStyle "(disc|square|circle)">
|
||||||
|
<!ENTITY % Number "CDATA">
|
||||||
|
<!ENTITY % LIStyle "CDATA">
|
||||||
|
<!ENTITY % OLStyle "CDATA">
|
||||||
|
|
||||||
|
<!ENTITY % counters "(i|I|1|a|A)">
|
||||||
<!ENTITY % special.extra "img">
|
<!ENTITY % special.extra "img">
|
||||||
<!ENTITY % special.basic "br | span | newpage">
|
<!ENTITY % special.basic "br | span | newpage">
|
||||||
<!ENTITY % special "%special.basic; | %special.extra;">
|
<!ENTITY % special "%special.basic; | %special.extra;">
|
||||||
@@ -26,6 +32,10 @@
|
|||||||
<!ENTITY % BTeXpapersize "papersize (standard) #IMPLIED">
|
<!ENTITY % BTeXpapersize "papersize (standard) #IMPLIED">
|
||||||
<!ENTITY % BTeXdefs "defs (mail|giro|examination) #IMPLIED">
|
<!ENTITY % BTeXdefs "defs (mail|giro|examination) #IMPLIED">
|
||||||
|
|
||||||
|
<!ENTITY % Countable
|
||||||
|
"type %counters; #IMPLIED
|
||||||
|
start %Number; #IMPLIED">
|
||||||
|
|
||||||
<!ENTITY % id-only "id CDATA #REQUIRED">
|
<!ENTITY % id-only "id CDATA #REQUIRED">
|
||||||
<!ENTITY % key-value
|
<!ENTITY % key-value
|
||||||
"key CDATA #REQUIRED
|
"key CDATA #REQUIRED
|
||||||
@@ -43,10 +53,6 @@
|
|||||||
<!ENTITY % block "p | %heading; | %lists; | %blocktext;">
|
<!ENTITY % block "p | %heading; | %lists; | %blocktext;">
|
||||||
<!ENTITY % Flow "(#PCDATA | %block; | %inline;)*">
|
<!ENTITY % Flow "(#PCDATA | %block; | %inline;)*">
|
||||||
|
|
||||||
<!ENTITY % ULStyle "(disc|square|circle)">
|
|
||||||
<!ENTITY % Number "CDATA">
|
|
||||||
<!ENTITY % LIStyle "CDATA">
|
|
||||||
|
|
||||||
<!ELEMENT btexdoc (cover?,tocpage?,manuscript,indexpage?)>
|
<!ELEMENT btexdoc (cover?,tocpage?,manuscript,indexpage?)>
|
||||||
<!ATTLIST btexdoc
|
<!ATTLIST btexdoc
|
||||||
%BTeXcover;
|
%BTeXcover;
|
||||||
@@ -75,13 +81,16 @@
|
|||||||
<!ATTLIST pbox %attrs; %TextAlign;>
|
<!ATTLIST pbox %attrs; %TextAlign;>
|
||||||
|
|
||||||
<!ELEMENT part %Inline;>
|
<!ELEMENT part %Inline;>
|
||||||
<!ATTLIST part %HeadingAttr;>
|
<!ATTLIST part
|
||||||
|
%HeadingAttr;
|
||||||
|
%Countable;
|
||||||
|
>
|
||||||
<!ELEMENT chapter %Inline;>
|
<!ELEMENT chapter %Inline;>
|
||||||
<!ATTLIST chapter %HeadingAttr;>
|
<!ATTLIST chapter %HeadingAttr; %Countable;>
|
||||||
<!ELEMENT section %Inline;>
|
<!ELEMENT section %Inline;>
|
||||||
<!ATTLIST section %HeadingAttr;>
|
<!ATTLIST section %HeadingAttr; %Countable;>
|
||||||
<!ELEMENT subsection %Inline;>
|
<!ELEMENT subsection %Inline;>
|
||||||
<!ATTLIST subsection %HeadingAttr;>
|
<!ATTLIST subsection %HeadingAttr; %Countable;>
|
||||||
|
|
||||||
|
|
||||||
<!-- self-closing tags -->
|
<!-- self-closing tags -->
|
||||||
@@ -120,13 +129,10 @@
|
|||||||
type %ULStyle; #IMPLIED
|
type %ULStyle; #IMPLIED
|
||||||
compact (compact) #IMPLIED
|
compact (compact) #IMPLIED
|
||||||
>
|
>
|
||||||
<!ENTITY % OLStyle "CDATA">
|
|
||||||
<!ELEMENT ol (li)+>
|
<!ELEMENT ol (li)+>
|
||||||
<!ATTLIST ol
|
<!ATTLIST ol
|
||||||
%attrs;
|
%attrs;
|
||||||
type %OLStyle; #IMPLIED
|
%Countable;
|
||||||
compact (compact) #IMPLIED
|
|
||||||
start %Number; #IMPLIED
|
|
||||||
>
|
>
|
||||||
<!ELEMENT li %Flow;>
|
<!ELEMENT li %Flow;>
|
||||||
<!ATTLIST li
|
<!ATTLIST li
|
||||||
|
|||||||
BIN
lib/TerrarumSansBitmap.jar
LFS
BIN
lib/TerrarumSansBitmap.jar
LFS
Binary file not shown.
@@ -362,6 +362,8 @@ class BTeXDrawCall(
|
|||||||
println("code themed")
|
println("code themed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extraDrawFun(batch, px, py)
|
||||||
|
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|
||||||
if (text != null && cmd == null) {
|
if (text != null && cmd == null) {
|
||||||
@@ -371,8 +373,6 @@ class BTeXDrawCall(
|
|||||||
cmd.draw(doc, batch, px, py, font)
|
cmd.draw(doc, batch, px, py, font)
|
||||||
}
|
}
|
||||||
else throw Error("Text and Texture are both non-null")
|
else throw Error("Text and Texture are both non-null")
|
||||||
|
|
||||||
extraDrawFun(batch, px, py)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isNotBlank(): Boolean {
|
fun isNotBlank(): Boolean {
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ import net.torvald.terrarum.btex.BTeXDrawCall
|
|||||||
import net.torvald.terrarum.btex.TypesetDrawCall
|
import net.torvald.terrarum.btex.TypesetDrawCall
|
||||||
import net.torvald.terrarum.ceilToFloat
|
import net.torvald.terrarum.ceilToFloat
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
|
import net.torvald.terrarum.modulebasegame.console.GetAV.isNum
|
||||||
import net.torvald.terrarum.toHex
|
import net.torvald.terrarum.toHex
|
||||||
import net.torvald.terrarum.tryDispose
|
import net.torvald.terrarum.tryDispose
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
import net.torvald.terrarumsansbitmap.MovableType
|
import net.torvald.terrarumsansbitmap.MovableType
|
||||||
|
import net.torvald.terrarumsansbitmap.TypesettingStrategy
|
||||||
import net.torvald.terrarumsansbitmap.gdx.CodepointSequence
|
import net.torvald.terrarumsansbitmap.gdx.CodepointSequence
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
||||||
import net.torvald.unicode.CURRENCY
|
import net.torvald.unicode.CURRENCY
|
||||||
@@ -98,9 +100,16 @@ object BTeXParser {
|
|||||||
private val elemClosers: HashMap<String, KFunction<*>> = HashMap()
|
private val elemClosers: HashMap<String, KFunction<*>> = HashMap()
|
||||||
|
|
||||||
private val paragraphBuffer = StringBuilder()
|
private val paragraphBuffer = StringBuilder()
|
||||||
|
private var currentAlign = "justify"
|
||||||
|
|
||||||
fun clearParBuffer() {
|
fun clearParBuffer() {
|
||||||
paragraphBuffer.clear()
|
paragraphBuffer.clear()
|
||||||
|
currentAlign = "justify"
|
||||||
|
codeMode = false
|
||||||
|
hrefMode = false
|
||||||
|
bucksMode = false
|
||||||
|
spanColour = null
|
||||||
|
currentTheme = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private val objDict = HashMap<String, (BTeXDrawCall) -> BTeXBatchDrawCall>()
|
private val objDict = HashMap<String, (BTeXDrawCall) -> BTeXBatchDrawCall>()
|
||||||
@@ -109,9 +118,9 @@ object BTeXParser {
|
|||||||
private var lastTagAtDepth = Array(24) { "" }
|
private var lastTagAtDepth = Array(24) { "" }
|
||||||
private var pTagCntAtDepth = IntArray(24)
|
private var pTagCntAtDepth = IntArray(24)
|
||||||
|
|
||||||
private data class CptSect(val type: String, var alt: String?)
|
private data class CptSect(val type: String, var alt: String?, var style: String, var start: Int? = null)
|
||||||
private data class CptSectInfo(val type: String, var name: String, var pagenum: Int,
|
private data class CptSectInfo(val type: String, var name: String, var pagenum: Int,
|
||||||
var partNum: Int?, var cptNum: Int?, var sectNum: Int?)
|
var partNum: String?, var cptNum: String?, var sectNum: String?)
|
||||||
|
|
||||||
private val cptSectStack = ArrayList<CptSect>()
|
private val cptSectStack = ArrayList<CptSect>()
|
||||||
|
|
||||||
@@ -129,6 +138,14 @@ object BTeXParser {
|
|||||||
private val bodyTextShadowAlpha = 0.36f
|
private val bodyTextShadowAlpha = 0.36f
|
||||||
|
|
||||||
|
|
||||||
|
private fun Int.toListNumStr(style: String) = when (style) {
|
||||||
|
"I" -> this.toRomanNum()
|
||||||
|
"i" -> this.toRomanNum().lowercase()
|
||||||
|
"1" -> this.toString()
|
||||||
|
"A" -> this.toAlphabetic()
|
||||||
|
"a" -> this.toAlphabetic().lowercase()
|
||||||
|
else -> throw IllegalArgumentException("Unknown list number style: $style")
|
||||||
|
}
|
||||||
|
|
||||||
private fun StringBuilder.appendObjectPlaceholder(id: String) {
|
private fun StringBuilder.appendObjectPlaceholder(id: String) {
|
||||||
(objWidthDict[id] ?: throw NullPointerException("No OBJ with id '$id' exists")).let {
|
(objWidthDict[id] ?: throw NullPointerException("No OBJ with id '$id' exists")).let {
|
||||||
@@ -314,27 +331,27 @@ object BTeXParser {
|
|||||||
private var oldBucksMode = false
|
private var oldBucksMode = false
|
||||||
private val CODE_TAG_MARGIN = 2
|
private val CODE_TAG_MARGIN = 2
|
||||||
|
|
||||||
|
private fun spanColToColourCode(): String? {
|
||||||
|
val spanGdxCol = getSpanColourOrNull()
|
||||||
|
if (spanGdxCol == null) return null
|
||||||
|
return TerrarumSansBitmap.toColorCode(
|
||||||
|
spanGdxCol.r.times(15f).roundToInt(),
|
||||||
|
spanGdxCol.g.times(15f).roundToInt(),
|
||||||
|
spanGdxCol.b.times(15f).roundToInt()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override fun characters(ch: CharArray, start: Int, length: Int) {
|
override fun characters(ch: CharArray, start: Int, length: Int) {
|
||||||
val str =
|
var str =
|
||||||
String(ch.sliceArray(start until start + length)).replace('\n', ' ').replace(Regex(" +"), " ")//.trim()
|
String(ch.sliceArray(start until start + length)).replace('\n', ' ').replace(Regex(" +"), " ")//.trim()
|
||||||
|
|
||||||
if (str.isNotEmpty()) {
|
if (str.isNotEmpty()) {
|
||||||
// printdbg("Characters [col:${spanColour}] \t\"$str\"")
|
// printdbg("Characters [col:${spanColour}] \t\"$str\"")
|
||||||
// process span request
|
// process span request
|
||||||
|
val spanCC = spanColToColourCode()
|
||||||
|
|
||||||
if (spanColour != oldSpanColour || spanColour != null) {
|
if (spanColour != oldSpanColour || spanColour != null) {
|
||||||
|
paragraphBuffer.append(spanCC ?: ccDefault)
|
||||||
val spanGdxCol = getSpanColourOrNull()
|
|
||||||
|
|
||||||
if (spanGdxCol == null) {
|
|
||||||
paragraphBuffer.append(ccDefault)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
paragraphBuffer.append(TerrarumSansBitmap.toColorCode(
|
|
||||||
spanGdxCol.r.times(15f).roundToInt(),
|
|
||||||
spanGdxCol.g.times(15f).roundToInt(),
|
|
||||||
spanGdxCol.b.times(15f).roundToInt()
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// process code request
|
// process code request
|
||||||
@@ -350,7 +367,7 @@ object BTeXParser {
|
|||||||
// getOrPutCodeTagRef(w)
|
// getOrPutCodeTagRef(w)
|
||||||
// paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
// paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
||||||
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
||||||
paragraphBuffer.append(ccCode)
|
paragraphBuffer.append(spanCC ?: ccCode)
|
||||||
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideCodestyle)
|
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideCodestyle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,12 +386,10 @@ object BTeXParser {
|
|||||||
if (bucksMode != oldBucksMode || bucksMode) {
|
if (bucksMode != oldBucksMode || bucksMode) {
|
||||||
if (!bucksMode) {
|
if (!bucksMode) {
|
||||||
paragraphBuffer.append(ccDefault)
|
paragraphBuffer.append(ccDefault)
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
paragraphBuffer.append(ccBucks)
|
paragraphBuffer.append(ccBucks)
|
||||||
val str2 = str.replace(' ', '\u00A0')
|
str = str.replace(' ', '\u00A0')
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,7 +768,7 @@ object BTeXParser {
|
|||||||
@OpenTag // reflective access is impossible with 'private'
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
fun processElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
fun processElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||||
handler.bucksMode = true
|
handler.bucksMode = true
|
||||||
handler.paragraphBuffer.append("$CURRENCY\u00A0")
|
handler.paragraphBuffer.append("$ccBucks$CURRENCY\u00A0")
|
||||||
}
|
}
|
||||||
@CloseTag
|
@CloseTag
|
||||||
fun closeElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
fun closeElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
||||||
@@ -776,14 +791,14 @@ object BTeXParser {
|
|||||||
fun processElemTOCPAGE(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
fun processElemTOCPAGE(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||||
doc.addNewPage() // toc: openright
|
doc.addNewPage() // toc: openright
|
||||||
val header = attribs["title"] ?: "Table of Contents"
|
val header = attribs["title"] ?: "Table of Contents"
|
||||||
typesetChapterHeading(null, header, handler, 16)
|
typesetChapterHeading(null, header, handler, PAR_INDENTATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OpenTag // reflective access is impossible with 'private'
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
fun processElemINDEXPAGE(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
fun processElemINDEXPAGE(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||||
if (doc.currentPageObj.isNotEmpty()) doc.addNewPage()
|
if (doc.currentPageObj.isNotEmpty()) doc.addNewPage()
|
||||||
val header = attribs["title"] ?: "Index"
|
val header = attribs["title"] ?: "Index"
|
||||||
typesetChapterHeading(null, header, handler, 16)
|
typesetChapterHeading(null, header, handler, PAR_INDENTATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OpenTag // reflective access is impossible with 'private'
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
@@ -850,14 +865,14 @@ object BTeXParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cptSectMap.forEach { (type, name, pg, part, cpt, sect) ->
|
cptSectMap.forEach { (type, name, pg, part, cpt, sect) ->
|
||||||
val indent = if (type == "subsection") 32 else if (type == "section") 16 else 0
|
val indent = if (type == "subsection") 2*PAR_INDENTATION else if (type == "section") PAR_INDENTATION else 0
|
||||||
val heading = if (part == null && cpt == null && sect == null)
|
val heading = if (part == null && cpt == null && sect == null)
|
||||||
""
|
""
|
||||||
else if (part != null && cpt == null && sect == null)
|
else if (part != null && cpt == null && sect == null)
|
||||||
"Part ${part.toRomanNum()}${glueToString(9)}"
|
"Part $part${glueToString(HEADING_NUM_TITLE_GAP)}"
|
||||||
else
|
else
|
||||||
listOfNotNull(cpt, sect).joinToString(".") + "${glueToString(9)}" +
|
listOfNotNull(cpt, sect).joinToString(".") + "${glueToString(HEADING_NUM_TITLE_GAP)}" +
|
||||||
(if (cpt != null && cpt < 10) "${glueToString(9)}" else "")
|
(if (cpt != null && cpt.length < 2 && cpt.isNum()) "${glueToString(HEADING_NUM_TITLE_GAP)}" else "")
|
||||||
|
|
||||||
typesetTOCline("$heading", name, pg, handler, indent, tocPage)
|
typesetTOCline("$heading", name, pg, handler, indent, tocPage)
|
||||||
}
|
}
|
||||||
@@ -926,9 +941,57 @@ object BTeXParser {
|
|||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
|
fun processElemPBOX(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||||
|
handler.clearParBuffer()
|
||||||
|
|
||||||
|
currentAlign = attribs["align"] ?: "justify"
|
||||||
|
|
||||||
|
if (attribs["class"] == "code") {
|
||||||
|
handler.codeMode = true
|
||||||
|
spanColour = "black"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@CloseTag // reflective access is impossible with 'private'
|
||||||
|
fun closeElemPBOX(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
||||||
|
// if this P is a very first P without chapters, leave two lines before typesetting
|
||||||
|
val penultTag = tagHistory.getOrNull(tagHistory.lastIndex - 1)
|
||||||
|
val thePar = handler.paragraphBuffer.toString().trim()
|
||||||
|
if (penultTag == "MANUSCRIPT")
|
||||||
|
doc.linesPrintedOnPage[doc.currentPage] += 2
|
||||||
|
|
||||||
|
|
||||||
|
typesetParagraphs("$ccDefault$thePar", handler, width = doc.textWidth - 2*MARGIN_PARBOX_H, align = handler.currentAlign).forEachIndexed { index, it ->
|
||||||
|
it.posX += MARGIN_PARBOX_H
|
||||||
|
it.deltaX += MARGIN_PARBOX_H
|
||||||
|
|
||||||
|
it.posY += doc.lineHeightInPx / 2
|
||||||
|
it.deltaY += doc.lineHeightInPx / 2
|
||||||
|
|
||||||
|
// add boxes
|
||||||
|
it.extraDrawFun = { batch, x, y ->
|
||||||
|
val width = it.width.toFloat()
|
||||||
|
val height = it.lineCount * doc.lineHeightInPx.toFloat()
|
||||||
|
|
||||||
|
val oldcol = batch.color.cpy()
|
||||||
|
batch.color = Color(0xccccccff.toInt())
|
||||||
|
Toolkit.fillArea(batch, x - MARGIN_PARBOX_H, y - MARGIN_PARBOX_V, width + 2*MARGIN_PARBOX_H, height + 2*MARGIN_PARBOX_V)
|
||||||
|
batch.color = Color(0x999999ff.toInt())
|
||||||
|
Toolkit.drawBoxBorder(batch, x - MARGIN_PARBOX_H, y - MARGIN_PARBOX_V, width + 2*MARGIN_PARBOX_H, height + 2*MARGIN_PARBOX_V)
|
||||||
|
batch.color = oldcol
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.linesPrintedOnPage[doc.currentPage] < doc.pageLines)
|
||||||
|
doc.linesPrintedOnPage[doc.currentPage] += 1
|
||||||
|
|
||||||
|
handler.clearParBuffer()
|
||||||
|
}
|
||||||
|
|
||||||
@CloseTag
|
@CloseTag
|
||||||
fun closeElemANONBREAK(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
fun closeElemANONBREAK(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
||||||
typesetParagraphs("${ccDefault}――――――――――――", handler).also {it.first().let {
|
typesetParagraphs("${ccDefault}――――――――――――", handler, align = "left").also {it.first().let {
|
||||||
it.posX += (doc.textWidth - it.width) / 2
|
it.posX += (doc.textWidth - it.width) / 2
|
||||||
} }
|
} }
|
||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
@@ -982,27 +1045,27 @@ object BTeXParser {
|
|||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
|
|
||||||
if (attribs["hide"] == null)
|
if (attribs["hide"] == null)
|
||||||
cptSectStack.add(CptSect("part", attribs["alt"]))
|
cptSectStack.add(CptSect("part", attribs["alt"], attribs["type"] ?: "I", attribs["start"]?.toInt()))
|
||||||
else
|
else
|
||||||
cptSectStack.add(CptSect("part-hidden", attribs["alt"]))
|
cptSectStack.add(CptSect("part-hidden", attribs["alt"], attribs["type"] ?: "I", attribs["start"]?.toInt()))
|
||||||
}
|
}
|
||||||
@OpenTag // reflective access is impossible with 'private'
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
fun processElemCHAPTER(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
fun processElemCHAPTER(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
|
|
||||||
if (attribs["hide"] == null)
|
if (attribs["hide"] == null)
|
||||||
cptSectStack.add(CptSect("chapter", attribs["alt"]))
|
cptSectStack.add(CptSect("chapter", attribs["alt"], attribs["type"] ?: "1", attribs["start"]?.toInt()))
|
||||||
else
|
else
|
||||||
cptSectStack.add(CptSect("chapter-hidden", attribs["alt"]))
|
cptSectStack.add(CptSect("chapter-hidden", attribs["alt"], attribs["type"] ?: "1", attribs["start"]?.toInt()))
|
||||||
}
|
}
|
||||||
@OpenTag // reflective access is impossible with 'private'
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
fun processElemSECTION(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
fun processElemSECTION(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
|
|
||||||
if (attribs["hide"] == null)
|
if (attribs["hide"] == null)
|
||||||
cptSectStack.add(CptSect("section", attribs["alt"]))
|
cptSectStack.add(CptSect("section", attribs["alt"], attribs["type"] ?: "1", attribs["start"]?.toInt()))
|
||||||
else
|
else
|
||||||
cptSectStack.add(CptSect("section-hidden", attribs["alt"]))
|
cptSectStack.add(CptSect("section-hidden", attribs["alt"], attribs["type"] ?: "1", attribs["start"]?.toInt()))
|
||||||
}
|
}
|
||||||
@CloseTag // reflective access is impossible with 'private'
|
@CloseTag // reflective access is impossible with 'private'
|
||||||
fun closeElemPART(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
fun closeElemPART(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
||||||
@@ -1011,11 +1074,13 @@ object BTeXParser {
|
|||||||
|
|
||||||
val partOrder = cptSectMap.count { it.type.startsWith("part") } + 1
|
val partOrder = cptSectMap.count { it.type.startsWith("part") } + 1
|
||||||
val thePar = handler.paragraphBuffer.toString().trim()
|
val thePar = handler.paragraphBuffer.toString().trim()
|
||||||
typesetPartHeading(partOrder, thePar, handler)
|
|
||||||
|
|
||||||
val cptSectInfo = cptSectStack.removeLast()
|
val cptSectInfo = cptSectStack.removeLast()
|
||||||
|
val partNumStr = partOrder.toListNumStr(cptSectInfo.style)
|
||||||
|
|
||||||
|
typesetPartHeading(partNumStr, thePar, handler)
|
||||||
if (!cptSectInfo.type.endsWith("-hidden"))
|
if (!cptSectInfo.type.endsWith("-hidden"))
|
||||||
cptSectMap.add(CptSectInfo("part", cptSectInfo.alt ?: thePar, doc.currentPage, partOrder, null, null))
|
cptSectMap.add(CptSectInfo("part", cptSectInfo.alt ?: thePar, doc.currentPage, partNumStr, null, null))
|
||||||
|
|
||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
}
|
}
|
||||||
@@ -1028,11 +1093,14 @@ object BTeXParser {
|
|||||||
val cptOrder = cptSectMap.count { it.type.startsWith("chapter") } + 1
|
val cptOrder = cptSectMap.count { it.type.startsWith("chapter") } + 1
|
||||||
|
|
||||||
val thePar = handler.paragraphBuffer.toString().trim()
|
val thePar = handler.paragraphBuffer.toString().trim()
|
||||||
typesetChapterHeading(cptOrder, thePar, handler, 16)
|
|
||||||
|
|
||||||
val cptSectInfo = cptSectStack.removeLast()
|
val cptSectInfo = cptSectStack.removeLast()
|
||||||
|
val partNumStr = partOrder.toListNumStr(cptSectStack.findLast { it.type.startsWith("part") }?.type ?: "1")
|
||||||
|
val cptNumStr = cptOrder.toListNumStr(cptSectInfo.style)
|
||||||
|
|
||||||
|
typesetChapterHeading(cptNumStr, thePar, handler, 16)
|
||||||
if (!cptSectInfo.type.endsWith("-hidden"))
|
if (!cptSectInfo.type.endsWith("-hidden"))
|
||||||
cptSectMap.add(CptSectInfo("chapter", cptSectInfo.alt ?: thePar, doc.currentPage, partOrder, cptOrder, null))
|
cptSectMap.add(CptSectInfo("chapter", cptSectInfo.alt ?: thePar, doc.currentPage, partNumStr, cptNumStr, null))
|
||||||
|
|
||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
}
|
}
|
||||||
@@ -1056,11 +1124,15 @@ object BTeXParser {
|
|||||||
|
|
||||||
|
|
||||||
val thePar = handler.paragraphBuffer.toString().trim()
|
val thePar = handler.paragraphBuffer.toString().trim()
|
||||||
typesetSectionHeading(cptOrder, sectOrder, thePar, handler, 8)
|
|
||||||
|
|
||||||
val cptSectInfo = cptSectStack.removeLast()
|
val cptSectInfo = cptSectStack.removeLast()
|
||||||
|
val partNumStr = partOrder.toListNumStr(cptSectStack.findLast { it.type.startsWith("part") }?.type ?: "1")
|
||||||
|
val cptNumStr = cptOrder.toListNumStr(cptSectStack.findLast { it.type.startsWith("chapter") }?.type ?: "1")
|
||||||
|
val sectNumStr = sectOrder.toListNumStr(cptSectInfo.style)
|
||||||
|
|
||||||
|
typesetSectionHeading("$cptNumStr.$sectNumStr", thePar, handler, 8)
|
||||||
if (!cptSectInfo.type.endsWith("-hidden"))
|
if (!cptSectInfo.type.endsWith("-hidden"))
|
||||||
cptSectMap.add(CptSectInfo("section", cptSectInfo.alt ?: thePar, doc.currentPage, partOrder, cptOrder, sectOrder))
|
cptSectMap.add(CptSectInfo("section", cptSectInfo.alt ?: thePar, doc.currentPage, partNumStr, cptNumStr, sectNumStr))
|
||||||
|
|
||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
}
|
}
|
||||||
@@ -1083,7 +1155,7 @@ object BTeXParser {
|
|||||||
// else, print the text normally
|
// else, print the text normally
|
||||||
else thePar
|
else thePar
|
||||||
|
|
||||||
typesetParagraphs(ccDefault + text, handler)
|
typesetParagraphs("$ccDefault$text", handler, align = handler.currentAlign)
|
||||||
|
|
||||||
handler.clearParBuffer()
|
handler.clearParBuffer()
|
||||||
}
|
}
|
||||||
@@ -1106,22 +1178,22 @@ object BTeXParser {
|
|||||||
|
|
||||||
private fun typesetBookTitle(thePar: String, handler: BTeXHandler) {
|
private fun typesetBookTitle(thePar: String, handler: BTeXHandler) {
|
||||||
val label = "\n${TerrarumSansBitmap.toColorCode(15, 15, 15)}" + thePar
|
val label = "\n${TerrarumSansBitmap.toColorCode(15, 15, 15)}" + thePar
|
||||||
typesetParagraphs(getTitleFont(), label, handler, doc.textWidth - 16).also {
|
typesetParagraphs(getTitleFont(), label, handler, doc.textWidth - 2*MARGIN_TITLE_TEXTS, align = "left").also {
|
||||||
val addedLines = it.sumOf { it.lineCount }
|
val addedLines = it.sumOf { it.lineCount }
|
||||||
doc.linesPrintedOnPage[doc.currentPage] += addedLines
|
doc.linesPrintedOnPage[doc.currentPage] += addedLines
|
||||||
|
|
||||||
it.forEach {
|
it.forEach {
|
||||||
it.posX += 8
|
it.posX += MARGIN_TITLE_TEXTS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typesetBookAuthor(thePar: String, handler: BTeXHandler) {
|
private fun typesetBookAuthor(thePar: String, handler: BTeXHandler) {
|
||||||
typesetParagraphs(getSubtitleFont(), "\n\n${TerrarumSansBitmap.toColorCode(15, 15, 15)}" + thePar, handler, doc.textWidth - 16).also {
|
typesetParagraphs(getSubtitleFont(), "\n\n${TerrarumSansBitmap.toColorCode(15, 15, 15)}" + thePar, handler, doc.textWidth - 2*MARGIN_TITLE_TEXTS, align = "left").also {
|
||||||
it.last().extraDrawFun = { batch, x, y ->
|
it.last().extraDrawFun = { batch, x, y ->
|
||||||
val px = x
|
val px = x
|
||||||
val py = y + 23
|
val py = y + doc.lineHeightInPx - 1
|
||||||
val pw = doc.textWidth - 16f
|
val pw = doc.textWidth - 2f * MARGIN_TITLE_TEXTS
|
||||||
batch.color = Color(1f,1f,1f,.5f)
|
batch.color = Color(1f,1f,1f,.5f)
|
||||||
Toolkit.fillArea(batch, px, py, pw+1, 2f)
|
Toolkit.fillArea(batch, px, py, pw+1, 2f)
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
@@ -1129,24 +1201,24 @@ object BTeXParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it.forEach {
|
it.forEach {
|
||||||
it.posX += 8
|
it.posX += MARGIN_TITLE_TEXTS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typesetBookEdition(thePar: String, handler: BTeXHandler) {
|
private fun typesetBookEdition(thePar: String, handler: BTeXHandler) {
|
||||||
typesetParagraphs(getSubtitleFont(), "${TerrarumSansBitmap.toColorCode(15, 15, 15)}" + thePar, handler, doc.textWidth - 16).also {
|
typesetParagraphs(getSubtitleFont(), "${TerrarumSansBitmap.toColorCode(15, 15, 15)}" + thePar, handler, doc.textWidth - 2*MARGIN_TITLE_TEXTS, align = "left").also {
|
||||||
it.forEach {
|
it.forEach {
|
||||||
it.posX += 8
|
it.posX += MARGIN_TITLE_TEXTS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typesetPartHeading(num: Int, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
private fun typesetPartHeading(num: String, thePar: String, handler: BTeXHandler, indent: Int = PAR_INDENTATION, width: Int = doc.textWidth) {
|
||||||
typesetParagraphs("${ccDefault}⁃ Part ${num.toRomanNum()} ⁃", handler)
|
typesetParagraphs("${ccDefault}⁃ Part $num ⁃", handler, align = "left")
|
||||||
typesetParagraphs(" ", handler)
|
typesetParagraphs(" ", handler, align = "left")
|
||||||
// typesetParagraphs(getTitleFont(), "$ccDefault$thePar", handler)
|
// typesetParagraphs(getTitleFont(), "$ccDefault$thePar", handler)
|
||||||
typesetParagraphs(getSubtitleFont(), "$ccDefault$thePar", handler)
|
typesetParagraphs(getSubtitleFont(), "$ccDefault$thePar", handler, align = "left")
|
||||||
|
|
||||||
// get global yDelta
|
// get global yDelta
|
||||||
doc.currentPageObj.let { page ->
|
doc.currentPageObj.let { page ->
|
||||||
@@ -1224,9 +1296,9 @@ object BTeXParser {
|
|||||||
doc.addNewPage()
|
doc.addNewPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typesetChapterHeading(chapNum: Int?, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
private fun typesetChapterHeading(num: String?, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
||||||
val header = if (chapNum == null) thePar else "$chapNum${glueToString(9)}$thePar"
|
val header = if (num == null) thePar else "$num${glueToString(9)}$thePar"
|
||||||
typesetParagraphs("\n$ccDefault$header", handler, width - indent).also {
|
typesetParagraphs("\n$ccDefault$header", handler, width - indent, align = "left").also {
|
||||||
// add indents and adjust text y pos
|
// add indents and adjust text y pos
|
||||||
it.forEach {
|
it.forEach {
|
||||||
it.posX += indent
|
it.posX += indent
|
||||||
@@ -1246,8 +1318,8 @@ object BTeXParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typesetSectionHeading(chapNum: Int, sectNum: Int, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
private fun typesetSectionHeading(num: String, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
||||||
typesetParagraphs("\n$ccDefault$chapNum.$sectNum${glueToString(9)}$thePar", handler, width - indent).also {
|
typesetParagraphs("\n$ccDefault$num${glueToString(9)}$thePar", handler, width - indent, align = "left").also {
|
||||||
// add indents and adjust text y pos
|
// add indents and adjust text y pos
|
||||||
it.forEach {
|
it.forEach {
|
||||||
it.posX += indent
|
it.posX += indent
|
||||||
@@ -1256,12 +1328,17 @@ object BTeXParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typesetParagraphs(thePar: String, handler: BTeXHandler, width: Int = doc.textWidth, startingPage: Int = doc.currentPage): List<BTeXDrawCall> {
|
private fun typesetParagraphs(thePar: String, handler: BTeXHandler, width: Int = doc.textWidth, startingPage: Int = doc.currentPage, align: String): List<BTeXDrawCall> {
|
||||||
return typesetParagraphs(getFont(), thePar, handler, width, startingPage)
|
return typesetParagraphs(getFont(), thePar, handler, width, startingPage, align)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typesetParagraphs(font: TerrarumSansBitmap, thePar: String, handler: BTeXHandler, width: Int = doc.textWidth, startingPage: Int = doc.currentPage): List<BTeXDrawCall> {
|
private fun typesetParagraphs(font: TerrarumSansBitmap, thePar: String, handler: BTeXHandler, width: Int = doc.textWidth, startingPage: Int = doc.currentPage, align: String): List<BTeXDrawCall> {
|
||||||
val slugs = MovableType(font, thePar, width)
|
val strat = when (align) {
|
||||||
|
"left" -> TypesettingStrategy.RAGGED_RIGHT
|
||||||
|
"justify" -> TypesettingStrategy.JUSTIFIED
|
||||||
|
else -> throw IllegalArgumentException("Unknown text alignment")
|
||||||
|
}
|
||||||
|
val slugs = MovableType(font, thePar, width, strat)
|
||||||
var pageNum = startingPage
|
var pageNum = startingPage
|
||||||
|
|
||||||
val drawCalls = ArrayList<BTeXDrawCall>()
|
val drawCalls = ArrayList<BTeXDrawCall>()
|
||||||
@@ -1389,7 +1466,7 @@ object BTeXParser {
|
|||||||
val dotGap = 10
|
val dotGap = 10
|
||||||
val dotPosEnd = typeWidth - pageNumWidth - dotGap*1.5f
|
val dotPosEnd = typeWidth - pageNumWidth - dotGap*1.5f
|
||||||
|
|
||||||
typesetParagraphs("$ccDefault$heading$name", handler, typeWidth, pageToWrite ?: doc.currentPage).let {
|
typesetParagraphs("$ccDefault$heading$name", handler, typeWidth, pageToWrite ?: doc.currentPage, align = "justify").let {
|
||||||
it.forEach {
|
it.forEach {
|
||||||
it.posX += indentation
|
it.posX += indentation
|
||||||
|
|
||||||
@@ -1430,9 +1507,15 @@ object BTeXParser {
|
|||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val MARGIN_PARBOX_V = 2
|
||||||
|
private const val MARGIN_PARBOX_H = 8
|
||||||
|
private const val MARGIN_TITLE_TEXTS = 8
|
||||||
|
private const val PAR_INDENTATION = 16
|
||||||
|
private const val HEADING_NUM_TITLE_GAP = 9
|
||||||
|
|
||||||
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
||||||
val ccBucks = TerrarumSansBitmap.toColorCode(4,0,0)
|
val ccBucks = TerrarumSansBitmap.toColorCode(5,0,0)
|
||||||
val ccCode = TerrarumSansBitmap.toColorCode(0,5,7)
|
val ccCode = TerrarumSansBitmap.toColorCode(0,4,8)
|
||||||
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
||||||
|
|
||||||
private const val ZWSP = 0x200B
|
private const val ZWSP = 0x200B
|
||||||
@@ -1506,6 +1589,13 @@ object BTeXParser {
|
|||||||
else -> throw IllegalArgumentException("Number out of range: $this")
|
else -> throw IllegalArgumentException("Number out of range: $this")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Int.toAlphabetic(): String = when (this) {
|
||||||
|
in 27..2147483647 -> (this / 26).toAlphabetic() + (this % 26).toAlphabetic()
|
||||||
|
in 1..26 -> "${Char(this + 0x40)}"
|
||||||
|
0 -> ""
|
||||||
|
else -> throw IllegalArgumentException("Number is negative: $this")
|
||||||
|
}
|
||||||
|
|
||||||
private fun codepointToObjIdChar(c: Int): Char {
|
private fun codepointToObjIdChar(c: Int): Char {
|
||||||
return when (c) {
|
return when (c) {
|
||||||
in 0xFFF70..0xFFF79 -> (0x30 + (c - 0xFFF70)).toChar()
|
in 0xFFF70..0xFFF79 -> (0x30 + (c - 0xFFF70)).toChar()
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import kotlin.system.measureTimeMillis
|
|||||||
*/
|
*/
|
||||||
class BTeXTest : ApplicationAdapter() {
|
class BTeXTest : ApplicationAdapter() {
|
||||||
|
|
||||||
val filePath = "btex.xml"
|
// val filePath = "btex.xml"
|
||||||
// val filePath = "test.xml"
|
val filePath = "test.xml"
|
||||||
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
||||||
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
||||||
// val filePath = "literature/koKR/yisang_nalgae.btexbin"
|
// val filePath = "literature/koKR/yisang_nalgae.btexbin"
|
||||||
|
|||||||
Reference in New Issue
Block a user