btex: new macro 'chapteronnewpage'

This commit is contained in:
minjaesong
2024-05-17 01:20:56 +09:00
parent c7ca5a61c8
commit 163216707e
3 changed files with 49 additions and 29 deletions

View File

@@ -107,7 +107,7 @@
<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="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, see <a href="macro definition">The Macro Definition</a></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>callout</code>, <code>ul</code>, <code>ol</code> or <code>anonbreak</code></li>
<li><index id="span (tag)"/><code>span</code> — allows changing the colour or the style of the texts. The colour must be specified in the <code>colour</code> attribute. Six-digit hex code, three-digit hex code and CSS Colours 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>
@@ -229,10 +229,11 @@
will change how the heading numbers are printed. The following is a list of names and default values:</p>
<ul>
<li><code>thepart</code> — Part heading. Default: <code>Part %1$s</code></li>
<li><code>parttype</code> — Default style of the <code>part</code> tag. Default: <code>I</code></li>
<li><code>thechapter</code> — Chapter heading. Default: <code>%1$s</code></li>
<li><code>chaptertype</code> — Default style of the <code>chapter</code> tag. Default: <code>1</code></li>
<li><index id="thepart (macro)"/><code>thepart</code> — Part heading. Default: <code>Part %1$s</code></li>
<li><index id="parttype (macro)"/><code>parttype</code> — Default style of the <code>part</code> tag. Default: <code>I</code></li>
<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>
</ul>
<p>The argument key <code>%1$s</code> will be replaced into a number, Roman numerals, etc.
@@ -250,7 +251,7 @@
<chapter>Printing External Variables</chapter>
<p>Defining the text to be printed outside the typesetting system, such as the name of the sender
<p><index id="v (tag)"/>Defining the text to be printed outside the typesetting system, such as the name of the sender
and the recipient, can be desired. These texts can be used with the self-closing <code>v</code> tag. This tag
can also be used to use an ingame string as well.</p>
<p>To print an external variable, use the <code>id</code> attribute; to print an ingame string, use
@@ -273,11 +274,11 @@
<p><index id="korean postpositions"/>To accommodate the Korean Postposition transformations, special <code>v</code> series tags are added:</p>
<ul>
<li><code>veun</code> <code>vneun</code> — 은/는</li>
<li><code>vi</code> <code>vga</code> — 이/가</li>
<li><code>veul</code> <code>vreul</code> — 을/를</li>
<li><code>vwa</code> <code>vgwa</code> — 와/과</li>
<li><code>vro</code> <code>veuro</code> — 로/으로</li>
<li><index id="veun (tag)"/><index id="vneun (tag)"/><code>veun</code> <code>vneun</code> — 은/는</li>
<li><index id="vi (tag)"/><index id="vga (tag)"/><code>vi</code> <code>vga</code> — 이/가</li>
<li><index id="veul (tag)"/><index id="vreul (tag)"/><code>veul</code> <code>vreul</code> — 을/를</li>
<li><index id="vwa (tag)"/><index id="vgwa (tag)"/><code>vwa</code> <code>vgwa</code> — 와/과</li>
<li><index id="vro (tag)"/><index id="veuro (tag)"/><code>vro</code> <code>veuro</code> — 로/으로</li>
</ul>
<p>Either of the tag in the pair can be used; they will put the correct postposition based on the word.

View File

@@ -60,7 +60,7 @@
<p><index id="btexdoc"/>스타일 정의문은 <btex/> 문서의 가장 첫 부분이다. 스타일 정의문의 구조는 다음과 같다.</p>
<callout align="left" class="code"><index id="btexdoc (tag)"/><!--
<callout align="left" class="code"><index id="btexdoc (태그)"/><!--
-->&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br/><!--
-->&lt;!DOCTYPE btexdoc SYSTEM "btexdoc.dtd"&gt;<br/><!--
-->&lt;btexdoc cover="hardcover" inner="standard" papersize="standard"&gt;
@@ -103,13 +103,13 @@
<p><index id="원고"/><index id="태그 목록"/>원고는 책의 진짜 본문이 담긴 부분을 말한다. 본문에는 다음의 태그를 사용할 수 있다.</p>
<ul>
<li><index id="part (태그)"/><code>part</code> — 원고에 새 부(part)를 추가함</li>
<li><index id="chapter (태그)"/><index id="section (태그)"/><code>chapter</code>, <code>section</code> — 원고에 새 장(chapter)·절(section)을 추가함. 목차 페이지에는 다른 이름을 표시하고 싶다면 <code>alt</code> 속성을 사용할 수 있음. 목차 페이지에서 숨기고 싶다면 <code>hide="1"</code> 속성을 추가할 것. 장이 새 페이지에서 시작되게 하려면 <code>chapter</code> 태그 앞에 <code>newpage</code>를 추가할</li>
<li><index id="chapter (태그)"/><index id="section (태그)"/><code>chapter</code>, <code>section</code> — 원고에 새 장(chapter)·절(section)을 추가함. 목차 페이지에는 다른 이름을 표시하고 싶다면 <code>alt</code> 속성을 사용할 수 있음. 목차 페이지에서 숨기고 싶다면 <code>hide="1"</code> 속성을 추가할 것. 장이 새 페이지에서 시작되게 하려면 <a href="macro definition">매크로 정의문</a>을 볼</li>
<li><index id="p (태그)"/><code>p</code> — 새 문단을 삽입함. 본문의 글은 반드시 이 태그 내부에 작성되어야 함. 모든 문단는 16픽셀의 들여쓰기로 조판되나, 다음의 경우 들여쓰기가 적용되지 않음: 부·장·절의 첫 문단, <code>br</code>, <code>newpage</code>, <code>callout</code>, <code>ul</code>, <code>ol</code>, <code>anonbreak</code> 태그 직후의 문단</li>
<li><index id="span (태그)"/><code>span</code> — 문구의 색상이나 스타일을 변경함. 색상은 <code>colour</code> 속성에 작성되어야 함. 6자리 헥스코드, 3자리 헥스코드, CSS Colours Level 4에 정의된 색상명을 사용할 수 있음. 모든 색상은 내부적으로 가장 가까운 3자리 헥스코드로 변경됨에 유의할 것</li>
<li><index id="emph (태그)"/><code>emph</code><code>span</code>의 특수한 경우로, 문구를 <emph>빨간색으로</emph> 인자함</li>
<li><index id="itemname (태그)"/><code>itemname</code><code>span</code>의 특수한 경우로, 게임 내 아이템의 이름을 강조 표시할 때 사용함. 문구는 <itemname>파란색으로</itemname> 인자됨</li>
<li><index id="targetname (태그)"/><code>targetname</code><code>span</code>의 특수한 경우로, 임의의 목표를 강조 표시할 때 사용함. 문구는 <targetname>초록색으로</targetname> 인자됨</li>
<li><index id="code (태그)"/><code>code</code><code>span</code>의 특수한 경우로, 코드를 강조 표시할 때 사용함. 문구는 <code>청록색의 고정폭으로</code> 인자됨</li>
<li><index id="code (태그)"/><code>code</code><code>span</code>의 특수한 경우로, 코드를 강조 표시할 때 사용함. 문구는 <code>암적색의 고정폭으로</code> 인자됨</li>
<li><index id="br (태그)"/><code>br</code> — 스스로 닫는 태그. 임의의 줄바꿈을 삽입함</li>
<li><index id="newpage (태그)"/><code>newpage</code> — 스스로 닫는 태그. 임의의 새 페이지를 삽입함</li>
<li><index id="anonbreak (태그)"/><code>anonbreak</code> — 스스로 닫는 태그. 임의의 문단 분할을 적용함. 분할 표시는 한 줄을 비우고 가운데에 긴 줄을 삽입하여 이루어짐. 주로 소설을 조판하는 데에 사용됨</li>
@@ -212,10 +212,11 @@
<p>내부적으로 부와 장 제목은 매크로를 사용하여 인자된다. 매크로의 값을 바꾸면 번호가 인자되는 스타일을 변경할 수 있다. 매크로의 이름과 기본값은 다음과 같다.</p>
<ul>
<li><code>thepart</code> — 부 제목 번호. 기본값: <code>Part %1$s</code></li>
<li><code>parttype</code><code>part</code> 태그의 기본 스타일. 기본값: <code>I</code></li>
<li><code>thechapter</code> — 장 제목 번호. 기본값: <code>%1$s</code></li>
<li><code>chaptertype</code><code>chapter</code> 태그의 기본 스타일. 기본값: <code>1</code></li>
<li><index id="thepart (매크로)"/><code>thepart</code> — 부 제목 번호. 기본값: <code>Part %1$s</code></li>
<li><index id="parttype (매크로)"/><code>parttype</code><code>part</code> 태그의 기본 스타일. 기본값: <code>I</code></li>
<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>
</ul>
<p>매개변수인 <code>%1$s</code>는 각 제목의 <code>type</code> 속성에 따라 적절한 숫자로 치환된다.</p>
@@ -230,7 +231,7 @@
<chapter>외부 변수 인자하기</chapter>
<p>편지의 보내는 사람과 받는 사람과 같이 인자될 문구를 조판 시스템 외부에서 정의하는 것이 바람직한 경우가 있다. 이러한 문구는 스스로 닫는 <code>v</code> 태그를 사용하여 추가할 수 있다. 이 태그는 또한 게임 내에 정의된 문자열을 가져오는 데에 사용될 수도 있다.</p>
<p><index id="v (태그)"/>편지의 보내는 사람과 받는 사람과 같이 인자될 문구를 조판 시스템 외부에서 정의하는 것이 바람직한 경우가 있다. 이러한 문구는 스스로 닫는 <code>v</code> 태그를 사용하여 추가할 수 있다. 이 태그는 또한 게임 내에 정의된 문자열을 가져오는 데에 사용될 수도 있다.</p>
<p>외부 변수를 인자하려면 <code>id</code> 속성을 사용하여야 한다. 게임 내 문자열을 가져오려면 <code>fromgame</code> 속성을 사용하라. 두 속성은 서로 상충되므로 하나의 속성만을 사용하여야 한다.</p>
<section>게임 내 화폐 단위 인자하기</section>
@@ -247,11 +248,11 @@
<p><index id="조사처리"/>조사 처리를 위한 <code>v</code>태그는 다음과 같다.</p>
<ul>
<li><code>veun</code> <code>vneun</code> — 은/는</li>
<li><code>vi</code> <code>vga</code> — 이/가</li>
<li><code>veul</code> <code>vreul</code> — 을/를</li>
<li><code>vwa</code> <code>vgwa</code> — 와/과</li>
<li><code>vro</code> <code>veuro</code> — 로/으로</li>
<li><index id="veun (태그)"/><index id="vneun (태그)"/><code>veun</code> <code>vneun</code> — 은/는</li>
<li><index id="vi (태그)"/><index id="vga (태그)"/><code>vi</code> <code>vga</code> — 이/가</li>
<li><index id="veul (태그)"/><index id="vreul (태그)"/><code>veul</code> <code>vreul</code> — 을/를</li>
<li><index id="vwa (태그)"/><index id="vgwa (태그)"/><code>vwa</code> <code>vgwa</code> — 와/과</li>
<li><index id="vro (태그)"/><index id="veuro (태그)"/><code>vro</code> <code>veuro</code> — 로/으로</li>
</ul>
<p>태그 쌍 중에서는 아무거나 사용해도 무방하다. 어느 쪽이든 알맞는 조사를 추가할 것이다. 달리 말하면, <code>veun</code><code>vneun</code>은 완전히 동일한 태그이다.</p>
@@ -269,7 +270,7 @@
<part>일반인 출입금지</part>
<chapter>왜 책이 인쇄될 때까지 기다려야 하나요? 인쇄기를 직접 사용할 수는 없나요?</chapter>
<chapter alt="대기 프로세스">왜 책이 인쇄될 때까지 기다려야 하나요? 인쇄기를 직접 사용할 수는 없나요?</chapter>
<p><btex/> 엔진은 빠른 물건이 아니다. 책을 하나 조판하려면 최소 몇 초가 필요하다. “대기 시스템”은 별도의 스레드 풀에서 (멀티스레딩으로 작동함) 책이 인쇄되도록 하여 게임플레이를 방해하지 않도록 도입되었다. 이것이 없다면 책이 한번 인쇄될 때마다 게임이 ‘응답 없음’ 상태가 될 것이고, 이는 인게임 경험에 매우 부정적으로 작용한다.</p>
@@ -277,6 +278,7 @@
<p>상기와 같은 이유로 “인쇄기”는 플레이어에게 직접적으로 제공되지 않고, “출판사”와 우편을 통해 간접적으로 이용하는 형태로 제공된다.</p>
<newpage/>
<fullpagebox>

View File

@@ -130,7 +130,8 @@ object BTeXParser {
"thepart" to "Part %1\$s",
"parttype" to "I",
"thechapter" to "%1\$s",
"chaptertype" to "1"
"chaptertype" to "1",
"chapteronnewpage" to "0",
)
private fun invokeMacro(name: String, vararg args: String): String {
@@ -1286,9 +1287,6 @@ object BTeXParser {
}
@CloseTag // reflective access is impossible with 'private'
fun closeElemCHAPTER(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 - 2) doc.addNewPage()
val partOrder = cptSectMap.count { it.type.startsWith("part") }
val cptOrder = cptSectMap.count { it.type.startsWith("chapter") } + 1
@@ -1297,6 +1295,25 @@ object BTeXParser {
val cptSectInfo = cptSectStack.removeLast()
val partNumStr = partOrder.toListNumStr(cptSectStack.findLast { it.type.startsWith("part") }?.type ?: "1")
val cptNumStr = cptOrder.toListNumStr(cptSectInfo.style)
var cptSibling = 1 // alternative for siblingIndex as the value is always 1 here
var cnt = cptSectMap.size - 1
while (cnt >= 0) {
if (cptSectMap[cnt].type.startsWith("part"))
break
else
cptSibling += 1
cnt -= 1
}
// if current line is the last line, proceed to the next page
if (doc.linesPrintedOnPage.last() >= doc.pageLines - 2) doc.addNewPage()
// if defined by the macro, proceed to the next page
if (macrodefs["chapteronnewpage"] != "0" && cptSibling > 1)
doc.addNewPage()
typesetChapterHeading(invokeMacro("thechapter", cptNumStr), thePar, handler, 16)
if (!cptSectInfo.type.endsWith("-hidden"))