more btex styling

This commit is contained in:
minjaesong
2024-04-28 15:32:28 +09:00
parent 8a1ff32fa7
commit 54663657bd
2 changed files with 13 additions and 4 deletions

View File

@@ -710,6 +710,15 @@ object BTeXParser {
handler.paragraphBuffer.clear()
}
@CloseTag
fun closeElemANONBREAK(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
typesetParagraphs("――――――――――――", 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()
}
@CloseTag
fun closeElemCOVER(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
handler.spanColour = null
@@ -794,12 +803,12 @@ object BTeXParser {
@CloseTag // reflective access is impossible with 'private'
fun closeElemP(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
// if this P is a very first P without chapters, leave two lines before typesetting
val addVirtualChapter = (tagHistory.size > 2 && tagHistory[tagHistory.lastIndex - 1] == "MANUSCRIPT")
val penultTag = tagHistory.getOrNull(tagHistory.lastIndex - 1)
val thePar = handler.paragraphBuffer.toString().trim()
val text =
if (siblingIndex > 1) "\u3000$thePar"
else if (addVirtualChapter) "\n\n$thePar"
if (siblingIndex > 1 && penultTag != "ANONBREAK" && penultTag != "BR") "\u3000$thePar"
else if (penultTag == "MANUSCRIPT") "\n\n$thePar"
else thePar
typesetParagraphs(text, handler)