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

@@ -234,6 +234,7 @@
<li><index id="thechapter (macro)"/><code>thechapter</code> — Chapter heading. Default: <code>%1$s</code></li>
<li><index id="chaptertype (macro)"/><code>chaptertype</code> — Default style of the <code>chapter</code> tag. Default: <code>1</code></li>
<li><index id="chapteronnewpage (macro)"/><code>chapteronnewpage</code> — Controls if a chapter must start on a new page. Put non-zero value to enable this behaviour. Default: <code>0</code></li>
<li><index id="parindent (macro)"/><code>parindent</code> — Controls the indentation size of the paragraphs. Default: <code>16</code></li>
</ul>
<p>The argument key <code>%1$s</code> will be replaced into a number, Roman numerals, etc.

View File

@@ -217,6 +217,7 @@
<li><index id="thechapter (매크로)"/><code>thechapter</code> — 장 제목 번호. 기본값: <code>%1$s</code></li>
<li><index id="chaptertype (매크로)"/><code>chaptertype</code><code>chapter</code> 태그의 기본 스타일. 기본값: <code>1</code></li>
<li><index id="chapteronnewpage (매크로)"/><code>chapteronnewpage</code> — 새 페이지에서 장이 시작되게 하기. 활성화하려면 0이 아닌 임의의 값을 넣을 것. 기본값: <code>0</code></li>
<li><index id="parindent (매크로)"/><code>parindent</code> — 문단의 들여쓰기 크기를 조절함. 기본값: <code>16</code></li>
</ul>
<p>매개변수인 <code>%1$s</code>는 각 제목의 <code>type</code> 속성에 따라 적절한 숫자로 치환된다.</p>

Binary file not shown.

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