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">
|
||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||
<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>
|
||||
<author>Terran Publishing</author>
|
||||
<edition>Test Edition</edition>
|
||||
</cover>
|
||||
|
||||
<tocpage><tableofcontents /></tocpage>
|
||||
<tocpage><tableofcontents/></tocpage>
|
||||
|
||||
<manuscript>
|
||||
<part>The Book</part>
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
<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
|
||||
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
|
||||
<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>
|
||||
@@ -37,21 +37,21 @@
|
||||
<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
|
||||
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>
|
||||
<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
|
||||
<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 <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="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>
|
||||
@@ -59,14 +59,14 @@
|
||||
|
||||
<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>
|
||||
<index id="btexdoc (tag)" />
|
||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||
<pbox align="left" class="code">
|
||||
<index id="btexdoc (tag)"/>
|
||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||
</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>
|
||||
<ul>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<index id="cover (tag)" />
|
||||
<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>
|
||||
<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 align="left" class="code">
|
||||
<index id="cover (tag)"/>
|
||||
<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>
|
||||
<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>
|
||||
@@ -96,59 +96,59 @@
|
||||
|
||||
<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>
|
||||
|
||||
<pbox>
|
||||
<index id="tocpage (tag)" />
|
||||
<tocpage title="Custom page name if necessary"><tableofcontents /></tocpage>
|
||||
<pbox align="left" class="code">
|
||||
<index id="tocpage (tag)"/>
|
||||
<tocpage title="Custom page name if necessary"><tableofcontents/></tocpage>
|
||||
</pbox>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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.
|
||||
<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 align="left" class="code">
|
||||
<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,
|
||||
@@ -157,18 +157,18 @@
|
||||
|
||||
<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
|
||||
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
|
||||
<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 />
|
||||
<newpage/>
|
||||
|
||||
<fullpagebox>
|
||||
<p><span colour="#666">this page is intentionally left blank</span></p>
|
||||
@@ -176,5 +176,5 @@
|
||||
|
||||
</manuscript>
|
||||
|
||||
<indexpage><tableofindices /></indexpage>
|
||||
<indexpage><tableofindices/></indexpage>
|
||||
</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">
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<pbox>
|
||||
<index id="btexdoc (tag)" />
|
||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||
</pbox>
|
||||
|
||||
<p>The <code>btexdoc</code> tag takes one attribute: <code>cover</code>.</p>
|
||||
<p>The <code>btexdoc</code> tag takes two attributes: <code>cover</code> and <code>inner</code>.</p>
|
||||
<p>The <code>btexdoc</code> tag takes three attributes: <code>cover</code>, <code>inner</code> and <code>papersize</code>.</p>
|
||||
<ul>
|
||||
<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>
|
||||
<p>Test with excessive white spaces !!</p>
|
||||
<pbox>
|
||||
<index id="cover (tag)" />
|
||||
<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>
|
||||
A Callout!
|
||||
</pbox>
|
||||
<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>
|
||||
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<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
|
||||
</pbox>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
</manuscript>
|
||||
|
||||
<indexpage><tableofindices /></indexpage>
|
||||
</btexdoc>
|
||||
|
||||
30
btexdoc.dtd
30
btexdoc.dtd
@@ -1,6 +1,12 @@
|
||||
<!ENTITY nbsp " ">
|
||||
<!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.basic "br | span | newpage">
|
||||
<!ENTITY % special "%special.basic; | %special.extra;">
|
||||
@@ -26,6 +32,10 @@
|
||||
<!ENTITY % BTeXpapersize "papersize (standard) #IMPLIED">
|
||||
<!ENTITY % BTeXdefs "defs (mail|giro|examination) #IMPLIED">
|
||||
|
||||
<!ENTITY % Countable
|
||||
"type %counters; #IMPLIED
|
||||
start %Number; #IMPLIED">
|
||||
|
||||
<!ENTITY % id-only "id CDATA #REQUIRED">
|
||||
<!ENTITY % key-value
|
||||
"key CDATA #REQUIRED
|
||||
@@ -43,10 +53,6 @@
|
||||
<!ENTITY % block "p | %heading; | %lists; | %blocktext;">
|
||||
<!ENTITY % Flow "(#PCDATA | %block; | %inline;)*">
|
||||
|
||||
<!ENTITY % ULStyle "(disc|square|circle)">
|
||||
<!ENTITY % Number "CDATA">
|
||||
<!ENTITY % LIStyle "CDATA">
|
||||
|
||||
<!ELEMENT btexdoc (cover?,tocpage?,manuscript,indexpage?)>
|
||||
<!ATTLIST btexdoc
|
||||
%BTeXcover;
|
||||
@@ -75,13 +81,16 @@
|
||||
<!ATTLIST pbox %attrs; %TextAlign;>
|
||||
|
||||
<!ELEMENT part %Inline;>
|
||||
<!ATTLIST part %HeadingAttr;>
|
||||
<!ATTLIST part
|
||||
%HeadingAttr;
|
||||
%Countable;
|
||||
>
|
||||
<!ELEMENT chapter %Inline;>
|
||||
<!ATTLIST chapter %HeadingAttr;>
|
||||
<!ATTLIST chapter %HeadingAttr; %Countable;>
|
||||
<!ELEMENT section %Inline;>
|
||||
<!ATTLIST section %HeadingAttr;>
|
||||
<!ATTLIST section %HeadingAttr; %Countable;>
|
||||
<!ELEMENT subsection %Inline;>
|
||||
<!ATTLIST subsection %HeadingAttr;>
|
||||
<!ATTLIST subsection %HeadingAttr; %Countable;>
|
||||
|
||||
|
||||
<!-- self-closing tags -->
|
||||
@@ -120,13 +129,10 @@
|
||||
type %ULStyle; #IMPLIED
|
||||
compact (compact) #IMPLIED
|
||||
>
|
||||
<!ENTITY % OLStyle "CDATA">
|
||||
<!ELEMENT ol (li)+>
|
||||
<!ATTLIST ol
|
||||
%attrs;
|
||||
type %OLStyle; #IMPLIED
|
||||
compact (compact) #IMPLIED
|
||||
start %Number; #IMPLIED
|
||||
%Countable;
|
||||
>
|
||||
<!ELEMENT li %Flow;>
|
||||
<!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")
|
||||
}
|
||||
|
||||
extraDrawFun(batch, px, py)
|
||||
|
||||
batch.color = Color.WHITE
|
||||
|
||||
if (text != null && cmd == null) {
|
||||
@@ -371,8 +373,6 @@ class BTeXDrawCall(
|
||||
cmd.draw(doc, batch, px, py, font)
|
||||
}
|
||||
else throw Error("Text and Texture are both non-null")
|
||||
|
||||
extraDrawFun(batch, px, py)
|
||||
}
|
||||
|
||||
fun isNotBlank(): Boolean {
|
||||
|
||||
@@ -14,10 +14,12 @@ import net.torvald.terrarum.btex.BTeXDrawCall
|
||||
import net.torvald.terrarum.btex.TypesetDrawCall
|
||||
import net.torvald.terrarum.ceilToFloat
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.console.GetAV.isNum
|
||||
import net.torvald.terrarum.toHex
|
||||
import net.torvald.terrarum.tryDispose
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarumsansbitmap.MovableType
|
||||
import net.torvald.terrarumsansbitmap.TypesettingStrategy
|
||||
import net.torvald.terrarumsansbitmap.gdx.CodepointSequence
|
||||
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
||||
import net.torvald.unicode.CURRENCY
|
||||
@@ -98,9 +100,16 @@ object BTeXParser {
|
||||
private val elemClosers: HashMap<String, KFunction<*>> = HashMap()
|
||||
|
||||
private val paragraphBuffer = StringBuilder()
|
||||
private var currentAlign = "justify"
|
||||
|
||||
fun clearParBuffer() {
|
||||
paragraphBuffer.clear()
|
||||
currentAlign = "justify"
|
||||
codeMode = false
|
||||
hrefMode = false
|
||||
bucksMode = false
|
||||
spanColour = null
|
||||
currentTheme = ""
|
||||
}
|
||||
|
||||
private val objDict = HashMap<String, (BTeXDrawCall) -> BTeXBatchDrawCall>()
|
||||
@@ -109,9 +118,9 @@ object BTeXParser {
|
||||
private var lastTagAtDepth = Array(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,
|
||||
var partNum: Int?, var cptNum: Int?, var sectNum: Int?)
|
||||
var partNum: String?, var cptNum: String?, var sectNum: String?)
|
||||
|
||||
private val cptSectStack = ArrayList<CptSect>()
|
||||
|
||||
@@ -129,6 +138,14 @@ object BTeXParser {
|
||||
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) {
|
||||
(objWidthDict[id] ?: throw NullPointerException("No OBJ with id '$id' exists")).let {
|
||||
@@ -314,27 +331,27 @@ object BTeXParser {
|
||||
private var oldBucksMode = false
|
||||
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) {
|
||||
val str =
|
||||
var str =
|
||||
String(ch.sliceArray(start until start + length)).replace('\n', ' ').replace(Regex(" +"), " ")//.trim()
|
||||
|
||||
if (str.isNotEmpty()) {
|
||||
// printdbg("Characters [col:${spanColour}] \t\"$str\"")
|
||||
// process span request
|
||||
val spanCC = spanColToColourCode()
|
||||
|
||||
if (spanColour != oldSpanColour || spanColour != null) {
|
||||
|
||||
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()
|
||||
))
|
||||
}
|
||||
paragraphBuffer.append(spanCC ?: ccDefault)
|
||||
}
|
||||
|
||||
// process code request
|
||||
@@ -350,7 +367,7 @@ object BTeXParser {
|
||||
// getOrPutCodeTagRef(w)
|
||||
// paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
||||
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
||||
paragraphBuffer.append(ccCode)
|
||||
paragraphBuffer.append(spanCC ?: ccCode)
|
||||
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideCodestyle)
|
||||
}
|
||||
}
|
||||
@@ -369,12 +386,10 @@ object BTeXParser {
|
||||
if (bucksMode != oldBucksMode || bucksMode) {
|
||||
if (!bucksMode) {
|
||||
paragraphBuffer.append(ccDefault)
|
||||
|
||||
}
|
||||
else {
|
||||
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'
|
||||
fun processElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.bucksMode = true
|
||||
handler.paragraphBuffer.append("$CURRENCY\u00A0")
|
||||
handler.paragraphBuffer.append("$ccBucks$CURRENCY\u00A0")
|
||||
}
|
||||
@CloseTag
|
||||
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>) {
|
||||
doc.addNewPage() // toc: openright
|
||||
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'
|
||||
fun processElemINDEXPAGE(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
if (doc.currentPageObj.isNotEmpty()) doc.addNewPage()
|
||||
val header = attribs["title"] ?: "Index"
|
||||
typesetChapterHeading(null, header, handler, 16)
|
||||
typesetChapterHeading(null, header, handler, PAR_INDENTATION)
|
||||
}
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
@@ -850,14 +865,14 @@ object BTeXParser {
|
||||
}
|
||||
|
||||
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)
|
||||
""
|
||||
else if (part != null && cpt == null && sect == null)
|
||||
"Part ${part.toRomanNum()}${glueToString(9)}"
|
||||
"Part $part${glueToString(HEADING_NUM_TITLE_GAP)}"
|
||||
else
|
||||
listOfNotNull(cpt, sect).joinToString(".") + "${glueToString(9)}" +
|
||||
(if (cpt != null && cpt < 10) "${glueToString(9)}" else "")
|
||||
listOfNotNull(cpt, sect).joinToString(".") + "${glueToString(HEADING_NUM_TITLE_GAP)}" +
|
||||
(if (cpt != null && cpt.length < 2 && cpt.isNum()) "${glueToString(HEADING_NUM_TITLE_GAP)}" else "")
|
||||
|
||||
typesetTOCline("$heading", name, pg, handler, indent, tocPage)
|
||||
}
|
||||
@@ -926,9 +941,57 @@ object BTeXParser {
|
||||
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
|
||||
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
|
||||
} }
|
||||
handler.clearParBuffer()
|
||||
@@ -982,27 +1045,27 @@ object BTeXParser {
|
||||
handler.clearParBuffer()
|
||||
|
||||
if (attribs["hide"] == null)
|
||||
cptSectStack.add(CptSect("part", attribs["alt"]))
|
||||
cptSectStack.add(CptSect("part", attribs["alt"], attribs["type"] ?: "I", attribs["start"]?.toInt()))
|
||||
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'
|
||||
fun processElemCHAPTER(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.clearParBuffer()
|
||||
|
||||
if (attribs["hide"] == null)
|
||||
cptSectStack.add(CptSect("chapter", attribs["alt"]))
|
||||
cptSectStack.add(CptSect("chapter", attribs["alt"], attribs["type"] ?: "1", attribs["start"]?.toInt()))
|
||||
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'
|
||||
fun processElemSECTION(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.clearParBuffer()
|
||||
|
||||
if (attribs["hide"] == null)
|
||||
cptSectStack.add(CptSect("section", attribs["alt"]))
|
||||
cptSectStack.add(CptSect("section", attribs["alt"], attribs["type"] ?: "1", attribs["start"]?.toInt()))
|
||||
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'
|
||||
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 thePar = handler.paragraphBuffer.toString().trim()
|
||||
typesetPartHeading(partOrder, thePar, handler)
|
||||
|
||||
val cptSectInfo = cptSectStack.removeLast()
|
||||
val partNumStr = partOrder.toListNumStr(cptSectInfo.style)
|
||||
|
||||
typesetPartHeading(partNumStr, thePar, handler)
|
||||
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()
|
||||
}
|
||||
@@ -1028,11 +1093,14 @@ object BTeXParser {
|
||||
val cptOrder = cptSectMap.count { it.type.startsWith("chapter") } + 1
|
||||
|
||||
val thePar = handler.paragraphBuffer.toString().trim()
|
||||
typesetChapterHeading(cptOrder, thePar, handler, 16)
|
||||
|
||||
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"))
|
||||
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()
|
||||
}
|
||||
@@ -1056,11 +1124,15 @@ object BTeXParser {
|
||||
|
||||
|
||||
val thePar = handler.paragraphBuffer.toString().trim()
|
||||
typesetSectionHeading(cptOrder, sectOrder, thePar, handler, 8)
|
||||
|
||||
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"))
|
||||
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()
|
||||
}
|
||||
@@ -1083,7 +1155,7 @@ object BTeXParser {
|
||||
// else, print the text normally
|
||||
else thePar
|
||||
|
||||
typesetParagraphs(ccDefault + text, handler)
|
||||
typesetParagraphs("$ccDefault$text", handler, align = handler.currentAlign)
|
||||
|
||||
handler.clearParBuffer()
|
||||
}
|
||||
@@ -1106,22 +1178,22 @@ object BTeXParser {
|
||||
|
||||
private fun typesetBookTitle(thePar: String, handler: BTeXHandler) {
|
||||
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 }
|
||||
doc.linesPrintedOnPage[doc.currentPage] += addedLines
|
||||
|
||||
it.forEach {
|
||||
it.posX += 8
|
||||
it.posX += MARGIN_TITLE_TEXTS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 ->
|
||||
val px = x
|
||||
val py = y + 23
|
||||
val pw = doc.textWidth - 16f
|
||||
val py = y + doc.lineHeightInPx - 1
|
||||
val pw = doc.textWidth - 2f * MARGIN_TITLE_TEXTS
|
||||
batch.color = Color(1f,1f,1f,.5f)
|
||||
Toolkit.fillArea(batch, px, py, pw+1, 2f)
|
||||
batch.color = Color.WHITE
|
||||
@@ -1129,24 +1201,24 @@ object BTeXParser {
|
||||
}
|
||||
|
||||
it.forEach {
|
||||
it.posX += 8
|
||||
it.posX += MARGIN_TITLE_TEXTS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.posX += 8
|
||||
it.posX += MARGIN_TITLE_TEXTS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun typesetPartHeading(num: Int, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
||||
typesetParagraphs("${ccDefault}⁃ Part ${num.toRomanNum()} ⁃", handler)
|
||||
typesetParagraphs(" ", handler)
|
||||
private fun typesetPartHeading(num: String, thePar: String, handler: BTeXHandler, indent: Int = PAR_INDENTATION, width: Int = doc.textWidth) {
|
||||
typesetParagraphs("${ccDefault}⁃ Part $num ⁃", handler, align = "left")
|
||||
typesetParagraphs(" ", handler, align = "left")
|
||||
// typesetParagraphs(getTitleFont(), "$ccDefault$thePar", handler)
|
||||
typesetParagraphs(getSubtitleFont(), "$ccDefault$thePar", handler)
|
||||
typesetParagraphs(getSubtitleFont(), "$ccDefault$thePar", handler, align = "left")
|
||||
|
||||
// get global yDelta
|
||||
doc.currentPageObj.let { page ->
|
||||
@@ -1224,9 +1296,9 @@ object BTeXParser {
|
||||
doc.addNewPage()
|
||||
}
|
||||
|
||||
private fun typesetChapterHeading(chapNum: Int?, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
||||
val header = if (chapNum == null) thePar else "$chapNum${glueToString(9)}$thePar"
|
||||
typesetParagraphs("\n$ccDefault$header", handler, width - indent).also {
|
||||
private fun typesetChapterHeading(num: String?, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
||||
val header = if (num == null) thePar else "$num${glueToString(9)}$thePar"
|
||||
typesetParagraphs("\n$ccDefault$header", handler, width - indent, align = "left").also {
|
||||
// add indents and adjust text y pos
|
||||
it.forEach {
|
||||
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) {
|
||||
typesetParagraphs("\n$ccDefault$chapNum.$sectNum${glueToString(9)}$thePar", handler, width - indent).also {
|
||||
private fun typesetSectionHeading(num: String, thePar: String, handler: BTeXHandler, indent: Int = 16, width: Int = doc.textWidth) {
|
||||
typesetParagraphs("\n$ccDefault$num${glueToString(9)}$thePar", handler, width - indent, align = "left").also {
|
||||
// add indents and adjust text y pos
|
||||
it.forEach {
|
||||
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> {
|
||||
return typesetParagraphs(getFont(), thePar, handler, width, startingPage)
|
||||
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, align)
|
||||
}
|
||||
|
||||
private fun typesetParagraphs(font: TerrarumSansBitmap, thePar: String, handler: BTeXHandler, width: Int = doc.textWidth, startingPage: Int = doc.currentPage): List<BTeXDrawCall> {
|
||||
val slugs = MovableType(font, thePar, width)
|
||||
private fun typesetParagraphs(font: TerrarumSansBitmap, thePar: String, handler: BTeXHandler, width: Int = doc.textWidth, startingPage: Int = doc.currentPage, align: String): List<BTeXDrawCall> {
|
||||
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
|
||||
|
||||
val drawCalls = ArrayList<BTeXDrawCall>()
|
||||
@@ -1389,7 +1466,7 @@ object BTeXParser {
|
||||
val dotGap = 10
|
||||
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.posX += indentation
|
||||
|
||||
@@ -1430,9 +1507,15 @@ object BTeXParser {
|
||||
|
||||
|
||||
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 ccBucks = TerrarumSansBitmap.toColorCode(4,0,0)
|
||||
val ccCode = TerrarumSansBitmap.toColorCode(0,5,7)
|
||||
val ccBucks = TerrarumSansBitmap.toColorCode(5,0,0)
|
||||
val ccCode = TerrarumSansBitmap.toColorCode(0,4,8)
|
||||
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
||||
|
||||
private const val ZWSP = 0x200B
|
||||
@@ -1506,6 +1589,13 @@ object BTeXParser {
|
||||
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 {
|
||||
return when (c) {
|
||||
in 0xFFF70..0xFFF79 -> (0x30 + (c - 0xFFF70)).toChar()
|
||||
|
||||
@@ -26,8 +26,8 @@ import kotlin.system.measureTimeMillis
|
||||
*/
|
||||
class BTeXTest : ApplicationAdapter() {
|
||||
|
||||
val filePath = "btex.xml"
|
||||
// val filePath = "test.xml"
|
||||
// val filePath = "btex.xml"
|
||||
val filePath = "test.xml"
|
||||
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
||||
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
||||
// val filePath = "literature/koKR/yisang_nalgae.btexbin"
|
||||
|
||||
Reference in New Issue
Block a user