mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-09 13:21:51 +09:00
more XML
This commit is contained in:
@@ -61,13 +61,10 @@
|
||||
|
||||
<p><index id="btexdoc"/>The Style Declaration is the very first line of a <btex/> document. Its syntax is as follows:</p>
|
||||
|
||||
<pbox align="left" class="code">
|
||||
<index id="btexdoc (tag)"/>
|
||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||
</pbox>
|
||||
<callout align="left" class="code"><index id="btexdoc (tag)"/><btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||
</callout>
|
||||
|
||||
<p>The <code>btexdoc</code> tag takes three attributes:<br/>
|
||||
<code>cover</code>, <code>inner</code> and <code>papersize</code>.</p>
|
||||
<p>The <code>btexdoc</code> tag takes following attributes:</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>
|
||||
@@ -77,19 +74,13 @@
|
||||
<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 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>
|
||||
<callout 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><br/>
|
||||
<title>Title of your book</title><br/>
|
||||
<subtitle>Subtitle if necessary</subtitle><br/>
|
||||
<author>Who wrote this book</author><br/>
|
||||
<edition>Edition information if necessary</edition><br/>
|
||||
</cover>
|
||||
</pbox>
|
||||
</callout>
|
||||
<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>
|
||||
|
||||
@@ -99,10 +90,8 @@
|
||||
<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 align="left" class="code">
|
||||
<index id="tocpage (tag)"/>
|
||||
<tocpage title="Custom page name if necessary"><tableofcontents/></tocpage>
|
||||
</pbox>
|
||||
<callout align="left" class="code"><index id="tocpage (tag)"/><tocpage title="Custom page name if necessary"><tableofcontents/></tocpage>
|
||||
</callout>
|
||||
|
||||
<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>
|
||||
@@ -115,7 +104,7 @@
|
||||
<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="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>callout</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>
|
||||
@@ -124,7 +113,7 @@
|
||||
<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="callout (tag)"/><code>callout</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>
|
||||
@@ -133,6 +122,29 @@
|
||||
<p>Self-closing tags have no child tags. To use a self-closing tag, simply do <code><tagname/></code>.</p>
|
||||
|
||||
|
||||
<section>Heading Styling</section>
|
||||
|
||||
<p>The <code>part</code>, <code>chapter</code> and <code>section</code> takes optional <code>type</code> attributes which changes how the chapter should be numbered. Available options are:</p>
|
||||
<ul>
|
||||
<li><code>a</code> — use alphabet for the number (a, b, c, …)</li>
|
||||
<li><code>A</code> — use majuscule alphabet for the number (A, B, C, …)</li>
|
||||
<li><code>i</code> — use Roman numeral for the number (i, ii, iii, …)</li>
|
||||
<li><code>I</code> — use majuscule Roman numeral for the number (I, II, III, …)</li>
|
||||
<li><code>1</code> — use numbers (1, 2, 3)</li>
|
||||
</ul>
|
||||
<p>By default, parts use majuscule Roman numerals and others use just numbers.</p>
|
||||
|
||||
|
||||
<section>Paragraph Styling</section>
|
||||
|
||||
<p>The <code>p</code> and <code>callout</code> tag take <code>align</code> attribute, which controls how the text should be aligned. Available options are:</p>
|
||||
<ul>
|
||||
<li><code>left</code> — aligns the text to the left without breaking words, also known as ragged-right</li>
|
||||
<li><code>justify</code> — aligns the text as evenly as possible, like real books. This is the default value.</li>
|
||||
</ul>
|
||||
<p>The <code>p</code>, <code>span</code> and <code>callout</code> tags also take <code>class="code"</code> attribute, which results in the text printed using the <span class="code">code font.</span></p>
|
||||
|
||||
|
||||
<section>Hyperlinking</section>
|
||||
|
||||
<p><index id="hyperlink"/>Hyperlinks can be defined using <code>index</code> and <code>a</code> tags.</p>
|
||||
@@ -141,15 +153,14 @@
|
||||
<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 align="left" class="code">
|
||||
<index id="indexpage (tag)"/>
|
||||
<indexpage title="Custom page name if necessary"><tableofindices/></indexpage>
|
||||
</pbox>
|
||||
<callout align="left" class="code"><index id="indexpage (tag)"/><indexpage title="Custom page name if necessary"><tableofindices/></indexpage>
|
||||
</callout>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -8,14 +8,13 @@
|
||||
<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>
|
||||
<p>Test with excessive white spaces !!</p>
|
||||
<pbox>
|
||||
<callout>
|
||||
A Callout!
|
||||
</pbox>
|
||||
<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>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>
|
||||
</callout>
|
||||
<p class="code">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>
|
||||
<callout align="left" class="code">Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph Long callout paragraph
|
||||
</callout>
|
||||
<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>
|
||||
</btexdoc>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
<!ENTITY % heading "part | chapter | section | subsection">
|
||||
<!ENTITY % lists "ul | ol">
|
||||
<!ENTITY % blocktext "pre | anonbreak | pbox | center | fullpagebox">
|
||||
<!ENTITY % blocktext "pre | anonbreak | callout | center | fullpagebox">
|
||||
<!ENTITY % block "p | %heading; | %lists; | %blocktext;">
|
||||
<!ENTITY % Flow "(#PCDATA | %block; | %inline;)*">
|
||||
|
||||
@@ -77,8 +77,8 @@
|
||||
<!-- MANUSCRIPT tag specification -->
|
||||
<!ELEMENT manuscript %Flow;>
|
||||
<!ELEMENT fullpagebox %Flow;>
|
||||
<!ELEMENT pbox %Inline;>
|
||||
<!ATTLIST pbox %attrs; %TextAlign;>
|
||||
<!ELEMENT callout %Inline;>
|
||||
<!ATTLIST callout %attrs; %TextAlign;>
|
||||
|
||||
<!ELEMENT part %Inline;>
|
||||
<!ATTLIST part
|
||||
|
||||
BIN
lib/TerrarumSansBitmap.jar
LFS
BIN
lib/TerrarumSansBitmap.jar
LFS
Binary file not shown.
@@ -42,7 +42,7 @@ import kotlin.reflect.full.findAnnotation
|
||||
*/
|
||||
object BTeXParser {
|
||||
|
||||
internal val textTags = hashSetOf("P", "PBOX", "TITLE", "AUTHOR", "EDITION", "CHAPTER", "SECTION", "LI")
|
||||
internal val textTags = hashSetOf("P", "CALLOUT", "TITLE", "AUTHOR", "EDITION", "CHAPTER", "SECTION", "LI")
|
||||
internal val textDecorTags = hashSetOf("SPAN", "CODE")
|
||||
|
||||
operator fun invoke(file: FileHandle, varMap: Map<String, String>) = invoke(file.file(), varMap)
|
||||
@@ -720,6 +720,10 @@ object BTeXParser {
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
fun processElemSPAN(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.spanColour = attribs["colour"] ?: attribs["color"]
|
||||
|
||||
if (attribs["class"] == "code") {
|
||||
handler.codeMode = true
|
||||
}
|
||||
}
|
||||
|
||||
@CloseTag
|
||||
@@ -939,22 +943,29 @@ object BTeXParser {
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
fun processElemP(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.clearParBuffer()
|
||||
|
||||
currentAlign = attribs["align"] ?: "justify"
|
||||
|
||||
if (attribs["class"] == "code") {
|
||||
handler.codeMode = true
|
||||
handler.spanColour = "black"
|
||||
}
|
||||
}
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
fun processElemPBOX(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
fun processElemCALLOUT(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"
|
||||
handler.spanColour = "black"
|
||||
}
|
||||
}
|
||||
|
||||
@CloseTag // reflective access is impossible with 'private'
|
||||
fun closeElemPBOX(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
||||
fun closeElemCALLOUT(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()
|
||||
@@ -971,15 +982,29 @@ object BTeXParser {
|
||||
|
||||
// add boxes
|
||||
it.extraDrawFun = { batch, x, y ->
|
||||
val width = it.width.toFloat()
|
||||
val width = doc.textWidth - 2 * MARGIN_PARBOX_H.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 (height > 0) {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1116,10 +1141,11 @@ object BTeXParser {
|
||||
var cnt = cptSectMap.size - 1
|
||||
while (cnt >= 0) {
|
||||
if (cptSectMap[cnt].type.startsWith("section")) {
|
||||
cnt += 1
|
||||
sectOrder += 1
|
||||
}
|
||||
else break
|
||||
|
||||
cnt -= 1
|
||||
}
|
||||
|
||||
|
||||
@@ -1507,8 +1533,8 @@ object BTeXParser {
|
||||
|
||||
|
||||
companion object {
|
||||
private const val MARGIN_PARBOX_V = 2
|
||||
private const val MARGIN_PARBOX_H = 8
|
||||
private const val MARGIN_PARBOX_V = 4
|
||||
private const val MARGIN_PARBOX_H = 12
|
||||
private const val MARGIN_TITLE_TEXTS = 8
|
||||
private const val PAR_INDENTATION = 16
|
||||
private const val HEADING_NUM_TITLE_GAP = 9
|
||||
|
||||
@@ -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.xml"
|
||||
|
||||
Reference in New Issue
Block a user