new macro parindent

This commit is contained in:
minjaesong
2024-05-19 00:45:45 +09:00
parent 49e9b6bcdc
commit 4401b7377f
5 changed files with 10 additions and 4 deletions

View File

@@ -133,6 +133,7 @@ object BTeXParser {
"thechapter" to "%1\$s",
"chaptertype" to "1",
"chapteronnewpage" to "0",
"parindent" to "16"
)
private fun invokeMacro(name: String, vararg args: String): String {
@@ -1398,11 +1399,14 @@ object BTeXParser {
val penultTag = tagHistory.getOrNull(tagHistory.lastIndex - 1)
val thePar = paragraphBuffer.toString().trim()
val indentSize = macrodefs["parindent"]!!.toInt()
val indent = if (indentSize > 0) spacingBlockToString(indentSize) else ""
val text =
// DON't indent on centering context
if (tagStack.contains("CENTER") || tagStack.contains("FULLPAGEBOX")) thePar
// indent the second+ pars (or don't indent first par after cpt/sect, anonbreak and br)
else if (siblingIndex > 1 && penultTag != "ANONBREAK" && penultTag != "BR") "\uDBBF\uDFDF$thePar"
else if (siblingIndex > 1 && penultTag != "ANONBREAK" && penultTag != "BR") "$indent$thePar"
// if the very first tag within the MANUSCRIPT is par (i.e. no chapter), create a "virtual" chapter
else if (penultTag == "MANUSCRIPT") "\n\n$thePar"
// else, print the text normally

View File

@@ -4,7 +4,6 @@ import com.badlogic.gdx.ApplicationAdapter
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.InputAdapter
import com.badlogic.gdx.InputProcessor
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
import com.badlogic.gdx.graphics.Color
@@ -39,6 +38,7 @@ class BTeXTest : ApplicationAdapter() {
// 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.xml"
// val filePath = "literature/koKR/yisang_geonchukmuhanyukmyeongakche.xml"
private lateinit var document: BTeXDocument