diff --git a/assets/mods/basegame/books/test.xml b/assets/mods/basegame/books/test.xml new file mode 100644 index 000000000..87723c902 --- /dev/null +++ b/assets/mods/basegame/books/test.xml @@ -0,0 +1,178 @@ + + + The Way to Mastery of<br />Lorem Ipsum + Or, How To Write and Publish a Book + Terran Publishing + Test Edition + + + + + + The Book + + What Is a Book + +

This example book is written to give readers the example of the Book Language.

+ +
What Qualifies as a 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 hyperlinks.

+

Books are considered as bound and always presented in two pages for reading.

+ + Writing a Book Using a Typewriter + +

Typewriter allows quick scribbling of the words in convenient manners, just click on them and get + writing!

+

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.

+

Typed papers are considered as non-bound and only one page at a time will be presented.

+

All in all, you cannot write a true Book using a typewriter.

+ + Writing a Book with Publishers and Printing Presses + +

Professional-looking texts, with all the benefits of a real Book can be made, or even mass-produced + easily with the help of publishers.

+

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 .

+

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.

+ + + The + + Introduction + +

is a markup language based on XML, with a resemblance of the . + abstracts away the meticulous styling and typesetting configurations, so you can focus on + actually writing your texts than debugging the macros. This does come with a downside of + not being able to change the given style.

+

document is divided up to five parts: the Style Declaration, the + Cover, the Table of Contents, the + Manuscript, and the Index Page. Of which the + Style Declaration and the Manuscript is the mandatory parts.

+ + + The Style Declaration + +

The Style Declaration is the very first line of a document. Its syntax is as follows:

+ + + + <btexdoc cover="hardcover" inner="standard" papersize="standard"> + + +

The btexdoc tag takes three attributes: cover, inner and papersize.

+ + + The 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:

+ + + + + + + <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> + +

Only the title 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.

+ + + The 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:

+ + + + <tocpage title="Custom page name if necessary"><tableofcontents /></tocpage> + + +

The optional title attribute allows a custom name can be given to this page. + If unspecified, the default name is “Table of Contents”.

+

The tag <tableofcontents /> is an internal tag used by the typesetter.

+ + + The Manuscript + +

This is the part where you actually write your body texts in. The body text can have the following tags:

+ +

Self-closing tags have no child tags. To use a self-closing tag, simply do <tagname />.

+ + +
Hyperlinking
+ +

Hyperlinks can be defined using index and a tags.

+ + + The Index Page + +

The contents of the Index Page is filled in automatically by reading through your manuscript. + All the usage of index tags will be shown here. Its syntax is as follows:

+ + + + <indexpage title="Custom page name if necessary"><tableofindices /></indexpage> + + +

The optional title attribute allows a custom name can be given to this page. If unspecified, + the default name is “Index”.

+ + + Ending the Document + +

The document must begin with the opening btexdoc tag, and therefore must + end with a matching closing tag. Simply write away </btexdoc> and the + document is finished.

+ + + Conclusion + +

The finished book description using 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!

+ + + + +

this page is intentionally left blank

+
+ +
+ + +
diff --git a/btexdoc.dtd b/btexdoc.dtd new file mode 100644 index 000000000..387d259e9 --- /dev/null +++ b/btexdoc.dtd @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/TerrarumSansBitmap.jar b/lib/TerrarumSansBitmap.jar index 80eded83d..ca03cd4f2 100644 --- a/lib/TerrarumSansBitmap.jar +++ b/lib/TerrarumSansBitmap.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:82f10fc3ef4ab42fb87502b3cf309fb0bde8b4b45ec214be70a9c6f826862b3d -size 226415 +oid sha256:6509a3c37695401b3026865683fb2f54f715d81168f497dbd938b479fff3c3d9 +size 199551 diff --git a/src/net/torvald/btex/BTeXParser.kt b/src/net/torvald/btex/BTeXParser.kt index f6225fe1c..fc6474f1f 100644 --- a/src/net/torvald/btex/BTeXParser.kt +++ b/src/net/torvald/btex/BTeXParser.kt @@ -226,8 +226,8 @@ object BTeXParser { override fun startElement(uri: String, localName: String, qName: String, attributes: Attributes) { val tag = qName - if (tagStack.isEmpty() && tag.lowercase() != "btexdoc") throw BTeXParsingException("Document is not BTeX") val theTag = tag.uppercase() + if (tagStack.isEmpty() && theTag != "BTEXDOC") throw BTeXParsingException("Document is not BTeX") if (tagStack.isNotEmpty() && tagStack.any { textTags.contains(it) } && textTags.contains(theTag)) throw IllegalStateException("Text tag '$theTag' used inside of text tags (tag stack is ${tagStack.joinToString()}, $theTag)") @@ -284,6 +284,7 @@ object BTeXParser { private var oldSpanColour: String? = null private var oldCodeMode = false + private val CODE_TAG_MARGIN = 2 override fun characters(ch: CharArray, start: Int, length: Int) { var str = @@ -310,17 +311,17 @@ object BTeXParser { // process code request if (codeMode != oldCodeMode || codeMode) { - println("CODE tag for str '$str'") - - str = CodepointSequence(listOf(0xF901D, 0xF901D, 0xF901D)).toUTF8Bytes().decodeToString() if (!codeMode) { paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideDefault) + paragraphBuffer.append(glueToString(CODE_TAG_MARGIN)) } else { - val w = getFont().getWidth(str) + println("CODE tag for str '$str'") + val w = getFont().getWidth(str) + 2*CODE_TAG_MARGIN getOrPutCodeTagRef(w) - paragraphBuffer.appendObjectPlaceholder("TAG@CODE-$w") + paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}") + paragraphBuffer.append(glueToString(CODE_TAG_MARGIN)) paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideCodestyle) } } diff --git a/src/net/torvald/terrarum/tests/BTeXTest.kt b/src/net/torvald/terrarum/tests/BTeXTest.kt index f1b6f5831..a5cb1aa79 100644 --- a/src/net/torvald/terrarum/tests/BTeXTest.kt +++ b/src/net/torvald/terrarum/tests/BTeXTest.kt @@ -26,7 +26,8 @@ import kotlin.system.measureTimeMillis */ class BTeXTest : ApplicationAdapter() { - val filePath = "btex.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"