the real btex doc

This commit is contained in:
minjaesong
2024-05-01 04:49:44 +09:00
parent 62d321b150
commit 739734732e
4 changed files with 163 additions and 54 deletions

View File

@@ -9,61 +9,169 @@
<tocpage><tableofcontents /></tocpage>
<manuscript>
<part>The Book</part>
<chapter>What Is a Book</chapter>
<p>This example book is designed to give you the example of the Book Language.</p>
<p>This example book is written to give readers the example of the Book Language.</p>
<section>What Really Is a Book</section>
<section hide="1">What Qualifies as a Book</section>
<p>A book is a collection of texts printed in a special way that allows them to be read easily, with
enumerable pages and insertion of other helpful resources, such as illustrations and <a href="btex language">hyperlinks</a>.</p>
<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. The <btex />
abstracts away the meticulous styling and typesetting configurations, so you can focus on writing
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><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)" />
&lt;btexdoc cover="hardcover" inner="standard" papersize="standard"&gt;
</pbox>
<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>
<pbox>
<index id="cover (tag)" />
<index id="title (tag)" />
<index id="subtitle (tag)" />
<index id="author (tag)" />
<index id="edition (tag)" />
&lt;cover&gt;
  &lt;title&gt;Title of your book&lt;/title&gt;
  &lt;subtitle&gt;Subtitle if necessary&lt;/subtitle&gt;
  &lt;author&gt;Who wrote this book&lt;/author&gt;
  &lt;edition&gt;Edition information if necessary&lt;/edition&gt;
&lt;/cover&gt;
</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)" />
&lt;tocpage title="Custom page name if necessary"&gt;&lt;tableofcontents /&gt;&lt;/tocpage&gt;
</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>&lt;tableofcontents /&gt;</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>&lt;tagname /&gt;</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)" />
&lt;indexpage title="Custom page name if necessary"&gt;&lt;tableofindices /&gt;&lt;/indexpage&gt;
</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>&lt;/btexdoc&gt;</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="grey">
this page is intentionally left blank
</span></p>
<p><span colour="#666">this page is intentionally left blank</span></p>
</fullpagebox>
<chapter>Writing a Book Using Pen and Papers</chapter>
<p><index id="pen and paper" />If you open a book on a writing table, you will be welcomed with a
toolbar used to put other book elements, such as chapters and sections.</p>
<chapter>Writing a Book Using a Typewriter</chapter>
<p><index id="typewriter" />Typewriters can only write in a single style of font, chapters and
sections are not available.</p>
<chapter>Writing a Book Using a Computer</chapter>
<p>Writing book using a computer requires the use of the Book Typesetting Engine Extended, or <btex />.</p>
<section>Full Control of the Shape</section>
<p><index id="btex language" />With <btex /> you can fully control how your publishing would look like,
from a pile of papers that look like they have been typed out using typewriter, a pile of printouts
that have pictures in it, to a true hardcover book.</p>
<p><index id="cover" />This style is controlled using the <code>cover</code> attribute on the root tag,
with following values: <code>typewriter</code>, <code>printout</code> and <code>hardcover</code>.</p>
<p>Typewriter and Printout are considered not-bound and readers will only see one page at a time,
while Hardcover is considered bound and two pages are presented to the readers.</p>
</manuscript>
<indexpage><tableofindices /></indexpage>

View File

@@ -14,8 +14,9 @@
</p><p>“테이프가 끊어지면 피가 나오. 생채기도 머지않아 완치될 줄 믿소. 굿바이.” 감정은 어떤 ‘포즈’. (그 ‘포즈’의 원소만을 지적하는 것이 아닌지 나도 모르겠소.) 그 포우즈가 부동자세에까지 고도화할 때 감정은 딱 공급을 정지합네다.
</p><p>나는 내 비범한 발육을 회고하여 세상을 보는 안목을 규정하였소.
</p><p>여왕봉과 미망인—세상의 하고 많은 여인이 본질적으로 이미 미망인이 아닌 이가 있으리까? 아니, 여인의 전부가 그 일상에 있어서 개개 ‘미망인’이라는 내 논리가 뜻밖에도 여성에 대한 모독이 되오? 굿바이.
</p><p><anonbreak />
</p><p>그 33번지라는 것이 구조가 흡사 유곽이라는 느낌이 없지 않다.
</p>
<anonbreak />
<p>그 33번지라는 것이 구조가 흡사 유곽이라는 느낌이 없지 않다.
</p><p>한 번지에 18가구가 죽 어깨를 맞대고 늘어서서 창호가 똑같고 아궁이 모양이 똑같다. 게다가 각 가구에 사는 사람들이 송이송이 꽃과 같이 젊다.
</p><p>해가 들지 않는다. 해가 드는 것을 그들이 모른 체하는 까닭이다. 턱살밑에다 철줄을 매고 얼룩 진 이부자리를 널어 말린다는 핑계로 미닫이에 해가 드는 것을 막아 버린다. 침침한 방안에서 낮잠들을 잔다. 그들은 밤에는 잠을 자지 않나? 알 수 없다. 나는 밤이나 낮이나 잠만 자느라고 그런 것을 알 길이 없다. 33번지 18가구의 낮은 참 조용하다.
</p><p>조용한 것은 낮뿐이다. 어둑어둑하면 그들은 이부자리를 걷어 들인다. 전등불이 켜진 뒤의 18가구는 낮보다 훨씬 화려하다. 저물도록 미닫이 여닫는 소리가 잦다. 바빠진다. 여러 가지 냄새가 나기 시작한다. 비웃 굽는 내, 탕고도오랑내, 뜨물내, 비눗내.

View File

@@ -38,7 +38,7 @@ import kotlin.reflect.full.findAnnotation
*/
object BTeXParser {
internal val textTags = hashSetOf("P", "TITLE", "AUTHOR", "EDITION", "CHAPTER", "SECTION")
internal val textTags = hashSetOf("P", "PBOX", "TITLE", "AUTHOR", "EDITION", "CHAPTER", "SECTION", "LI")
internal val textDecorTags = hashSetOf("SPAN", "CODE")
operator fun invoke(file: FileHandle) = invoke(file.file())
@@ -590,7 +590,7 @@ object BTeXParser {
@OpenTag // reflective access is impossible with 'private'
fun processElemINDEXPAGE(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
doc.addNewPage()
if (doc.currentPageObj.isNotEmpty()) doc.addNewPage()
val header = attribs["title"] ?: "Index"
typesetChapterHeading(header, handler, 16)
}
@@ -725,7 +725,6 @@ object BTeXParser {
typesetParagraphs("${ccDefault}――――――――――――", handler).also {it.first().let {
it.posX += (doc.textWidth - it.width) / 2
} }
doc.linesPrintedOnPage[doc.currentPage] = (doc.linesPrintedOnPage[doc.currentPage] - 1).coerceAtLeast(0)
handler.paragraphBuffer.clear()
}
@@ -792,8 +791,9 @@ object BTeXParser {
}
@CloseTag // reflective access is impossible with 'private'
fun closeElemCHAPTER(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
// insert new page for second+ chapters
if (siblingIndex > 0) doc.addNewPage()
// if current line is the last line, proceed to the next page
if (doc.linesPrintedOnPage.last() >= doc.pageLines - 2) doc.addNewPage()
val thePar = handler.paragraphBuffer.toString().trim()
typesetChapterHeading(thePar, handler, 16)
@@ -807,7 +807,7 @@ object BTeXParser {
@CloseTag // reflective access is impossible with 'private'
fun closeElemSECTION(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
// if current line is the last line, proceed to the next page
if (doc.linesPrintedOnPage.last() == doc.pageLines - 1) doc.addNewPage()
if (doc.linesPrintedOnPage.last() >= doc.pageLines - 1) doc.addNewPage()
val thePar = handler.paragraphBuffer.toString().trim()
typesetSectionHeading(thePar, handler, 8)

View File

@@ -27,8 +27,8 @@ import kotlin.system.measureTimeMillis
class BTeXTest : ApplicationAdapter() {
val filePath = "btex.xml"
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.btexbin"
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.btexbin"
// 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"