mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
more XML
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!DOCTYPE btexdoc SYSTEM "btexdoc.dtd">
|
||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||
<cover>
|
||||
<title>The Way to Mastery of<br />Lorem Ipsum</title>
|
||||
@@ -50,10 +51,10 @@
|
||||
<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>
|
||||
<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>
|
||||
|
||||
|
||||
<chapter>The Style Declaration</chapter>
|
||||
@@ -65,7 +66,8 @@
|
||||
<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:<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>
|
||||
<li><code>inner</code> — changes the style of the body. Possible values: <code>standard</code>, <code>typewriter</code></li>
|
||||
|
||||
35
btexdoc.dtd
35
btexdoc.dtd
@@ -2,31 +2,36 @@
|
||||
<!ENTITY money "¤">
|
||||
|
||||
<!ENTITY % special.extra "img">
|
||||
<!ENTITY % special.basic "br | span">
|
||||
<!ENTITY % special.basic "br | span | newpage">
|
||||
<!ENTITY % special "%special.basic; | %special.extra;">
|
||||
<!ENTITY % fontstyle.extra "big | small | font | basefont">
|
||||
<!ENTITY % fontstyle.basic "tt | i | b | u | s | strike ">
|
||||
<!ENTITY % fontstyle "%fontstyle.basic; | %fontstyle.extra;">
|
||||
<!ENTITY % inlinelogo "btex | tex | latex">
|
||||
<!ENTITY % inline "a | %special; | %fontstyle; | code | bucks | %inlinelogo; | index | var">
|
||||
<!ENTITY % textdecor "emph | itemname | targetname">
|
||||
<!ENTITY % inline "a | %special; | %fontstyle; | code | bucks | %inlinelogo; | index | var | %textdecor;">
|
||||
<!ENTITY % inline.meta "a | %special.basic; | %inlinelogo;">
|
||||
<!ENTITY % Inline "(#PCDATA | %inline;)*">
|
||||
<!ENTITY % Inline.meta "(#PCDATA | %inline.meta;)*">
|
||||
<!ENTITY % Text "CDATA">
|
||||
<!ENTITY % TextAlign "align (left|center|right|justify) #IMPLIED">
|
||||
<!ENTITY % HeadingAttr
|
||||
"hide CDATA #IMPLIED
|
||||
alt %Text; #IMPLIED">
|
||||
<!ENTITY % pre.content
|
||||
"(#PCDATA | a | %special.basic; | %fontstyle.basic;)*">
|
||||
|
||||
<!ENTITY % BTeXcover "cover (hardcover|none) #IMPLIED">
|
||||
<!ENTITY % BTeXinner "inner (standard) #IMPLIED">
|
||||
<!ENTITY % BTeXpapersize "papersize (standard) #IMPLIED">
|
||||
<!ENTITY % BTeXdefs "defs (mail|giro|examination) #IMPLIED">
|
||||
|
||||
<!ENTITY % id-only "id ID #REQUIRED">
|
||||
<!ENTITY % id-only "id CDATA #REQUIRED">
|
||||
<!ENTITY % key-value
|
||||
"key CDATA #REQUIRED
|
||||
value CDATA #REQUIRED">
|
||||
<!ENTITY % coreattrs
|
||||
"id ID #IMPLIED
|
||||
"id CDATA #IMPLIED
|
||||
class CDATA #IMPLIED
|
||||
title %Text; #IMPLIED">
|
||||
|
||||
@@ -52,10 +57,10 @@
|
||||
|
||||
<!-- COVER tag specification -->
|
||||
<!ELEMENT cover (title?, subtitle?, author?, edition?)>
|
||||
<!ELEMENT title (#PCDATA)>
|
||||
<!ELEMENT subtitle (#PCDATA)>
|
||||
<!ELEMENT author (#PCDATA)>
|
||||
<!ELEMENT edition (#PCDATA)>
|
||||
<!ELEMENT title %Inline.meta;>
|
||||
<!ELEMENT subtitle %Inline.meta;>
|
||||
<!ELEMENT author %Inline.meta;>
|
||||
<!ELEMENT edition %Inline.meta;>
|
||||
|
||||
<!-- TOC-like tag specification -->
|
||||
<!ELEMENT tocpage (tableofcontents)>
|
||||
@@ -98,11 +103,15 @@
|
||||
<!ELEMENT p %Inline;>
|
||||
<!ATTLIST p %attrs; %TextAlign;>
|
||||
<!ELEMENT span %Inline;>
|
||||
<!ATTLIST span %attrs;>
|
||||
<!ATTLIST span
|
||||
%attrs;
|
||||
color %Text; #IMPLIED
|
||||
colour %Text; #IMPLIED
|
||||
>
|
||||
<!ELEMENT emph %Inline;>
|
||||
<!ELEMENT itemname %Inline;>
|
||||
<!ELEMENT targetname %Inline;>
|
||||
<!ELEMENT code %Inline;>
|
||||
<!ELEMENT code %pre.content;>
|
||||
<!ELEMENT bucks %Inline;>
|
||||
<!ELEMENT br EMPTY>
|
||||
<!ELEMENT ul (li)+>
|
||||
@@ -125,3 +134,9 @@
|
||||
type %LIStyle; #IMPLIED
|
||||
value %Number; #IMPLIED
|
||||
>
|
||||
<!ENTITY % a.content
|
||||
"(#PCDATA | %special; | %fontstyle; | code | var)*">
|
||||
<!ELEMENT a %a.content;>
|
||||
<!ATTLIST a
|
||||
href CDATA #REQUIRED
|
||||
>
|
||||
@@ -90,6 +90,7 @@ object BTeXParser {
|
||||
private var currentTheme = ""
|
||||
private var spanColour: String? = null
|
||||
private var codeMode: Boolean = false
|
||||
private var hrefMode: Boolean = false
|
||||
private var bucksMode: Boolean = false
|
||||
|
||||
|
||||
@@ -189,7 +190,7 @@ object BTeXParser {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOrPutCodeTagRef(width: Int): ((BTeXDrawCall) -> BTeXBatchDrawCall)? {
|
||||
/*private fun getOrPutCodeTagRef(width: Int): ((BTeXDrawCall) -> BTeXBatchDrawCall)? {
|
||||
val tagname = "TAG@CODE-$width"
|
||||
if (!objDict.contains(tagname)) {
|
||||
objWidthDict[tagname] = 0
|
||||
@@ -207,7 +208,7 @@ object BTeXParser {
|
||||
}
|
||||
}
|
||||
return objDict[tagname]
|
||||
}
|
||||
}*/
|
||||
|
||||
fun dispose() {
|
||||
if (::testFont.isInitialized) testFont.tryDispose()
|
||||
@@ -309,6 +310,7 @@ object BTeXParser {
|
||||
|
||||
private var oldSpanColour: String? = null
|
||||
private var oldCodeMode = false
|
||||
private var oldHrefMode = false
|
||||
private var oldBucksMode = false
|
||||
private val CODE_TAG_MARGIN = 2
|
||||
|
||||
@@ -339,18 +341,30 @@ object BTeXParser {
|
||||
if (codeMode != oldCodeMode || codeMode) {
|
||||
if (!codeMode) {
|
||||
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideDefault)
|
||||
paragraphBuffer.append(ccDefault)
|
||||
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
||||
}
|
||||
else {
|
||||
// println("CODE tag for str '$str'")
|
||||
val w = getFont().getWidth(str) + 2*CODE_TAG_MARGIN
|
||||
getOrPutCodeTagRef(w)
|
||||
paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
||||
// val w = getFont().getWidth(str) + 2*CODE_TAG_MARGIN
|
||||
// getOrPutCodeTagRef(w)
|
||||
// paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
||||
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
||||
paragraphBuffer.append(ccCode)
|
||||
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideCodestyle)
|
||||
}
|
||||
}
|
||||
|
||||
// process href request
|
||||
if (hrefMode != oldHrefMode || hrefMode) {
|
||||
if (!hrefMode) {
|
||||
paragraphBuffer.append(ccDefault)
|
||||
}
|
||||
else {
|
||||
paragraphBuffer.append(ccHref)
|
||||
}
|
||||
}
|
||||
|
||||
// process bucks request
|
||||
if (bucksMode != oldBucksMode || bucksMode) {
|
||||
if (!bucksMode) {
|
||||
@@ -369,6 +383,7 @@ object BTeXParser {
|
||||
|
||||
oldSpanColour = spanColour
|
||||
oldCodeMode = codeMode
|
||||
oldHrefMode = hrefMode
|
||||
oldBucksMode = bucksMode
|
||||
}
|
||||
}
|
||||
@@ -618,7 +633,7 @@ object BTeXParser {
|
||||
)
|
||||
|
||||
private val ccEmph = "#C11"// TerrarumSansBitmap.toColorCode(0xfd44)
|
||||
private val ccItemName = "#14C" // TerrarumSansBitmap.toColorCode(0xf37d)
|
||||
private val ccItemName = "#03B" // TerrarumSansBitmap.toColorCode(0xf37d)
|
||||
private val ccTargetName = "#170" // TerrarumSansBitmap.toColorCode(0xf3c4)
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
@@ -726,6 +741,15 @@ object BTeXParser {
|
||||
handler.codeMode = false
|
||||
}
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
fun processElemA(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.hrefMode = true
|
||||
}
|
||||
@CloseTag
|
||||
fun closeElemA(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
||||
handler.hrefMode = false
|
||||
}
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
fun processElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.bucksMode = true
|
||||
@@ -830,7 +854,7 @@ object BTeXParser {
|
||||
val heading = if (part == null && cpt == null && sect == null)
|
||||
""
|
||||
else if (part != null && cpt == null && sect == null)
|
||||
"Part ${part.toRomanNum()}.${glueToString(9)}"
|
||||
"Part ${part.toRomanNum()}${glueToString(9)}"
|
||||
else
|
||||
listOfNotNull(cpt, sect).joinToString(".") + "${glueToString(9)}" +
|
||||
(if (cpt != null && cpt < 10) "${glueToString(9)}" else "")
|
||||
@@ -1408,6 +1432,8 @@ object BTeXParser {
|
||||
companion object {
|
||||
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
||||
val ccBucks = TerrarumSansBitmap.toColorCode(4,0,0)
|
||||
val ccCode = TerrarumSansBitmap.toColorCode(0,5,7)
|
||||
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
||||
|
||||
private const val ZWSP = 0x200B
|
||||
private const val SHY = 0xAD
|
||||
|
||||
@@ -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