mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +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">
|
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||||
<cover>
|
<cover>
|
||||||
<title>The Way to Mastery of<br />Lorem Ipsum</title>
|
<title>The Way to Mastery of<br />Lorem Ipsum</title>
|
||||||
@@ -50,10 +51,10 @@
|
|||||||
<btex /> abstracts away the meticulous styling and typesetting configurations, so you can focus on
|
<btex /> abstracts away the meticulous styling and typesetting configurations, so you can focus on
|
||||||
actually writing your texts than debugging the <latex /> macros. This does come with a downside of
|
actually writing your texts than debugging the <latex /> macros. This does come with a downside of
|
||||||
not being able to change the given style.</p>
|
not being able to change the given style.</p>
|
||||||
<p><btex /> document is divided up to five parts: the <itemname>Style Declaration</itemname>, the
|
<p><btex /> document is divided up to five parts: the <a href="btexdoc">Style Declaration</a>, the
|
||||||
<itemname>Cover</itemname>, the <itemname>Table of Contents</itemname>, the
|
<a href="cover">Cover</a>, the <a href="table of contents">Table of Contents</a>, the
|
||||||
<itemname>Manuscript</itemname>, and the <itemname>Index Page</itemname>. Of which the
|
<a href="manuscript">Manuscript</a>, and the <a href="index page">Index Page</a>, of which the
|
||||||
Style Declaration and the Manuscript is the mandatory parts.</p>
|
Style Declaration and the Manuscript are the mandatory parts.</p>
|
||||||
|
|
||||||
|
|
||||||
<chapter>The Style Declaration</chapter>
|
<chapter>The Style Declaration</chapter>
|
||||||
@@ -65,7 +66,8 @@
|
|||||||
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||||
</pbox>
|
</pbox>
|
||||||
|
|
||||||
<p>The <code>btexdoc</code> tag takes three attributes: <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>
|
<ul>
|
||||||
<li><code>cover</code> — changes the style of the cover. Possible values: <code>hardcover</code>, <code>none</code></li>
|
<li><code>cover</code> — changes the style of the cover. Possible values: <code>hardcover</code>, <code>none</code></li>
|
||||||
<li><code>inner</code> — changes the style of the body. Possible values: <code>standard</code>, <code>typewriter</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 money "¤">
|
||||||
|
|
||||||
<!ENTITY % special.extra "img">
|
<!ENTITY % special.extra "img">
|
||||||
<!ENTITY % special.basic "br | span">
|
<!ENTITY % special.basic "br | span | newpage">
|
||||||
<!ENTITY % special "%special.basic; | %special.extra;">
|
<!ENTITY % special "%special.basic; | %special.extra;">
|
||||||
<!ENTITY % fontstyle.extra "big | small | font | basefont">
|
<!ENTITY % fontstyle.extra "big | small | font | basefont">
|
||||||
<!ENTITY % fontstyle.basic "tt | i | b | u | s | strike ">
|
<!ENTITY % fontstyle.basic "tt | i | b | u | s | strike ">
|
||||||
<!ENTITY % fontstyle "%fontstyle.basic; | %fontstyle.extra;">
|
<!ENTITY % fontstyle "%fontstyle.basic; | %fontstyle.extra;">
|
||||||
<!ENTITY % inlinelogo "btex | tex | latex">
|
<!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 "(#PCDATA | %inline;)*">
|
||||||
|
<!ENTITY % Inline.meta "(#PCDATA | %inline.meta;)*">
|
||||||
<!ENTITY % Text "CDATA">
|
<!ENTITY % Text "CDATA">
|
||||||
<!ENTITY % TextAlign "align (left|center|right|justify) #IMPLIED">
|
<!ENTITY % TextAlign "align (left|center|right|justify) #IMPLIED">
|
||||||
<!ENTITY % HeadingAttr
|
<!ENTITY % HeadingAttr
|
||||||
"hide CDATA #IMPLIED
|
"hide CDATA #IMPLIED
|
||||||
alt %Text; #IMPLIED">
|
alt %Text; #IMPLIED">
|
||||||
|
<!ENTITY % pre.content
|
||||||
|
"(#PCDATA | a | %special.basic; | %fontstyle.basic;)*">
|
||||||
|
|
||||||
<!ENTITY % BTeXcover "cover (hardcover|none) #IMPLIED">
|
<!ENTITY % BTeXcover "cover (hardcover|none) #IMPLIED">
|
||||||
<!ENTITY % BTeXinner "inner (standard) #IMPLIED">
|
<!ENTITY % BTeXinner "inner (standard) #IMPLIED">
|
||||||
<!ENTITY % BTeXpapersize "papersize (standard) #IMPLIED">
|
<!ENTITY % BTeXpapersize "papersize (standard) #IMPLIED">
|
||||||
<!ENTITY % BTeXdefs "defs (mail|giro|examination) #IMPLIED">
|
<!ENTITY % BTeXdefs "defs (mail|giro|examination) #IMPLIED">
|
||||||
|
|
||||||
<!ENTITY % id-only "id ID #REQUIRED">
|
<!ENTITY % id-only "id CDATA #REQUIRED">
|
||||||
<!ENTITY % key-value
|
<!ENTITY % key-value
|
||||||
"key CDATA #REQUIRED
|
"key CDATA #REQUIRED
|
||||||
value CDATA #REQUIRED">
|
value CDATA #REQUIRED">
|
||||||
<!ENTITY % coreattrs
|
<!ENTITY % coreattrs
|
||||||
"id ID #IMPLIED
|
"id CDATA #IMPLIED
|
||||||
class CDATA #IMPLIED
|
class CDATA #IMPLIED
|
||||||
title %Text; #IMPLIED">
|
title %Text; #IMPLIED">
|
||||||
|
|
||||||
@@ -52,10 +57,10 @@
|
|||||||
|
|
||||||
<!-- COVER tag specification -->
|
<!-- COVER tag specification -->
|
||||||
<!ELEMENT cover (title?, subtitle?, author?, edition?)>
|
<!ELEMENT cover (title?, subtitle?, author?, edition?)>
|
||||||
<!ELEMENT title (#PCDATA)>
|
<!ELEMENT title %Inline.meta;>
|
||||||
<!ELEMENT subtitle (#PCDATA)>
|
<!ELEMENT subtitle %Inline.meta;>
|
||||||
<!ELEMENT author (#PCDATA)>
|
<!ELEMENT author %Inline.meta;>
|
||||||
<!ELEMENT edition (#PCDATA)>
|
<!ELEMENT edition %Inline.meta;>
|
||||||
|
|
||||||
<!-- TOC-like tag specification -->
|
<!-- TOC-like tag specification -->
|
||||||
<!ELEMENT tocpage (tableofcontents)>
|
<!ELEMENT tocpage (tableofcontents)>
|
||||||
@@ -98,11 +103,15 @@
|
|||||||
<!ELEMENT p %Inline;>
|
<!ELEMENT p %Inline;>
|
||||||
<!ATTLIST p %attrs; %TextAlign;>
|
<!ATTLIST p %attrs; %TextAlign;>
|
||||||
<!ELEMENT span %Inline;>
|
<!ELEMENT span %Inline;>
|
||||||
<!ATTLIST span %attrs;>
|
<!ATTLIST span
|
||||||
|
%attrs;
|
||||||
|
color %Text; #IMPLIED
|
||||||
|
colour %Text; #IMPLIED
|
||||||
|
>
|
||||||
<!ELEMENT emph %Inline;>
|
<!ELEMENT emph %Inline;>
|
||||||
<!ELEMENT itemname %Inline;>
|
<!ELEMENT itemname %Inline;>
|
||||||
<!ELEMENT targetname %Inline;>
|
<!ELEMENT targetname %Inline;>
|
||||||
<!ELEMENT code %Inline;>
|
<!ELEMENT code %pre.content;>
|
||||||
<!ELEMENT bucks %Inline;>
|
<!ELEMENT bucks %Inline;>
|
||||||
<!ELEMENT br EMPTY>
|
<!ELEMENT br EMPTY>
|
||||||
<!ELEMENT ul (li)+>
|
<!ELEMENT ul (li)+>
|
||||||
@@ -124,4 +133,10 @@
|
|||||||
%attrs;
|
%attrs;
|
||||||
type %LIStyle; #IMPLIED
|
type %LIStyle; #IMPLIED
|
||||||
value %Number; #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 currentTheme = ""
|
||||||
private var spanColour: String? = null
|
private var spanColour: String? = null
|
||||||
private var codeMode: Boolean = false
|
private var codeMode: Boolean = false
|
||||||
|
private var hrefMode: Boolean = false
|
||||||
private var bucksMode: 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"
|
val tagname = "TAG@CODE-$width"
|
||||||
if (!objDict.contains(tagname)) {
|
if (!objDict.contains(tagname)) {
|
||||||
objWidthDict[tagname] = 0
|
objWidthDict[tagname] = 0
|
||||||
@@ -207,7 +208,7 @@ object BTeXParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return objDict[tagname]
|
return objDict[tagname]
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fun dispose() {
|
fun dispose() {
|
||||||
if (::testFont.isInitialized) testFont.tryDispose()
|
if (::testFont.isInitialized) testFont.tryDispose()
|
||||||
@@ -309,6 +310,7 @@ object BTeXParser {
|
|||||||
|
|
||||||
private var oldSpanColour: String? = null
|
private var oldSpanColour: String? = null
|
||||||
private var oldCodeMode = false
|
private var oldCodeMode = false
|
||||||
|
private var oldHrefMode = false
|
||||||
private var oldBucksMode = false
|
private var oldBucksMode = false
|
||||||
private val CODE_TAG_MARGIN = 2
|
private val CODE_TAG_MARGIN = 2
|
||||||
|
|
||||||
@@ -339,18 +341,30 @@ object BTeXParser {
|
|||||||
if (codeMode != oldCodeMode || codeMode) {
|
if (codeMode != oldCodeMode || codeMode) {
|
||||||
if (!codeMode) {
|
if (!codeMode) {
|
||||||
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideDefault)
|
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideDefault)
|
||||||
|
paragraphBuffer.append(ccDefault)
|
||||||
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// println("CODE tag for str '$str'")
|
// println("CODE tag for str '$str'")
|
||||||
val w = getFont().getWidth(str) + 2*CODE_TAG_MARGIN
|
// val w = getFont().getWidth(str) + 2*CODE_TAG_MARGIN
|
||||||
getOrPutCodeTagRef(w)
|
// getOrPutCodeTagRef(w)
|
||||||
paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
// paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
||||||
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
||||||
|
paragraphBuffer.append(ccCode)
|
||||||
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideCodestyle)
|
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideCodestyle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process href request
|
||||||
|
if (hrefMode != oldHrefMode || hrefMode) {
|
||||||
|
if (!hrefMode) {
|
||||||
|
paragraphBuffer.append(ccDefault)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
paragraphBuffer.append(ccHref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// process bucks request
|
// process bucks request
|
||||||
if (bucksMode != oldBucksMode || bucksMode) {
|
if (bucksMode != oldBucksMode || bucksMode) {
|
||||||
if (!bucksMode) {
|
if (!bucksMode) {
|
||||||
@@ -369,6 +383,7 @@ object BTeXParser {
|
|||||||
|
|
||||||
oldSpanColour = spanColour
|
oldSpanColour = spanColour
|
||||||
oldCodeMode = codeMode
|
oldCodeMode = codeMode
|
||||||
|
oldHrefMode = hrefMode
|
||||||
oldBucksMode = bucksMode
|
oldBucksMode = bucksMode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -618,7 +633,7 @@ object BTeXParser {
|
|||||||
)
|
)
|
||||||
|
|
||||||
private val ccEmph = "#C11"// TerrarumSansBitmap.toColorCode(0xfd44)
|
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)
|
private val ccTargetName = "#170" // TerrarumSansBitmap.toColorCode(0xf3c4)
|
||||||
|
|
||||||
@OpenTag // reflective access is impossible with 'private'
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
@@ -726,6 +741,15 @@ object BTeXParser {
|
|||||||
handler.codeMode = false
|
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'
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
fun processElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
fun processElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||||
handler.bucksMode = true
|
handler.bucksMode = true
|
||||||
@@ -830,7 +854,7 @@ object BTeXParser {
|
|||||||
val heading = if (part == null && cpt == null && sect == null)
|
val heading = if (part == null && cpt == null && sect == null)
|
||||||
""
|
""
|
||||||
else if (part != null && cpt == null && sect == null)
|
else if (part != null && cpt == null && sect == null)
|
||||||
"Part ${part.toRomanNum()}.${glueToString(9)}"
|
"Part ${part.toRomanNum()}${glueToString(9)}"
|
||||||
else
|
else
|
||||||
listOfNotNull(cpt, sect).joinToString(".") + "${glueToString(9)}" +
|
listOfNotNull(cpt, sect).joinToString(".") + "${glueToString(9)}" +
|
||||||
(if (cpt != null && cpt < 10) "${glueToString(9)}" else "")
|
(if (cpt != null && cpt < 10) "${glueToString(9)}" else "")
|
||||||
@@ -1408,6 +1432,8 @@ object BTeXParser {
|
|||||||
companion object {
|
companion object {
|
||||||
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
||||||
val ccBucks = TerrarumSansBitmap.toColorCode(4,0,0)
|
val ccBucks = TerrarumSansBitmap.toColorCode(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 ZWSP = 0x200B
|
||||||
private const val SHY = 0xAD
|
private const val SHY = 0xAD
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import kotlin.system.measureTimeMillis
|
|||||||
*/
|
*/
|
||||||
class BTeXTest : ApplicationAdapter() {
|
class BTeXTest : ApplicationAdapter() {
|
||||||
|
|
||||||
// val filePath = "btex.xml"
|
val filePath = "btex.xml"
|
||||||
val filePath = "test.xml"
|
// val filePath = "test.xml"
|
||||||
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
||||||
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
||||||
// val filePath = "literature/koKR/yisang_nalgae.btexbin"
|
// val filePath = "literature/koKR/yisang_nalgae.btexbin"
|
||||||
|
|||||||
Reference in New Issue
Block a user