Debian Codegraph @

texmf-dist/tex/optex/opbible/opbible.opm

raw
1 %% opbible macros, see opbible-doc.pdf
2 \_def\_opb_version {0.31, 2023-10-04}
3
4 \_codedecl \processbooks {OpBible: macros for creating annotated Bible}
5
6 \_doc
7 Printing version.
8 \_cod
9
10 \_message{This is OP-Bible, version <\_opb_version>}
11
12 \_doc
13 Loading packages.
14 \_cod
15
16 \_load[vlna] % single-letter prepositions and splitting hyphen managed specially in Czech
17 \_load[mte] % micro typographical extensions
18
19 \_doc
20 Namespace of internal macros of `opbible`.
21 \_cod
22
23 \_namespace{opb}
24
25 \_doc
26 Basic settings of \TeX/ parameters.
27 \_cod
28
29 \_newdimen\.lrmargin \.lrmargin=10mm
30 \_margins/2 a4 (23,27,20,20)mm
31
32 \_typosize[11/13] % typesetting size of Bible text
33 \_hyperlinks\Blue\Blue % hyperlinks activated
34
35 \_parindent=20pt
36 \_nopagenumbers
37 \_mte_enablemte % micro typographical extensions enabled
38 \_vlna_singlechars {Czech}{AaIiVvOoUuSsZzKk} % lowercase "a" added to this family
39
40 \_showboxbreadth=0
41 \_let\notecolor=\Red
42
43 \_def\LightGrey {\_setcmykcolor{0 0 0 .1}}
44 \_def\LiRed {\_setcmykcolor{0 .2 .2 0}}
45
46 \_doc
47 \sec Fonts
48 The Biblon font family has commercial license but it is very suitable for Bible
49 typesetting. If it is present on your system, we use it. Otherwise, we
50 use Termes font.
51 \_cod
52
53 \_fontfam[lm]
54 \_fontfam[Heros] % fonts for notes
55 \_fontfam[biblon] % fonts for Bible text
56 \_ifx\Biblon\_undefined % replace font if Biblon is unavailable:
57 \_fontfam[Termes]
58 \_let\Biblon=\Termes
59 \_fi
60
61 \_fontdef\.bookfont{\_setfontsize{at19.pt}\_bf}
62 \_fontdef\.chapfont{\_setfontsize{at13.pt}\_bf}
63 \_fontdef\.markfont{\_setfontsize{at7pt}\_rm}
64 \_fontdef\.captionfont{\Heros\cond\_setfontsize{at8pt}\_bf}
65 \_def\.headfont{\.Biblon\_setfontsize{at10pt}\_rm}
66 \_nsprivate \Biblon ;
67
68 \_doc
69 \sec Usable macros
70 Auxiliary macros.
71 \`\.printwarn` `{<text>}` prints warning.
72 \`\.sedef` `{<name>}{<body>}` is expanded `\sdef`.
73 \`\.myaddto` `{<macro-name>}{<text>}` adds <text> to `\<macro-name>` globally.
74 Moeower it defines the undefined macro by `\sdef{<macro-name>}{<text>}`.
75 \_cod
76
77 \_let\.printwarn=\_opwarning
78 \_def \.sedef #1{\_ea\_edef \_csname#1\_endcsname}
79 \_long\_def\.myaddto#1#2{\_ifcsname#1\_endcsname
80 \_gobal\_ea\_addto\_csname#1\_endcsname{#2}\_else \_global\_sdef{#1}{#2}\_fi}
81
82 \_doc
83 We prepare expandable if-macros:\nl
84 \`\.isspacein`` <text> \_iftrue` is true if `<text>` includes a space.\nl
85 \`\.iscolonin`` <text>:\_iftrue` is true if `<text>` includes a colon.\nl
86 \`\.isdivisin`` <text>-\_iftrue` is true if `<text>` includes a divis.
87 \_cod
88
89 \_def\.isspacein #1 #2\_iftrue{\_isempty{#2}\_iffalse}
90 \_def\.iscolonin #1:#2\_iftrue{\_isempty{#2}\_iffalse}
91 \_def\.isdivisin #1-#2\_iftrue{\_isempty{#2}\_iffalse}
92
93 \_doc
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 \sec The main loop over Bible books
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 The \`\processbooks` macro does two loops over all marks in \^`\printedbooks`.
98 The macro \`\printedbooks` is a list of `<a-marks>` of Bible books separated by spaces
99 and it must be defined in the main file. The `\_useit` trick is used here
100 in order we want to add `<space>{}` at the end of the expanded
101 \^`\printedbooks`.
102 The first loop body sets \`\pbook!``<a-mark>` used for hyperlinks.
103 The second loop body does:
104 \begitems
105 * Defines \`\amark` as <a-mark> (an actual mark of the book used in the text).
106 * Defines \`\bmark` as <b-mark> (a mark of the book used in file names).
107 * Defines \`\.btit` as the book title.
108 * Saves `<a-mark>` to the \`\.currbook` macro.
109 * Calls \^`\.newbook{<a-mark>}`
110 * Prints title of the book to the terminal and to the log.
111 * Calls \^`\bex!<a-mark>` in order to apply the \^`\BookException` data.
112 * Inputs introduction file if it exists. The real `\input` and formating
113 of the introduction text is done by the `\.printintro` macro.
114 * Inputs format definition file if it exists. Information is saved to the
115 \TeX/ memory.
116 * Inputs notes file if it exists. The notes are saved to the \TeX/ memory.
117 * Calls \^`\bpr!<a-mark>` in order to apply the \^`\BookPre` data.
118 * Inputs `txs` file with original text of the Bible using \`\.bibleinput`,
119 i.e.\ prints the text from `txs` file with notes from the \TeX/ memory.
120 * Calls \^`\bpo!<a-mark>` in order to apply \^`\BookPost` data.
121 \enditems
122 Note that the macros \`\introfile`, \`\fmtfile`, and \`\notesfile`
123 give the location of aprropriate files and these macros must be defined
124 by the user in the main file.\nl
125 Note2: each book of the Bible is processed in the group.
126 It means that all data from notes, formats etc. are stored
127 in the memory only temporary for processing single book. After
128 the Book is finalized, the \TeX/ memory is freed.
129 \_cod
130
131 \_def\.processbooks {\_par
132 \_ifx\tmark\_undefined \_def\tmark{none}\_fi
133 \.checknochapbooks
134 \_useit{\_ea\.processbooksA \printedbooks} {}
135 \_useit{\_ea\.processbooksB \printedbooks} {}
136 }
137 \_def\.processbooksA #1 {%
138 \_if\_relax#1\_relax \_else \_sxdef{pbook!#1}{}\_ea\.processbooksA \_fi
139 }
140 \_def\.processbooksB #1 {%
141 \_if\_relax#1\_relax \_else
142 \_edef\amark{#1}
143 \_edef\bmark{\_cs{f!#1}}
144 \_edef\.btit{\_cs{btit!#1}}
145 \_begingroup
146 \_edef\.currbook{#1}
147 \.newbook{#1}
148 \_wterm{^^J** \_cs{btit!#1} {#1} (\string\tmark: \tmark) **^^J}
149 \_cs{bex!#1}
150 \_isfile{\introfile}\_iftrue \.printintro
151 \_else \.printwarn{File with introduction text \introfile\_space not found}\_fi
152 % \.CommentedBook{#1}
153 \_isfile{\fmtfile}\_iftrue \_input{\fmtfile}
154 \_else \.printwarn{File with format info \fmtfile\_space not found}\_fi
155 \_isfile{\notesfile}\_iftrue \_input{\notesfile}
156 \_else \.printwarn{File with notes \notesfile\_space not found}\_fi
157 \_cs{bpr!#1}
158 \.bibleinput{\txsfile}
159 \.chapafter % material after the last chapter
160 \_cs{bpo!#1}
161 \_endgroup
162 \_ea \.processbooksB
163 \_fi
164 }
165 \_nspublic \processbooks ;
166
167 \_doc
168 \`\.newbook``{<a-mark>}` ejects previous page, prepeares header and prints the book title.
169 \_cod
170
171 \_def\.newbook#1{\_vfil\_supereject
172 \_let\.prelinkB=\.currbook \.chapnum=0
173 \_def\.prelinkC{0}\_def\.prelinkV{0}
174 \_global\_headline={\_hfil \_ea\.setheadline\_ea{\.btit}}
175 \_line{\_hss\.bookfont\.btit\_hss}
176 \_label[cref!#1]\_wlabel{#1}
177 \_par\_nobreak\_medskip
178 }
179
180 \_doc
181 \`\.setheadline``{<book-title>}` sets `\_headline`. It is re-set for each
182 new book by \^`\.newbook`.\nl
183 The \`\bibname` can be defined by user as a name of the translating variant
184 of the Bible. If it is not defined then it is empty by default.
185 \_cod
186
187 \_def\.setheadline#1{\_global\_headline={\.headfont
188 \_ifodd\_pageno
189 \_rlap{\_it\bibname\_hss}%
190 \_hfil \_the\_pageno\_hfil
191 \_hbox to\.lrmargin{\_hss\_bf#1\_ifx^\_botmark^\_else\_space \_botmark\_fi}%
192 \_kern-\.lrmargin
193 \_else
194 \_kern-\.lrmargin
195 \_hbox to\.lrmargin{\_bf#1 \_firstmark\_hss}%
196 \_hfil \_the\_pageno\_hfil
197 \_llap{\_hss\_it\bibname}%
198 \_fi
199 }
200 }
201 \_def\bibname{}
202
203 \_doc
204 We want \code{<Fm 4>} to be a link to Fm/1:4 because it is a
205 single-chapter book. Compare \code{<Gn 4>} which is a link to Gn/4:1.
206 There is a list of single-chapter books \`\nochapbooks`. User
207 must define it. The marks of these single-chapter books are separated by spaces
208 here. The first and the last space are added to the \^`\nochapbooks`
209 macro because we need them in \`\.brefBookChapter`.
210 The \`\.checknochapbooks` macro does it, moreower, it checks if the
211 \^`\nochapbooks` is defined. If not, it prints warning.
212 \_cod
213
214 \_def\.checknochapbooks {%
215 \_ifx\nochapbooks\_undefined
216 \.printwarn{\_noexpand\nochapbooks (boks without chapters) undefined.}%
217 \_def\nochapbooks{}%
218 \_else \_edef\nochapbooks{\_space\nochapbooks\_space}\_fi
219 }
220
221 \_doc
222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 \sec Book titles
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
225
226 The macro \`\BookTitle` `<a-mark> <b-mark> {<title>}` declares titles
227 of each Bible books. The <a-mark> is an actual book mark used in printed text.
228 The <b-mark> can be used in file names as \^`\bmark`.
229 The mapping is done here:
230 `\def`\`\btit!``<a-mark>{<title>}`, `\def`\`\f!``<a-mark>{<b-mark>}`.
231
232 The macro is defined as `\outer` because we don't want to see obscure
233 errors due to missing a space after `<b-mark>` or `<a-mark>`.
234 \_cod
235
236 \_def\genbooks{}
237 \_def\.BookTitle #1 #2 #3{%
238 \_sxdef{btit!#1}{#3}\_sxdef{f!#1}{#2}\_sxdef{fb!#2}{#1}%
239 \_addto\genbooks{#2 }%
240 }
241
242 \_doc
243 The \`\BookException` `<a-mark> {<code>}` macro adds the <code> to the
244 \`\bex!``<a-mark>` macro. It is used in \^`\processbooks`
245 loop in the group before files are read. You can redefine some filenames
246 or something more special here.\nl
247 Macros \`\BookPre` `<a-mark> {<code>}` and \`\BookPost` `<a-mark> {<code>}`
248 are defined similarly. They add <code> to the \`\bpr!``<a-mark>` and to
249 the \`\bpo!``<a-mark>` macros repectively.
250 \_cod
251
252 \_outer\_long\_def\.BookException #1 #2{\.myaddto{bex!#1}{#2}}
253 \_outer\_long\_def\.BookPre #1 #2{\.myaddto{bpr!#1}{#2}}
254 \_outer\_long\_def\.BookPost #1 #2{\.myaddto{bpo!#1}{#2}}
255
256 \_nspublic \BookTitle \BookException \BookPre \BookPost ;
257
258 \_doc
259 The `\ChapterPre``{<code>}` and `\ChapterPost``{<code>}` inserts <code>
260 before each chapter and after each chapter. The <code> is the same for
261 each chapter, it does not vary depending on the Book or Chapter number.
262 \_cod
263
264 \_long\_def\.ChapterPre #1{\_def\.chapbefore{#1}}
265 \_long\_def\.ChapterPost #1{\_def\.chapafter{#1}}
266
267 %\_outer\_def\ChapterPre {\.ChapterPre}
268 %\_outer\_def\ChapterPost {\.ChapterPost} % be done at the end of this file
269
270 \_doc
271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272 \sec Actions
273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274 We create the output in two steps. First step: the data from \^`\Note`
275 etc.\ are read and saved to the \TeX/ memory. For each such data element the
276 \"action" is registered to a list of actions of the given verse. Each
277 Bible verse has its list of actions.
278 The second step: the Bible verses are read from a `.txs`
279 file and all appropriate actions (registered to this verse) are
280 processed before the verse text is printed. These actions can modify the
281 selected parts of the verse text.\nl
282 \`\alist!``<full-vref>` is the list of actions associated with the verse
283 `<full-vref>`. The <full-vref> is full reference to the verse in the format
284 <book-mark>/<chapter-num>:<verse-num>\nl
285 \`\.newaction``{<full-vref>}{<action-body>}` allocates new action.
286 \_cod
287
288 \_def\.newaction#1#2{%
289 \_unless\_ifcsname alist!#1\_endcsname \_sdef{alist!#1}{}\_fi
290 \_ea\_addto\_csname alist!#1\_endcsname{#2}%
291 }
292
293 \_doc
294 A typical \"action" is `\.replpre`. The actions are processed for each
295 Bible verse when the verse text is saved to the \^`\.buff` macro. The
296 \^`\.buff` macro is processed after all actions of given verse are done.\nl
297 \`\.replpre``{<prefix>}{<text>}{<fail>}` replaces first occurrence of <text>
298 by `<prefix>{<text>}` in `\.buff` macro. If the <text> is empty then
299 `<prefix>{}` is inserted at the beginning of the \^`\.buff`.
300 \_cod
301
302 \_def\.replpre#1#2#3{%
303 \_ifx^#2^\_def\.tmp{#1{}}\_ea\_ea\_ea\_def\_ea\_ea\_ea\.buff\_ea\_ea\_ea{\_ea\.tmp\.buff}%
304 \_else
305 \.replbuff{#2}{#1{#2}}{#3}%
306 \_fi
307 }
308
309 \_doc
310 \`\.replprepost``{<text>}{<pre>}{<post>}{<fail>}`
311 searches <text> in \^`\.buff` and adds <pre> before and <post> after the <text>. If the
312 <text> is not found then <fail> is executed.
313 The \^`\.replprepost` is used by \^`\fmtins` (with empty <pre>) because we want to insert the
314 <post> material directly.\nl
315 The \^`\fmtkeep` uses \^`\.replprepost` with empty <pre> and <post> together.
316 \_cod
317
318 \_def\.replprepost#1#2#3#4{\.replbuff{#1}{#2#1#3}{#4}}
319
320 \_doc
321 Both, \^`\.replpre` and \^`\.replprepost`, use
322 \`\.replbuff``{<what>}{<whom>}{<fail>}`
323 which replaces first occurence of <what> by <whom> in `\.buff`.
324 If <what> doesn't exists then `\.text` is defined as <what>
325 and <fail> is executed.
326 \_cod
327
328 \_def\.replbuff #1#2#3{%
329 \_def\.replpredo##1#1##2\_end{%
330 \_ifx\_end##2\_end \_def\.text{#1}#3% <fail>
331 \_else \.replsave ##1#2##2\_end \_fi
332 }%
333 \_def\.replsave##1#1\_end{\_def\.buff{##1}}%
334 \_ea\.replpredo\.buff#1\_end
335 }
336
337 \_doc
338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
339 \sec The `\Note` macro
340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341 The first parameter of the \^`\Note` macro is `<gen-vref>`.
342 It is generalized reference to the Bible verse. It can be
343 `<chapter-num>:<verse>` (the <book-mark> is appended from
344 the \^`\.currbook` macro) or `<chapter-num>:<verse-from>-<verse-to>`
345 (only <verse-from> is used for generating <gen-vref>.\nl
346 \`\.gentovref``{<gen-vref>}` expands to <full-vref>.
347 \_cod
348
349 \_def\.gentovref#1{\.currbook/\.gentovrefA#1-\end}
350 \_def\.gentovrefA#1-#2\end{#1}
351
352 \_doc
353 \`\.renumvref`` <full-vref>\_relax` does re-caclulating of <full-vref> using
354 \^`\renum` data.
355 \_cod
356
357 \_def\.renumvref #1/#2\_relax{#1/\_trycs{rn!\tmark!#1/#2}{#2}}
358
359 \_doc
360 The `<word>` given as a parameter of the \^`\Note` macro (see bellow) is used as a word
361 phrase which should be be searched in the given verse text. This parameter `<word>`
362 is transformed first by expansion of \^`\.transformword{<word>}` to the `<tword>` variant
363 and the `<tword>` is actually used for searching. The \`\.transformword``{<word>}`
364 expands to the variant of the <word> declared by `\.vdef`. If not declared then it
365 expands to the <word> itself, i.e <tword> is equal to <word> in this case.
366 \_cod
367
368 \_def\.transformword#1{%
369 \_ifcsname v!\tmark!#1\_endcsname \_lastnamedcs
370 \_else #1\_fi
371 }
372
373 \_doc
374 \`\Note`` <gen-vref> <space> {<word>} <text> \par`
375 transforms <word> to the <tword> (see above),
376 saves <text> and activates replace-action of <tword> to
377 \^`\.doNote{<note-num>}{<tword>}` in given verse.
378 \nl
379 There is an alternative syntax
380 \^`\Note <gen-vref> <space> {<word>}={<pword>} <text> \par`
381 If <pword> is given then it is printed in the note instead <tword>.
382 More precisely: transformed <word> is used for searching
383 (and it is kept in the verse unchanged) but <pword> is
384 printed in the note.\nl
385 The \^`\ww` can precede \^`\Note`. If it is true then the <word> is prepared in
386 \^`\.nextww` and `<pword>` is in \^`\.nextwwA`. Otherwise, the macros \^`\.nextww`
387 and \^`\.nextwwA` are undefined.\nl
388 `\Note` does exactly following:
389 \begitems
390 * Calculates <full-vref> using `\.gentovref{<genv-ref>}` and svese it to
391 \`\.fullvref`.
392 * If the verse number of <full-vref> is zero, we want to insert the
393 note-text before the chapter. This is one by the \^`\.NoteB` macro.
394 * Allocates new <note-num>, i.e. \`\.notenum` is <note-num>.
395 * Modifies <full-vref> if \^`\renum` was declared using `\.renumvref` and
396 saves the result to \`\.fullvrefm`.
397 * Uses \^`\.nextww` and \^`\.nextwwA` as <tword> and <pword> if they are defined.
398 * Otherwise transforms <word> to <tword> by \^`\.transformword`.
399 * Reads <pword> (word to be printed in the note) by `\.NoteA` if the alternative syntax
400 with `={<pword>}` is used. Else <pword> is equal to <tword>.
401 Use it only if \^`\.nextww` is undefined.
402 * Defines \`\notetext!``<note-num>` as <text>.
403 * Defines \`\noteref!``<note-num>` as <full-vref> re-calulated by \^`\renum`.
404 * Defines \`\notepre!``<note-num>` as numeric part of modified <full-vref>.
405 and calculates <from>-<to> part (if exists in <gen-vref>) using \^`\.renumlabel` macro.
406 This is printed prefix of the `\Note`.
407 * Defines \`\pword!``<note-num>` as <pword>,
408 * Does
409 \^`\.newaction{<full-vref>}{\.replpre{\.doNote{<note-num>}}`\nl
410 \null\hskip14em `{<tword>}{\.notefail{<note-num>}}}`.\nl
411 This is done by \`\.AddNote``{<full-vref>}{<note-num>}{<tword>}`.
412 \enditems
413 Note that \^`\Note` is defined as `\outer` in order to report correctly typical
414 mistakes with missing empty line the <text> of a previous `\Note`.
415 \_cod
416
417 \_newcount\.notenum
418 \_def\.Note #1 #2{%
419 \_edef\.fullvref{\.gentovref{#1}}%
420 \_ea\.isversezero\.fullvref\_iftrue
421 \_ea\.NoteB
422 \_else
423 \_incr\.notenum
424 \_edef\.fullvrefm{\_ea\.renumvref\.fullvref\_relax}%
425 \_def\.tmp{#1}\.sedef{notepre!\_the\.notenum}{\_ea\.renumlabel\.fullvrefm\_relax}%
426 \_ifx\.nextww\_undefined
427 {\_def\.printwarn##1{}\_xdef\.tword{\.transformword{#2}}}%
428 \_else \_xdef\.tword{\.nextww}\_fi
429 \_afterfi{\_isnextchar={\.NoteA}{\.NoteA={}}}%
430 \_fi
431 }
432 \_def\.NoteA=#1#2% #2 separated by \par or \_par:
433
434 {%
435 \_sdef{notetext!\_the\.notenum}{\_ignorespaces#2}%
436 \.sedef{noteref!\_the\.notenum}{\.fullvrefm}%
437 \_ifx\.nextww\_undefined
438 \_ifx^#1^\_sdef{pword!\_the\.notenum\_ea}\_ea{\.tword}\_else \_sdef{pword!\_the\.notenum}{#1}\_fi
439 \_else
440 \_sdef{pword!\_the\.notenum\_ea}\_ea{\.nextwwA}%
441 \_let\.nextww=\_undefined \_let\.nextwwA=\_undefined
442 \_fi
443 \.reducetword
444 \_ea\.addNote\_expanded{{\.fullvrefm}{\_the\.notenum}{\.tword}}%
445 }
446 \_def\.addNote#1#2#3{%
447 \_ifx^#3^% \.tword is empty
448 \_edef\.tmp{\_cs{notepre!#2}}%
449 \_ea \.isdivisin\.tmp-\_iftrue
450 \.newaction{#1}{\.replpre{\.doNote{#2}}{}{}}%
451 \_else
452 \.newaction{#1}{\_addto\.prebuff{\.doCNote{#2}{}}}%
453 \_fi
454 \_else
455 \.newaction{#1}{\.replpre{\.doNote{#2}}{#3}{\.notefail{#2}}}%
456 \_fi
457 }
458 %\_outer\_def\Note{\.Note} % will be done at the end of this macro file
459
460 \_doc
461 The \`\.NoteB`` <text> \par`
462 does not register any action to the verse but defines
463 `\chapnote!<full-vref>` as the <text>. This chapter note will be printed
464 before the chapter starts.
465 \_cod
466
467 \_def\.NoteB #1% #1 separated by \par or \_par
468
469 {%
470 \_sdef{chapnote!\.fullvref}{\_ignorespaces#1}%
471 }
472 \_def\.isversezero#1/#2:#3\_iftrue{\_ifnum #3=0 }
473
474 \_doc
475 \`\.renumlabel` `<full-vref>\_relax` expands to the numeric part of
476 <full-vref> and appends the `--<to>` part if the `\.tmp` macro is in the
477 format `<chapter>:<from>-<to>`. The <to> part is re-calculated in order to
478 the the number of verses between `<from>` and `<to>` be kept.
479 If the `<to>` part is in the format <chapter>:<verse>
480 then it is unchanged. The \^`\.renumlabel` macro must be expandable, so we
481 cannot use `\isinlist` and we prepare special expandable macros
482 \^`\.isdivisin` and \^`\.iscolonin`.
483 \_cod
484
485 \_def\.renumlabel#1/#2\_relax{#2%
486 \_ea\.isdivisin\.tmp-\_iftrue --\_ea\.renumlabelA\.tmp\_relax#2\_relax \_fi
487 }
488 \_def\.renumlabelA#1:#2-#3\_relax#4:#5\_relax{%
489 \.iscolonin#3:\_iftrue #3\_else \_the\_numexpr#5+#3-#2\_relax \_fi
490 }
491
492 \_doc
493 The \^`\Note` text is processed and printed in the second step, when the
494 `.txs` file is read. Actions are assigned to each verse and they are run
495 before the appropriate verse is printed. And `\``Note` action says:
496 \begtt
497 \.replpre{\.doNote{<note-num>}}{<tword>}{\.notefail{<note-num>}}
498 \endtt
499 It means that the `<tword>` is searched in the verse text and
500 replaced by \^`\.doNote{<note-num>}{<tword>}`.
501 If `<tword>` is not found then \`\.notefail``{<note-num>}` prints warning
502 about it and\nl \^`\.doNote{<note-num>}{}` is prefixed before the verse text.
503 \_cod
504
505 \_def\.notefail#1{%
506 \.printwarn{\_csstring\\Note: \.currverse: The text "\_unexpanded\_ea{\.text}" not found}%
507 \.replpre{\.doNote{#1}}{}{}% \Note is registered with the beginning of the verse
508 }
509
510 \_doc
511 The \`\.doNote``{<note-num>}{<tword>}` prints the real note text in the second step,
512 when the verse text from \^`\.buff` is processed.\nl
513 The `<chapter>:<verse>` is printed from \^`\notepre!` only if it differs
514 from previous one, i.e.\ from \`\.prevnotepre`.
515 The <pword> is printed with uppercase first letter by \^`\.upcasefirst`
516 and with appended dot, but the dot is not printed
517 if the <pword> ends by `?` or `!` or `.`.
518 \_cod
519
520 \_def\.prevnotepre{}
521 \_def\.doNote#1#2{%
522 \_edef\.tmpb{\_cs{notepre!#1}}%
523 \.notelog{\_space\_space \_csstring\\Note \.tmpb\_space {#2}={\_cs{pword!#1}} (#1)}%
524 \.noteinsert{%
525 {\_bf \_ifx\.prevnotepre\.tmpb \_else \.tmpb \_enskip \_glet\.prevnotepre=\.tmpb \_fi
526 \.trymakedest{n:\_cs{noteref!#1}}%
527 \_edef\.tmpb{\_csname pword!#1\_endcsname}%
528 \_ifx\.tmpb\_empty \_else
529 \_addto\.tmpb{.\_relax}\.punctpword
530 \_ea\.upcasefirst \.tmpb\_space
531 \_fi
532 }% end of \bf
533 \_cs{notetext!#1}}%
534 {\notecolor#2}%
535 }
536 \_def\_printfnotemark{}
537 \_def\_textindent#1{\_noindent}
538
539 \_doc
540 The <pword> is typically all lowercase.
541 But we want to capitalize the first letter of the <pword>
542 when printing by \`\.upcasefirst`.
543 You can say `\let\.upcasefirts=\relax` if you don't want
544 this feature.
545 \_cod
546
547 \_def\.upcasefirst #1{\_uppercase{#1}}
548
549 \_doc
550 The dot is added to <pword> when it is printed. But if <pword> ends by
551 `!` or `?` or `.` then the added dot is uggly. We have to correct it in
552 the \`\.punctpword` macro. Note that <pword> is saved to `\.tmpb`.
553 \_cod
554
555 \_def\.punctpword{\_replstring\.tmpb{!.\_relax}{!}\_replstring\.tmpb{?.\_rleax}{?}%
556 \_replstring\.tmpb{..\_relax}{.}}
557
558 \_doc
559 When \^`\Note` has empty parameter <word> (i.e. <tword>) then it is anchored to the
560 beginning of the verse. Moreower, if there are more such Notes referenced
561 to the same verse then we merge all such notes to single note. So
562 \`\.doCNote``{<notenum>}` is run from \^`\.prebuff` and it only adds the text of
563 the note to the \`\.Cnotetext` buffer. When \`\.prebuff` is completed then
564 \`\.printCnote` prints the merged note.
565 \_cod
566
567 \_def\.doCNote #1{%
568 \_edef\.tmpb{\_csname pword!#1\_endcsname}%
569 \.notelog{\_space\_space \_csstring\\Note \.tmpb\_space {}={\_cs{pword!#1}} (#1)}%
570 \_edef\.prevnotepre{\_cs{notepre!#1}}%
571 \_ifx\.tmpb\_empty \_else
572 \_addto\.tmpb{.}\.punctpword
573 \_edef\.tmpb{{\_noexpand\_bf \_ea\.upcasefirst\.tmpb\_noexpand~}}%
574 \_ea\_addto \_ea\.Cnotetext \_ea{\.tmpb}%
575 \_fi
576 \_ea\_ea\_ea\_addto\_ea\_ea\_ea\.Cnotetext\_ea\_ea\_ea{\_csname notetext!#1\_endcsname}%
577 }
578 \_def\.printCnote{%
579 \_ifx\.Cnotetext\_empty \_else
580 \.noteinsert{%
581 {\_bf \_ea\.nobook\.currverse\_relax \.trymakedest{n:\.currverse}} \.Cnotetext
582 }%
583 \_fi
584 }
585 \_def\.nobook #1/#2\_relax {#2} % only chapter:verse is printed
586
587 \_doc
588 `\.reducetword` does nothing by default. But \`\megrednotes`
589 re-defines it, so all \^`\Note`s are referenced to the begining of the
590 verse and nothing is searched. The \^`\Note`s with the same verse are merged in
591 this case using \^`\.doCNote`.
592 \_cod
593
594 \_def\.reducetword{}
595 \_def\.mergednotes{\_def\.reducetword{\_def\.tword{}}}
596 \_nspublic \mergednotes ;
597
598 \_doc
599 Because there is asynchronous processing of the \^`\Note` text, we have a problem
600 when an error occurs here. We cannot reference to appropriate line where
601 the \^`\Note` is written. So, we print the parameters of processed
602 \^`\Note` to the log file. The user can look into this file and the last
603 printed \^`\Note` parameters here refers probably to the \^`\Note` where the
604 reason of the error is.\nl
605 The logging is done by \`\.notelog``{<text>}`. It is `\wlog` by default but
606 you can set it to `\ignoreit` or `\wterm`.
607 \_cod
608
609 \_let\.notelog=\_wlog
610
611 \_doc
612 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613 \sec Inserting data from format files
614 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615 \`\fmtpre`` {<gen-vref>}{<what>}` adds <what> to \`\.fmtprebuff`, i.e.\ at the
616 beginning of the verse.\nl
617 \`\ftmadd`` {<gen-vref>}{<what>}` adds <what> to \^`\.buff`, i.e.\ at the end
618 of the verse.\nl
619 \`\fmtins`` {<gen-vref>}{<text>}{<what>}` inserts <what> after <text> in the
620 verse. If <text> is not found then <what> is inserted like \^`\fmtpre` does it\nl
621 All these commands allocate new action using \^`\.newaction`.\nl
622 \`\.addpre``\macro{<text>}` adds the text to the macro before its
623 original contents.
624 \_cod
625
626 \_def\.fmtpre#1#2{\.newaction{\.gentovref{#1}}{\_addto\.fmtprebuff{#2}}}
627 \_def\.fmtpreind#1#2{\.newaction{\.gentovref{#1}}{\.addpre\.preindbuff{#2}}}
628 \_def\.fmtadd#1#2{\.newaction{\.gentovref{#1}}{\_addto\.buff{\_empty#2}}}
629 \_def\.fmtins#1#2#3{\.newaction{\.gentovref{#1}}{\.replprepost{#2}{}{\_empty#3}{\.fmtfail{#3}}}}
630 \_def\.fmtfail#1{\.fmtwarn\_addto\.fmtprebuff{#1}}
631 \_def\.fmtwarn{\.printwarn{\_string\fmtins: \.currverse: The text "\.text" not found}}
632 \_def\.addpre#1#2{\_ea\.addpreA \_ea{#1}{#2}#1}
633 \_def\.addpreA #1#2#3{\_def#3{#2#1}}
634
635 \_nspublic \fmtpre \fmtadd \fmtins ;
636
637 \_doc
638 \`\begcenter` starts the centering mode. It opens a group and does
639 setting. User must use paired \`\endcenter` in order to close this group.
640 The \`\centeringmode` status is checked by \^`\endcenter` because curious error
641 (about `#` character) should be occur without this checking.
642 \_cod
643
644 \_newdimen\.centermargin \.centermargin=4em
645 \_def\.begcenter{\_par \_ifnum\_lastpenalty<10000 \_medskip \_fi
646 \_bgroup
647 \_def\.centeringmode{y}
648 \_parindent=0pt
649 \_leftskip=\.centermargin plus1fill
650 \_rightskip=\_leftskip
651 }
652 \_def\.endcenter{\_par
653 \_ifx\.centeringmode\_undefined
654 \.printwarn{\_noexpand\endcenter ignored: no \_noexpand\begcenter precedes}
655 \_else \_egroup \_medskip \_fi
656 }
657 \_nspublic \begcenter \endcenter ;
658
659 \_doc
660 \`\ind``{<number>}` gives an indentaion in the poetry environment.
661 It is used in \^`\fmtpoetry`, the `\ind``{<number>}` is inserted typically
662 by \^`\fmtins` or \^`\fmtpre`.
663 It ends the current line by `\par` only if we are not at beginning of a verse~1.\nl
664 The `\spacefactor` is set to 1001, this value is used
665 by the macro \^`\.hboxorllap`: the verse number is llaped after `\ind`.
666 \_cod
667
668 \_newifi\_ifopb_firstverse
669
670 \_def\.ind#1{\_unless \_ifopb_firstverse \_par \_else \_hskip-\_parindent \_fi
671 \_noindent
672 \_hskip#1\_iindent \_spacefactor=1001 \_ignorespaces}
673
674 \_doc
675 \`\fmtpoetry``{<gen-vref>}{<fmt-data>}` saves `<gen-vref>` to `\.tmpa`
676 and runs <fmt-data> in recursive loop using \`\.fmtpoetA`.
677 The \`\.fmtpoetB` counts the number of slashes in local recursive loop
678 and saves the result to the `\_tmpnum`. The \`\.fmtpoetC` inserts desired
679 material using \`\fmtprepoet` or \^`\fmtins` and using `\ind{\_the\_tmpnum}`.
680 \_cod
681
682 \_def\.fmtpoetry#1#2{\_def\.tmpa{#1}\.fmtpoetA #2\_end}
683 \_def\.fmtpoetA #1/{\_def\.tmpb{#1}\_tmpnum=1 \.fmtpoetB}
684 \_def\.fmtpoetB #1{\_ifx/#1 \_incr\_tmpnum \_ea\.fmtpoetB \_else \_afterfi{\.fmtpoetC#1}\_fi}
685 \_def\.fmtpoetC #1{%
686 \_expanded{\_ifx\.tmpb\_empty \_noexpand\.fmtpreind{\.tmpa}\_else
687 \_noexpand\.fmtins{\.tmpa}{\.tmpb}\_fi{ \_noexpand\.ind{\_the\_tmpnum}}}%
688 \_ifx\_end#1 \_else \_afterfi{\.fmtpoetA#1}\_fi
689 }
690 \_nspublic \ind \fmtpoetry ;
691
692 \_doc
693 \`\fmtfont` `{<gen-vref>}{<whar>}{<cmd>}`
694 replaces <what> by `\bgroup <cmd><what>\egroup`.\nl
695 \`\fmtkeep` `{<gen-vref>}{<what>}`
696 replaces <what> by `{<what>}`, so it is unsearchable.\nl
697 \`\fmtrepl` `{<gen-vref>}{<what>}{<wham>}`
698 replaces <what> by <whom>.
699 \_cod
700
701 \_def\.fmtfont#1#2#3{%
702 \.newaction{\.gentovref{#1}}{\.replprepost{#2}{\bgroup#3}{\egroup}{\.fmtwarnf\fmtfont}}}
703 \_def\.fmtkeep#1#2{%
704 \.newaction{\.gentovref{#1}}{\.replpre{}{#2}{\.fmtwarnf\fmtkeep}}}
705 \_def\.fmtrepl#1#2#3{\.newaction{\.gentovref{#1}}{\.replbuff{#2}{#3}{\.fmtwarnf\fmtkeep}}}
706
707 \_def\.fmtwarnf#1{\.printwarn{\_string#1: \.currverse: The text "\.text" not found}}
708 \_nspublic \fmtfont \fmtkeep \fmtrepl ;
709
710
711 \_doc
712 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
713 \sec Printing verses from `.txs` files
714 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
715 When Bible text is processed then book mark is saved to
716 \^`\.currbook` and each input line is separated to the
717 <chapter-num>:<verse-num> and <verse-text>.\nl
718 The \`\.processline`` <chapter>:<verse><space><verse-text>^^J` is repeatedly processed.
719 \_cod
720
721 \_eoldef\.processline#1{\.processverse \.currbook/#1\_end}
722
723 \_doc
724 \`\.processverse`` <full-vref><space><verse-text>\_end` does
725 \begitems
726 * defines \`\.currverse` as <full-vref>,
727 * prepares \`\.currversenum`, \`\.currversetext`, \`\.currchapnum` from <full-vref>,
728 * defines \`\.buff` as <verse-text>,
729 * processes all actions from \^`\alist!``<full-vref>`,
730 * if \^`\.currchapnum` changed, prints `\.chapafter` (for previous chapter)
731 and `\.chapbefore` (for new chapter).
732 * prints verse from \^`\.buff` using \^`\.printverse`
733 \enditems
734 \_cod
735
736 \_newcount\.chapnum
737 \_def\.processverse #1 #2\_end{%
738 \_xdef\.currverse{#1}%
739 \.preparechapverse #1
740 \_let\.prelinkV=\.currversenum
741 \_gdef\.buff{#2}\_gdef\.fmtprebuff{}\_gdef\.preindbuff{}\_gdef\.prebuff{}\_gdef\.Cnotetext{}%
742 \_ifx\.verseto\_empty \_csname alist!#1\_endcsname \_else
743 \_fornum \.versefrom..\.verseto \_do{\_csname alist!\.currbook/\.currchapnum:##1\_endcsname}%
744 \_fi
745 \_ifnum\.currchapnum=\.chapnum \_else
746 \_ifnum\.chapnum>1 \.chapafter \_fi
747 \_let\.prelinkC=\.currchapnum \.chapnum=\.currchapnum\_relax
748 \.chapbefore
749 \_label[cref!\.currbook\_space\_the\.chapnum]\_wlabel{\.currbook~\_the\.chapnum}%
750 \_fi
751 \.printverse
752 }
753 \_def\.preparechapverse #1/#2:#3 {\_def\.currchapnum{#2}%
754 \_def\.verseto{}%
755 \.isdivisin #3-\_iftrue \.defversefromto #3\_end
756 \_else \_def\.currversenum{#3}\_glet\.currversetext=\.currversenum
757 \_fi
758 }
759 \_def\.defversefromto #1-#2\_end{%
760 \_def\.versefrom{#1}\_def\.verseto{#2}%
761 \_def\.currversenum{#1}\_gdef\.currversetext{#1--#2}}
762
763 \_doc
764 User can do little changes in the verse text using \`\cnvtext``{<what>}{<replaced>}`.
765 For example you can do `\cnvtext{[}{\bgroup\it}\cnvtext{]}{\/\egroup}`
766 for making `[words]` in brackets printed italics.
767 \_cod
768
769 \_def\.prepareversetext{}
770 \_def\.cnvtext#1#2{\_addto\.prepareversetext{\_replstring\.buff{#1}{#2}}}
771 \_nspublic \cnvtext ;
772
773
774 \_doc
775 \`\.printverse` prints verse from \^`\.currversenum` and (possibly changed) \^`\.buff`.
776 It prints the single raised verse number first.\nl
777 \`\.printbeforefirst` is a macro which is executed just before first verse
778 of the chapter, after all material from \^`\fmtpre` is executed. I.e after
779 printing a chapter name (if declared by \^`\fmtpre`).\nl
780 The \`\.fmtprebuf` includes \^`\ind` command from \^`\fmtpoetry` if the
781 verse should be indented at its begin before the verse number.
782 The verse number is shifted up and it is in an `\hbox` or it is llapped in the
783 poetry environment, more exactly immediatelly after \^`\ind` is used. The
784 \`\.hboxorllap` macro does this game.
785 \_cod
786
787 \_def\.printverse{%
788 \.fmtprebuff % material accumulated by \fmtpre
789 \_ifnum\.currversenum=1 \.firstversetrue \.printbeforefirst \_fi
790 \_quitvmode \_mark{\.currchapnum:\.currversetext}%
791 \_ifx\.verseto\_empty \.trymakedest{v:\.currverse}%
792 \_else \_fornum \.versefrom..\.verseto \_do{%
793 \_wlog{xxxxx v:\.currbook/\.currchapnum:##1}\.trymakedest{v:\.currbook/\.currchapnum:##1}}%
794 \_fi
795 \.preindbuff
796 \_raise5pt\.hboxorllap{\_unless\_ifnum\.currversenum=1 \.markfont\.currversetext\,\_fi}%
797 \.firstversefalse
798 \.prepareversetext
799 \.prebuff\.printCnote\.buff \_space
800 }
801 \_def\.hboxorllap{\_ifnum\_spacefactor=1001 \_ea\_llap \_else \_ea\_hbox \_fi}
802
803 \_def\.printbeforefirst{%
804 \_par\_nobreak \_medskip
805 \.trychapnote
806 \_setbox0=\_vtop{\_kern-1.5ex \_ewref\_sxdef{{ch!\.currbook/\_the\.chapnum}{\_string\.mypage}}
807 \_hbox{\_setfontsize{at50pt}\_bf\LiRed\_the\.chapnum}}
808 \_dp0=0pt
809 \_tmpdim=\.lrmargin
810 \_advance\_tmpdim by4pt
811 \_ifnum\_the\.chapnum>9 \_advance\_tmpdim by19pt \_fi
812 \_ifodd\_trycs{ch!\.currbook/\_the\.chapnum}{0}
813 \_moveright\_tmpdim \_line{\_hss\_box0}
814 \_else \_moveleft\_tmpdim \_box0 \_fi
815 \_nobreak \_vskip-\_medskipamount
816 \_nobreak \_nointerlineskip \_noindent
817 }
818
819 \_doc
820 \`\.printchapnote``{<text>}` implements printing the notes declared by `\Note` `<chapnum>:0`.
821 It is run using \`\.trychapnote` only if the relevant not is declared.
822 \_cod
823
824 \_def\.trychapnote{%
825 \_ifcsname chapnote!\.currbook/\_the\.chapnum:0\_endcsname
826 \.printchapnote{\_cs{chapnote!\.currbook/\_the\.chapnum:0}}\_fi
827 }
828 \_def\.printchapnote #1{\_par
829 {\_leftskip=\_parindent plus1fill \_rightskip=\_leftskip \_noindent\_it #1\_par}
830 \_medskip
831 }
832 \_nspublic \printchapnote ;
833
834 \_doc
835 \`\.chapbefore` is processed before each chapter.
836 \`\.chapafter` is processad after each chapter.
837 User can define values by `\ChapterPre` and `\ChapterPost` macros.
838 \_cod
839
840 \_def\.chapbefore{\_bigskip} \_def\.chapafter{}
841
842
843 \_doc
844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
845 \sec Bible references
846 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
847
848 The \code{\<} will be set to active as character equivalent to
849 the macro \`\.bref``<text>>`. This macro does all job with the hyperlinks.
850 Fist of all, it scans the parts of the `<text>` and saves them to
851 \begitems
852 * \`\.ltextP` ... the text before a link specification (given in `"..."`)
853 * \`\.ltextB` ... the book mark followed by `~`
854 * \`\.ltextC` ... the chapter number followed by `:`
855 * \`\.ltextV` ... the verse number
856 * \`\.ltextS` ... sub-verse identifier (`a` if there is a verse `4a`)
857 * \`\.ltextF` ... the `--` if the `<from>-<to>` format is given
858 * \`\.ltextN` ... the `<to>` part from the `<from>-<to>` format.
859 \enditems
860 All these macros above can be empty if the appropriate part of the
861 scanned `<text>` is missing.
862 The \`\.linkpre` macro includes `v` if it is verse link,
863 includes `n` if it is note link and `g` if it is gloss link.
864 These macros will be converted due to \^`\renum` data (if needed)
865 and printed by \`\.linktext`.
866 \_cod
867
868 \_def\.linktext{\.ltextP\.ltextB\.ltextC\.ltextV\.ltextS\.ltextF\.ltextN}
869 \_def\.bref #1>{\_let\.brefH=\_relax \_def\.linkspec{#1}\_isnextchar"{\.brefA}{\.brefA""}#1>}
870 \_def\.brefA"#1"{\_def\.ltextP{#1}%
871 \_isnextchar{ }{\_addto\.ltextP{~}\_afterassignment\.brefB\_let\.next= }%
872 {\_isnextchar{_}{\_def\.brefH{}\_afterassignment\.brefB\_let\.next= }{\.brefB}}%
873 }
874 \_def\.brefB #1>{% #1 is link-spec
875 \_def\.ltextB{}\_def\.ltextC{}\_def\.ltextF{}\_def\.ltextN{}%
876 \.isspacein #1 \_iftrue
877 \.iscolonin #1:\_iftrue \.brefBookChapterVerse #1>%
878 \_else \.brefBookChapter #1>\_fi
879 \_else \.iscolonin #1:\_iftrue \.brefChapterVerse #1>%
880 \_else \.brefVerse #1>%
881 \_fi\_fi
882 \_def\.linkpre{v}%
883 \_isnextchar n{\_def\.linkpre{n}\.brefC}%
884 {\_isnextchar g{\_def\.linkpre{g}\.brefC}%
885 {\_isnextchar a{\_def\.linkpre{a}\.brefC}%
886 {\_isnextchar i{\_def\.linkpre{i}\.brefC}{\.brefD}}}}%
887 }
888 \_def\.brefC{\_afterassignment\.brefD \_let\.next= }
889
890 \_def\.brefBookChapterVerse #1 #2:#3>{\_def\.ltextB{#1~}\.brefChapterVerse #2:#3>}
891 \_def\.brefBookChapter #1 #2>{\_def\.ltextB{#1~}%
892 \_isinlist\nochapbooks{ #1 }\_iftrue
893 \_def\.ltextC{}\_let\.ltextCin=\.ltextnCin \_afterfi{\.brefVerse #2>}%
894 \_else \_afterfi{\.brefChapter #2>}\_fi}
895 \_def\.brefChapterVerse #1:#2>{\_def\.ltextC{#1:}\.brefVerse #2>}
896 \_def\.brefVerse #1>{%
897 \.isdivisin #1-\_iftrue \.brefFromTo #1>%
898 \_else \.versedef#1\_relax\_fi
899 }
900 \_def\.brefChapter #1>{%
901 \.isdivisin #1-\_iftrue \.brefFromTo #1>\_let\.ltextC=\.ltextV
902 \_else \_def\.ltextC{#1}\_fi
903 \_def\.ltextV{}\_def\.ltextS{}%
904 }
905 \_def\.brefFromTo #1-#2>{\.versedef#1\_relax\_def\.ltextF{--}\_def\.ltextN{#2}}
906
907 \_doc
908 Because the verse number can be in the format `11b`, we need to separate
909 the numeric part of this and save it to \^`\.ltextV` and the rest is saved
910 to \^`\.ltextS`. This is done by the \`\.versedef`` <verse>\relax` macro.
911 \_cod
912
913 \_def\.versedef {\_afterassignment\.versedefB \_tmpnum=0}
914 \_def\.versedefB #1\_relax{\_edef\.ltextV{\_the\_tmpnum}\_def\.ltextS{#1}}
915
916 \_doc
917 Now, we create \`\.linkfspec` from scanned data. It is <full-vref>
918 used for hyperlinks. We must manage all situations of incomplete links.
919 \_cod
920
921 \_def\.brefD{%
922 \_ifnum 0\.ltextV=0 \_def\.ltextV{}\_fi
923 \_if a\.linkpre \_ifx\.ltextV\_empty \_else \_edef\.ltextC{\.ltextV:}\_def\.ltextV{}\_fi\_fi
924 \_edef\.linkfspec{\_ea\.ltextBin\.ltextB~/\_ea\.ltextCin\.ltextC:/\_ea\.ltextVin\.ltextV:/}%
925 \.brefL
926 }
927 \_def\.ltextBin #1~#2/{\_ifx^#1^\.prelinkB \_else #1\_immediateassignment\_def\.prelinkB{#1}\_fi/}
928 \_def\.ltextCin #1:#2/{\_ifx^#1^\.prelinkC \_else #1\_immediateassignment\_def\.prelinkC{#1}\_fi:}
929 \_def\.ltextVin #1:#2/{\_ifx^#1^\.prelinkV \_else #1\_immediateassignment\_def\.prelinkV{#1}\_fi}
930 \_def\.ltextnCin #1:#2/{\.prelinkC:\_immediateassignment\_let\.ltextCin=\.ltextsCin}
931 \_let\.ltextsCin=\.ltextCin
932
933 \_doc
934 \`\.prelinkB` is <book-mark> of last referenced book.
935 \`\.prelinkC` is <chapter-num> of last referenced chapter.
936 They are used if the reference is not full. They are initialized at the
937 beginning of books and chapters and they are changed locally in the `\``Note` text.
938 If the \code{\\<} is used then they are re-initialized.
939 \_cod
940
941 \_def\<{\_let\.prelinkB=\.currbook \_let\.prelinkC=\.currchapnum \_let\.prelinkV=\.currversenum \.bref}
942
943 \_doc
944 Macro \`\.brefL` recalculates \^`\.linkfspec` and \^`\.linktext` due to \^`\renum` data
945 and creates the link `\.linkpre:\.linkfspec` with the text \^`\.linktext`.\nl
946 \`\.renumlinktext`` <full-vref-ori>\_relax<full-vref-modified>\_relax`
947 does re-calculation of the parts of the \^`\.linktext` macro.\nl
948 The \`\.linkfspecone` solves situation when chapter is given but no verse
949 number: we must set the verse number to 1.\nl
950 If the link destination is article, then the `<full-vref>` has reduced
951 format `<book>/<chapter>`. If the link destination is itroduction then
952 the `<full-vref>` has more reduced format: `<book>/`.\nl
953 If the book mark is declared by `\vdef` then the printed version of the book
954 mark is transformed depending on the current `\tmark`. This is done by
955 the the \`\.newlinkB` macro.\nl
956 \`\.linklog`` {<text>}` macro prints logging info of the link in the format
957 \begtt \catcode`<=13 \adef({\string<} \adef){\string>}
958 (<link-spec>) = [<full-vref>]{<printed-link>}
959 \endtt
960 \^`\.linklog` is `\wlog` by default and when `\tracinglinks` is set.
961 It is `\ignreit` when \^`\notracinglinks` is set.
962 You can set it to `\wterm` if you want.
963 \_cod
964
965 \_def\.brefL{%
966 \_edef\.linkfspecm{\_ea\.renumvref\.linkfspec\_relax}%
967 \_ifx\.linkfspec\.linkfspecm \_else
968 \_ea\_ea\_ea\.renumlinktext \_ea\.linkfspec \_ea\_relax \.linkfspecm \_relax
969 \_let\.linkfspec=\.linkfspecm
970 \_fi
971 \_ifx\.ltextV\_empty \_ifx\.ltextC\_empty \_else \_ea\.linkfspecone \.linkfspec\_end \_fi\_fi
972 \_if a\.linkpre\_relax \_ea\.linkfspecarticle \.linkfspec\_end \_fi
973 \_if i\.linkpre\_relax \_ea\.linkfspecintro \.linkfspec\_end \_fi
974 \_ifx \.ltextB\_empty \_else \_ea \.newltextB \.ltextB \_fi
975 % \message{\meaning\.linkfspec, \meaning\.ltextC, \meaning\.currchapnum}%
976 \.reducelinktext
977 \.linklog{\.sspace <\_unexpanded\_ea{\.linkspec}>\.linkpost = [\.linkpre:\.linkfspec]%
978 {\_ifx\.brefH\_empty \.ltextP \_else \.linktext\_fi}}%
979 \.ensuredest \.createlink
980 }
981 \_def\.linkfspecone #1:#2\_end {\_def\.linkfspec{#1:1}\_def\.prelinkV{1}}
982 \_def\.linkfspecarticle #1/#2:#3\_end {\_def\.linkfspec{#1/#2}}
983 \_def\.linkfspecintro #1/#2\_end {\_def\.linkfspec{#1/}}
984
985 \_def\.renumlinktext #1/#2:#3\_relax #4/#5:#6\_relax{%
986 \_ifx\.ltextC\_empty \_else \_def\.ltextC{#5:}\_fi
987 \_def\.ltextV{#6}%
988 \_ifx\.ltextN\_empty \_else
989 \_ifx\.ltextF\.ltextDD
990 \_isinlist\.ltextN{:}\_iftrue
991 \_ifcsname rn!\tmark!#1/\.ltextN\_endcsname \_edef\.ltextN{\_cs{rn!\tmark!#1/\.ltextN}}%
992 \_fi
993 \_else \_edef\.ltextN{\_the\_numexpr#6+\.ltextN-#3\_relax}\_fi
994 \_else \_let\.tmp=\_ignoreit % \.ltextN is a list of verses, for example 7,9,13
995 \_ea\_foreach\.ltextN,\_do ##1,{\_edef\.tmp{\.tmp,\_the\_numexpr#6+##1-#3}}%
996 \_let\.ltextN=\.tmp
997 \_fi
998 \_fi
999 }
1000 \_def\.ltextDD{--}
1001
1002 \_def\.newltextB #1~{\_edef\.ltextB{\_trycs{v!\tmark!#1}{#1}~}}
1003
1004 \_def\.sspace{\_space\_space\_space\_space}
1005 \_def\.linkpost{\_if v\.linkpre \_else \.linkpre\_fi \_space}
1006
1007 \_doc
1008 \`\.reducelinktext` does nothing or reduces printed link if its book is
1009 equal to the current book and if its chapter is equal to printed chapter.
1010 It is activated by \`\reduceref` and deactivated by \`\noreduceref`.
1011 The \`\re` macro activates `\.reducelinktext` only for single `\.bref`.
1012 \_cod
1013
1014 \_def\.reducelinktextA{%
1015 \_edef\.tmp{\.currbook~}%
1016 \_ifx\.ltextB\.tmp \_def\.ltextB{}%
1017 \_edef\.tmp{\_trycs{_opb_currchapnum}{?}:}%
1018 \_ifx\.ltextC\.tmp \_def\.ltextC{}%
1019 \_fi\_fi
1020 \_ifcsname _opb_reA\_endcsname \_let\.reducelinktext=\.reA \_fi % after \re
1021 }
1022 \_def\.reduceref{\_let\.reducelinktext=\_reducelinktextA}
1023 \_def\.noreduceref{\_let\.reducelinktext=\_relax}
1024 \.noreduceref % default
1025
1026 \_def\.re{\_let\.reA=\.reducelinktext \.reduceref}
1027
1028 \_nspublic \reduceref \noreduceref \re ;
1029
1030 \_doc
1031 \`\tracinglinks` and \`\notracinglinks` are defined here.
1032 \_cod
1033
1034 \_def\tracinglinks{\_let\.linklog=\_wlog}
1035 \_def\notracinglinks{\_let\.linklog=\_ignoreit}
1036 \tracinglinks
1037
1038 \_doc
1039 \`\.createlink` creates link only if it refers to the place of printed book
1040 because we don't want to see many warnings about unreferenced links when
1041 we try to print only selected books. It creates link
1042 `\.linkpre:\.linkfspec` with the text `\.linktext`\nl
1043 The link is created only if the book is to be printed, i.e. the
1044 `\pbook!<book>` is defined.\nl
1045 \`\tracingouterlinks` acivates logging of broken links to non-existed
1046 books. By default, these links are not logged because we assume that
1047 no whole Bible is processed but only selected books.
1048 \_cod
1049
1050 \_def\.createlink{{%
1051 \_ifx\.brefH\_empty \_let\.linktext=\.ltextP\_fi
1052 \_ea\.isprintedbook\.linkfspec \_iftrue
1053 \_link[\.linkpre:\.linkfspec]{\_ilinkcolor}{\.linktext}%
1054 \_else {\_ilinkcolor\.linktext}\_fi}%
1055 }
1056 \_def\.isprintedbook #1/#2\_iftrue{\_ifcsname pbook!#1\_endcsname}
1057 \_def\tracingouterlinks{\_def\.isprintedbook ##1\_iftrue{\_iftrue}}
1058
1059 \_doc
1060 We don't create destinations for all verses, notes etc. but only for
1061 those which are referenced.
1062 The macro \`\.ensuredest` is called from \^`\.createlink` and it saves immediatelly
1063 `\sdef{<link>:<full-vref>}{}`
1064 to the special file `\jobname.xrf`. And the macro \^`\pg` saves immediatelly
1065 `\sdef{pg:<link>:<full-vref>}{??}` to this file.
1066 This `.xrf` file is read before standard
1067 `.ref` file. All link destinations save `\.Xdest{<full-vref>}` to the
1068 `.ref` file. The macro \`\.Xdest` does nothing if `\pg:<link>:<full-vref>` is not
1069 defined (from `.xrf` file). Otherwise, it is defined as a correct pageno.
1070 This result is used in the \^`\pg` macro.
1071 If `\<link>:<full-vref>` is not defined, no link destination is crated.
1072 First \TeX/ run creates `.ref` and `.xrf` files and does not create any
1073 hyperlink destinations. Second \TeX/ run uses data from these files
1074 and creates correct hyperlinks and page numbers.
1075 \_cod
1076
1077 \_newwrite\.xrf
1078 \_immediate\_openout\.xrf=\_jobname.xrf
1079 \_openref
1080
1081 \_def\.ensuredest{\_immediate\_write\.xrf{\_string\_sdef{\.linkpre:\.linkfspec}{}}}
1082 \_refdecl{
1083 \_isfile{\_jobname.xrf}\_iftrue \_input{\_jobname.xrf}\_fi^^J
1084 \_def\.Xdest#1{\_ifcsname pg:#1\_endcsname \_sxdef{pg:#1}{\_ea\_usesecond\_currpage}\_fi}^^J
1085 \_def\.mypage{\_ea\_usesecond\_currpage}
1086 }
1087 \_def\.trymakedest#1{%
1088 \_ifcsname #1\_endcsname \_dest[#1]\_ea\_glet\_csname #1\_endcsname \_undefined \_fi
1089 \_ewref\.Xdest{{#1}}%
1090 }
1091
1092 \_doc
1093 The \`\pg` macro should be used after \code{<...>}, i.e. the \^`\.linkpre`
1094 and \^`\.linkfspec` are defined. We use them. And the page number is saved to
1095 the `\pg:<link>:<full-vref>` macro in the second \TeX/ run.
1096 \_cod
1097
1098 \_def\.pg{%
1099 \_ifcsname pg:\.linkpre:\.linkfspec\_endcsname
1100 {\_edef\.linktext{\_cs{pg:\.linkpre:\.linkfspec}}\_let\.brefH=\_relax \.createlink}%
1101 \_else {\Red ??}\_fi
1102 \_immediate\_write\.xrf{\_string\_sdef{pg:\.linkpre:\.linkfspec}{??}}%
1103 }
1104 \_nspublic \pg ;
1105
1106 \_doc
1107 `\cref` if simply `\ref` with `cref!` prefix.
1108 \_cod
1109
1110 \_def\.cref[#1]{\_ref[cref!#1]}
1111
1112 \_nspublic \cref ;
1113
1114
1115 \_doc
1116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1117 \sec Language variants
1118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1119 \`\variants`` <number-of-variants> {<tmark-A>} {<tmark-B>} {<tmark-C>} ...`\nl
1120 sets \`\.numvariants``=<number-of-variants>` and does `\def\tmarkA{<tmark-A>}`
1121 `\def\var!1{<tmarkA>}` `\def\var!2{<tmark-B>}` `\def\var!3{<tmark-C>}` etc.
1122 \_cod
1123
1124 \_newcount\.numvariants
1125 \_def\.variants{\_tmpnum=0 \_afterassignment\.variantsA \.numvariants}
1126 \_def\.variantsA{%
1127 \_ifnum\_tmpnum<\.numvariants
1128 \_advance\_tmpnum by1
1129 \_afterfi{\.variantsB{\_the\_tmpnum}}%
1130 \_fi
1131 }
1132 \_def\.variantsB#1#2{%
1133 \_ifnum#1=1 \_gdef\tmarkA{#2}\_sxdef{var!1}{#2}%
1134 \_else \_sxdef{var!#1}{#2}%
1135 \_fi
1136 \.variantsA
1137 }
1138 \_nspublic \variants ;
1139
1140 \_doc
1141 \`\vdef`` {<phrase-A>} {<phrase-B>} {<phrase-C>} ...` does\nl
1142 `\def\v!<tmark-B>!<phrase-A>{<phrase-B>}`
1143 `\def\v!<tmark-C>!<phrase-A>{<phrase-C>}` etc.
1144 Empty parameter is interpreted as undefined data.
1145 The internal macro \`\.vdefB` implements the error message if there is too few
1146 parameters of \^`\vdef` and we were read next \^`\vdef`.
1147 The \^`\.sedef` used in the \^`\.vdefB{<number>}{<param>}` does real work and
1148 it defines (rougly sepaking):
1149 \begtt \catcode`<=13
1150 If <param> is " \def \v!<tmark>!<phrase-A> {<previous param>}
1151 else \def \v!<tmark>!<phrase-A> {<param>}
1152 \endtt
1153 \_cod
1154
1155 \_def\.vdef#1{\_def\.tmp{#1}%
1156 \_ifcsname v!\_trycs{var!2}{}!\.tmp\_endcsname
1157 \.printwarn{\_noexpand\vdef used secondly for phrase {\.tmp}, ignored}\_fi
1158 \_tmpnum=1 \_ea\.vdefA
1159 }
1160 \_def\.vdefA{%
1161 \_ifnum\_tmpnum<\.numvariants
1162 \_advance\_tmpnum by1
1163 \_afterfi{\.vdefB{\_the\_tmpnum}}%
1164 \_fi
1165 }
1166 \_def\.vdefB#1#2{\_def\.tmpa{}%
1167 \_ifx\.vdef#2\_def\.tmpa{#2}\_fi
1168 \_ifx\.tmpa\_empty
1169 \_ifx^#2^\_else
1170 \_unless \_ifcsname v!\_cs{var!#1}!\.tmp\_endcsname
1171 \.sedef{v!\_cs{var!#1}!\.tmp}{\_ifx"#2\.prevcs{#1}\.tmp \_else#2\_fi}%
1172 \_fi\_fi
1173 \_ea\.vdefA
1174 \_else \_errmessage{\_string\vdef: too few parameters. To be read again: \_string#2}%
1175 \_ea\.tmpa
1176 \_fi
1177 }
1178 \_def\.prevcs #1#2{\_ifnum#1=2 #2\_else \_cs{v!\_cs{var!\_the\_numexpr#1-1\_relax}!#2}\_fi}
1179
1180 \_nspublic \vdef ;
1181
1182 \_doc
1183 \`\x``/<phrase>/` expands to \`\v!``<tmark>!<phrase>` if such control sequence
1184 is defined else it expands simply to `<phrase>` using \^`\xA`.
1185 The `<tmark>` is actual value of the `\tmark` macro.\nl
1186 Note that if `\tmark` expands to `<t-markA>` (used in the `\variants`
1187 macro), then the `\v!<tmark>!<phrase>` is not defined and the \^`\x` macro
1188 expands to the <phrase> directly.\nl
1189 \`\xA`` <phrase>/` expands to `<phrase>` and prints warning, if `\tmark`
1190 is not the first `<t-markA>`.
1191 \_cod
1192
1193 \_def\.x/#1/{\_trycs{v!\tmark!#1}{\.xA#1/}}
1194 \_def\.xA#1/{#1\_ifx\tmarkA\_undefined \_else \_ifx\tmark\tmarkA \_else
1195 \.printwarn{\_string\x/#1/ -- this phrase is undefined by \_csstring\\vdef}%
1196 \_fi\_fi
1197 }
1198 \_nspublic \x ;
1199
1200 \_doc
1201 \`\ww` `{<phrase-A>} {<phrase-B>} ...` has the same number of parameters as `\vdef`.
1202 They are separated by spaces. Each parameter can be in the \"single form",
1203 i.e.\ `{<phrase-A>}` or in the \"extended form", i.e.\ `{<phrase-A>}={<printed-A>}`.
1204 The macro searchs the correct phrase (given by the \^`\.varnum`) and saves
1205 it to the \`\.nextww`. The \^`\.nextwwA` is set to `\.nextww` if there is
1206 single form of the parameter else \`\.nextwwA` is <printed-A> part of
1207 the parameter in the extended form. These macros are used in the next
1208 \^`\Note` where they are re-set to `\undefined` meaning.
1209 \_cod
1210
1211 \_def\.ww{%
1212 \_ifx\.varnum\_undefined \.setvarnum \_fi
1213 \_tmpnum=0
1214 \_ifx\.nextww\_undefined \_ea\.wwA
1215 \_else \.printwarn{Only single \_csstring\\ww must be before \_csstring\\Note}%
1216 \_ea\.wwB \_fi
1217 }
1218 \_def\.wwA#1#2 {\_advance\_tmpnum by1
1219 \_isequal{"}{#1}\_iffalse
1220 \_def\.nextww{#1}\_def\.nextwwA{#2}%
1221 \_ifx\.nextwwA\_empty \_let\.nextwwA=\.nextww \_else \_ea \.redefwwA #2\_end \_fi
1222 \_fi
1223 \_ifnum\.varnum=\_tmpnum \_ifnum\_tmpnum<\.numvariants \_ea\_ea\_ea \.wwB \_fi
1224 \_else \_ea \.wwA \_fi
1225 }
1226 \_def\.wwB#1 {\_advance\_tmpnum by1
1227 \_ifnum\_tmpnum<\.numvariants \_ea\.wwB \_fi
1228 }
1229 \_def\.redefwwA =#1\_end{\_def\.nextwwA{#1}}
1230
1231 % \_outer\_def\ww{\.ww} % will be done at the end of this macro file
1232
1233 \_doc
1234 The \`\switch` macro reads a pair of parameters using \`\.switchA`
1235 and processes the list of variants in `\foreach` loop. If an element from
1236 the list is equal with `\tmark` then the `#2` (saved in
1237 \`\.switchD` token list) is run and next parameter pairs are read by
1238 \`\.switchN`, i.e. they are ignored.\nl
1239 The \^`\Note` and \^`\ww` and more macros are defined as `\outer` in order to
1240 better diagnose mistakes with their parameters.
1241 But we want to skip such objects in \^`\switch` parameters. This is the reason
1242 why we set `\_suppressoutererror=1` during the \^`\switch` is processed.
1243 \_cod
1244
1245 \_newtoks\.switchD
1246 \_def\.switch {\_let\.switchN=\.switchA \_suppressoutererror=1 \.switchN}
1247 \_long\_def\.switchA #1#2{\.switchD={#2\_let\.switchN=\.switchI}%
1248 \_ifx\_relax#1\_relax \_the\.switchD
1249 \_else \_foreach #1,\_do ##1,{\_def\tmp{##1}\.switchC}%
1250 \_fi
1251 \_futurelet\.next\.switchB
1252 }
1253 \_def\.switchB{\_ifx\.next\_bgroup \_ea\.switchN \_else \_suppressoutererror=0 \_fi}
1254 \_long\_def\.switchI #1#2{\_futurelet\.next\.switchB}
1255 \_def\.switchC{\_ifx\tmp\tmark \_the\.switchD \_fi}
1256
1257 \_nspublic \switch ;
1258
1259 \_doc
1260 \`\.setvarnum` sets the \`\.varnum` as the position number of the current
1261 language variant due to the value of `\tmark`. The \^`\variants`
1262 declaration must precede.
1263 \_cod
1264
1265 \_def\.setvarnum{\_gdef\.varnum{0}%
1266 \_ifnum\.numvariants=0 \_gdef\.varnum{1}\_wlog{There is only single language variant (1)}%
1267 \_else
1268 \_tmpnum=0
1269 \_loop
1270 \_advance\_tmpnum by1
1271 \_ea\_ifx \_csname var!\_the\_tmpnum\_endcsname \tmark \_xdef\.varnum{\_the\_tmpnum}\_fi
1272 \_ifnum\_tmpnum<\.numvariants \_repeat
1273 \_ifnum \.varnum=0 \_errmessage{\_noexpand\tmark isn't set, \_noexpand\.setvarnum failded}%
1274 \_else \_wlog{Language variant set by \_string\tmark{\tmark} (\.varnum)}\_fi
1275 \_fi
1276 }
1277
1278 \_doc
1279 \`\renum` `<book-mark> <chapter-num>:<verse-num> = <t-mark> <chap-num>:<from>-<to>`
1280 does
1281 \begtt
1282 \def \rn!<t-mark>!<full-vref>{<chap-num>:<from>}
1283 \def \rn!<t-mark>!<full-vref+1>{<chap-num>:<from+1>}
1284 \def \rn!<t-mark>!<full-vref+2>{<chap-num>:<from+2>}
1285 ... etc.
1286 \def \rn!<t-mark>!<full-vref+n>{<chap-num>:<to>}
1287 \endtt
1288 \_cod
1289
1290 \_def\.renum #1 #2:#3 = #4 #5:#6-#7 {%
1291 \_tmpnum=#3\_relax
1292 \_fornum #6..#7 \_do {\_sxdef{rn!#4!#1/#2:\_the\_tmpnum}{#5:##1}\_incr\_tmpnum}%
1293 }
1294 \_nspublic \renum ;
1295
1296 \_doc
1297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1298 \sec Inserting notes to the page
1299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1300 We declare new insert \`\.noteins` used in the `\output` routine.
1301 \_cod
1302
1303 \_newinsert \.noteins
1304 \_skip\.noteins=\_bigskipamount % noterule height
1305 \_count\.noteins=500 % two columns
1306 \_dimen\.noteins=\_maxdimen % full page of notes allowed
1307
1308 \_doc
1309 The \`\.noteinsert`` {<text>}` inserts its parameter to the \^`\.noteins`.
1310 We open the `\insert` and set basic parameters using \`\.noteset`.
1311 Then the empty box with strut height is inserted in vertical mode
1312 (in order to consecutive notes have good baselineskip between them).
1313 Then the `<text>` is printed and the paragraph is finalized.
1314 The empty box with strut depth is appended after the paragraph
1315 (in order to the same reason). Final `\penalty0` allows breaking between
1316 notes.
1317 \_cod
1318
1319 \_def\.noteinsert #1{\_insert\.noteins{%
1320 \.noteset
1321 \_vbox to\_ht\_strutbox{}\_nobreak \_vskip-\_baselineskip
1322 #1\_unskip\_par \_nobreak \_vskip-\_baselineskip
1323 \_hbox{\_lower\_dp\_strutbox\_vbox{}}
1324 \_penalty0
1325 }}
1326 \_def\.noteset{\Heros\cond \_scalemain \_typoscale[800/800] % Heros condensed 80%
1327 \Black \_nobreak
1328 \_widowpenalty=20 \_clubpenalty=20
1329 \_leftskip=0pt \_rightskip=0pt \_parfillskip=0pt plus1fill
1330 \_parindent=0pt
1331 \_lineskiplimit=-3pt
1332 \_hsize=.5\_hsize \_advance\_hsize by-1em\_relax % two columns
1333 \_everypar{}
1334 }
1335
1336 \_doc
1337 We add macros for inserting two columns of notes from \^`\.noteins` into the
1338 page. First, we add \`\noterule` with the space given by
1339 `\skip\.noteins`. The \^`\.noteins` material is prefixed by `\penalty0` (in
1340 order to allow the next `\vsplit` operation) and the `\vfil` is added (in order
1341 to the case when the second column is smaller than the first one).
1342 The `\splittopskip` is set and first `\vsplit to0pt` adds skip given by
1343 `\splittopskip` to the \^`\.noteins`. The `\_balancecolumns` from \OpTeX/
1344 for splitting to two columns is used. We need to set `\_Ncols`, `\_dimen0`
1345 and `\_box6` before running `\_balancecolumns`. We need to insert
1346 `\vskip\splittopskip` because `\_balancecolumns` supposes that the typesetting point
1347 resides at the first baseline of the columns.\nl
1348 The final `\vskip` does \"raggedbottom". We need to add `1filll` in order
1349 to suppress the `\vfill` from the `\end` algorithm. We add `minus6pt`
1350 because the height of two columns can be by half-line higher than the
1351 insertion algorithm excepts (in the case with odd lines before
1352 splitting to the two columns).
1353 \_cod
1354
1355 \_addto\_pagecontents{%
1356 \_ifvoid\.noteins \_else
1357 \_vskip\_skip\.noteins \noterule
1358 \_setbox\.noteins=\_vbox{\_penalty0 \_unvbox\.noteins \_vfil}
1359 \_splittopskip=12pt
1360 \_setbox0=\_vsplit\.noteins to0pt % adding \splittopskip to \.noteins
1361 \_def\_Ncols{2}
1362 \_dimen0=.5\_ht\.noteins \_setbox6=\_box\.noteins
1363 \_vskip\_splittopskip
1364 \_balancecolumns
1365 \_fi
1366 \_unless\_ifvoid\.botins \_unvbox\.botins
1367 \_else \_vskip 0pt plus1filll minus8pt \_fi
1368 }
1369 \_def \noterule {\_kern-3pt {\Black \_hrule width\_hsize}\_kern 2.6pt }
1370
1371 \_doc
1372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1373 \sec Inserting images and articles to the page
1374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1375 \`\.botins` is analogue insert as `\_topins` but the material is inserted
1376 to the bottom of the page. The material is created by
1377 \`\.botinsert``...`\`\.endbot` pair of control sequences.
1378 We use it for inserting images and articles to the page.
1379 \_cod
1380
1381 \_newinsert\.botins
1382 \_def\.botinsert{\_setbox0=\_vbox\_bgroup}
1383 \_def\.endbot{\_par\_egroup
1384 \_insert\.botins{\_splittopskip=0pt \_penalty100
1385 \_hrule height0pt \_nobreak\_medskip\_bigskip \_unvbox0
1386 }%
1387 }
1388 \_skip\.botins=\_zoskip % no space added when a topinsert is present
1389 \_count\.botins=1000 % magnification factor (1 to 1)
1390 \_dimen\.botins=\_maxdimen % no limit per page
1391
1392 \_doc
1393 \`\putImage` `<chatper>:<verse> {<title>} [<label>] (<params>) {<image-file>}`
1394 inserts the given image to the page where the begining of the verse given
1395 by <chapter>:<verse> exists. We register a new action by
1396 \^`\.newaction{<full-vref>}{\.doImage{<title>}[<label>](<params>){<image-file>}}`.
1397 The \`\.doImage` puts the image by \^`\.botinsert`...\^`\.endbot` pair.
1398 The \`\.botTitle``{<title>}[<label>]` prints the title of the image (or
1399 article or watever is put to the bottom of the page) and inserts the
1400 destination of hyperlink based on the <label>, if the <label> isn't empty.
1401 \_cod
1402
1403 \_def\.putImage #1 #2#3[#4]#5(#6)#7{% chap:verse {Title} [label] (params) {image-file.pdf}
1404 \_edef\.fullvref{\.gentovref{#1}}%
1405 \_edef\.fullvrefm{\_ea\.renumvref\.fullvref\_relax}%
1406 \_ea\.newaction\_ea{\.fullvrefm}{\.doImage{#2}[#4](#6){#7}}%
1407 }
1408 \_def\.doImage #1[#2](#3)#4{% {Title}[label](params){image-file.pdf}
1409 \.botinsert
1410 \.botTitle{#1}[#2]%
1411 \_kern3pt \_nobreak
1412 \_hbox{\picw=\hsize #3\inspic{#4}}%
1413 \.endbot
1414 }
1415 \_def\.botTitle#1[#2]{\_hbox{\.captionfont
1416 \_ifx^#2^\_else \.botDest{#1}[#2]\_fi
1417 \_rlap{\Grey \_vrule height1.2em depth.5em width\_hsize}\White\_kern12pt #1}%
1418 }
1419 \_picdir={images/}
1420 \_def\.botDest#1[#2]{\_label[#2]\_wlabel{#1}}
1421
1422 \_nspublic \putImage ;
1423
1424 \_doc
1425 \`\putArticle` `<chapter>:<verse> {<title>} [<label>] (<params>)`
1426 inserts an article (an additional text) given in the file `articles-*.tex` signed by
1427 \`\Article`` [<label>]`. The article starts at the page where
1428 <chapter>:<verse> is or at the next page. The article is in two-columns
1429 style and it is divided to $k$ two-columns parts each of them is inserted
1430 at the bottom of the next page.
1431
1432 We calculate the number of pages used for article text by following rules.
1433 All the two-columns parts have the same height. If there are more than one such
1434 a part, the height does not exceeds 2/3 of the page. But single two-column part
1435 can be higher.
1436
1437 \^`\putArticle` registers \^`\.doArticle` using \^`\.newaction`.
1438 \^`\.doArticle` is run at the beginning of given verse and creates an
1439 \^`\.botinsert`. The insert material is breakable at its beginig and between
1440 each two-column boxes created by the `\_balancecolumn` macro.
1441
1442 We register a new action by
1443 `\.newaction{<full-vref>}{\.doArticle{<title>}[<label>](<params>)}`.
1444 \_cod
1445
1446 \_newcount\.articlenum
1447 \_def\.putArticle #1 #2#3[#4]#5(#6){% chap:verse {Title} [number] (params)
1448 \_edef\.fullvref{\.gentovref{#1}}%
1449 \_edef\.fullvrefm{\_ea\.renumvref\.fullvref\_relax}%
1450 \_ea\.newaction\_ea{\.fullvrefm}{\.doArticle{#2}[#4](#6)}%
1451 }
1452 \_nspublic \putArticle ;
1453
1454 \_doc
1455 The \`\.doArticle` `{<Title>}[<label>](<params>)` inserts the article to one
1456 or more pages by the pair \^`\.botinsert`...\^`\.endbot`.
1457 The Article is printed to two columns per
1458 page, all collumns of the article is completely balanced.
1459 First, the whole text is saved to the `\box0`
1460 with given column size and the number of pages is calculated in `\_tmpnum`.
1461 Then the number of columns `\_Ncols` is 2 times the number of calculated pages.
1462 The height of each two-columns part of the article is `\dimen0`.
1463 Finally we do re-boxing the output of `\_balancecolumns` in order to
1464 reach individual columns and create pairs of them by `\fornum` loop.
1465 These pairs are completed to blocks with LightGrey background.
1466 These blocks divided by `\break` are inserted into \^`\.botinsert`.
1467 \_cod
1468
1469 \_def\.doArticle#1[#2](#3){% {Title}[number](params)
1470 \_incr\.articlenum
1471 \.botinsert
1472 \_def\.botDest##1[##2]{\.trymakedest{a:\.currbook/##2}}
1473 \_parindent=12pt \_iindent=\_parindent
1474 \_setbox0=\_vbox{\_hsize=.458\_hsize \_emergencystretch=1em
1475 \_hbadness=6000 \_baselineskip=\_dimexpr\_baselineskip plus1pt
1476 \_def\Article[##1]{\_endinput}
1477 \_penalty0
1478 \_long\_def\.searcharticle##1\Article[#2]{}
1479 \_ea\.searcharticle \_input \articlefile \_relax}
1480 \_splittopskip=12pt
1481 \_setbox1=\_vsplit0 to0pt % adding \splittopskip
1482 \_tmpdim=\_vsize \_advance\_tmpdim by-24pt % \.botTitle height plus above/below skips
1483 \_ifdim 2\_tmpdim > \_ht0 \_tmpnum=1
1484 \_else
1485 \_tmpnum=\.roundexpr{\_bp{\_ht0}/\_bp{1.333\_vsize}+0.999} % number of 2/3 pages
1486 \_fi
1487 \_multiply\_tmpnum by2 % number of columns
1488 \_edef\_Ncols{\_the\_tmpnum}
1489 \_dimen0=\_expr{1/\_Ncols}\_ht0 \_setbox6=\_box0 % height of each two-columns part
1490 \_setbox0=\_vbox{\_balancecolumns}
1491 \_tmpdim=\_ht0 \_advance\_tmpdim by1.2\_baselineskip
1492 \_setbox0=\_vbox{\_unvbox0 \_global\_setbox2=\_lastbox}
1493 \_setbox0=\_hbox{\_unhbox2
1494 \_fornum 1..\_Ncols \_do {\_unskip \_global\_setbox1##1=\_lastbox}}
1495 \_fornumstep -2: \_Ncols..1 \_do {
1496 \_hrule height0pt\_kern5pt\_nobreak\_vfill
1497 \_ifnum\_Ncols=##1 \.botTitle{#1}[#2]\_else \.botTitle{}[]\_fi
1498 \_kern3pt \_nobreak
1499 \_hbox to\_hsize{%
1500 \_rlap{\LightGrey \_vrule height\_tmpdim depth6pt width\_hsize}%
1501 \_kern\_parindent
1502 \_box1##1\_hss\_box1\_the\_numexpr##1-1
1503 \_kern\_parindent
1504 }
1505 \_break
1506 }
1507 \.endbot
1508 }
1509 \_def\.roundexpr#1{\_ea\.roundexprA\_expanded{\_expr{#1}}\_relax}
1510 \_def\.roundexprA#1.#2\_relax{\_ifnum#1=0 0\_else #1\_fi}
1511
1512 \_doc
1513 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1514 \sec Inserting images over two pages
1515 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1516 We can insert an image at the bottom of the page which spans from even to
1517 odd page. The macro
1518 \`\insertSpanImage``{<Title>} [<label>] (<params>) {<image file>}` does it.
1519 The image is placed at the bottom of the pages using following rule:
1520 if the `\insertSpanImage` occurrs at the current page $c$ then
1521 \begitems
1522 * if $c$ is even and the image height fits to the current page then the
1523 image is inserted to pages $c$, $c+1$,
1524 * if $c$ is even and the image height doesn't fit to the current page then
1525 the image is inserted to pages $c+2$, $c+3$,
1526 * if $c$ is odd then the image is inserted to pages $c+1$, $c+2$.
1527 \enditems
1528 The macro `\insertSpanImage` saves the image in the box `\.spanpicbox`.
1529 The `\_picwidth` of the image is calculated as 2*(`\_hsize`*<inner_margin>).
1530 I.e. when we put the box to the page firstly
1531 then only the left half of its size is printed.
1532
1533 Next, \^`\insertSpanImage` checks if the current page is even. If it is true and
1534 if there is sufficient space `\pagegoal-\pagetotal` at the current page, the
1535 image is inserted to the current page using the `\.startinsertSpanImage`
1536 which runs `\.insertBot` in fact. The second part of the image is printed
1537 because `\_endoutput` (processed at the end of the output routine where
1538 first part of the image is inserted) runs `\.addpicbox`. The
1539 `\.addpicbox` runs second `\.insertBot` which is printed on the next
1540 page.
1541
1542 If the current page is odd, then `\insertSpanImage` doesn't run `\.startinsertSpanImage`
1543 immediatelly, but `\_endouput` inserts first part of the image using
1544 `\.inspicbox` which is equal to `\.inspicboxafter` in this case. It
1545 processes `\.startinsertSpanImage` which inserts the first part of the
1546 image on the next page (even) page.
1547
1548 If the current page is even but the image cannot fit to the current page
1549 then the delay using `\_endoutput` is activated too. But the
1550 `\.ispicboxafter` checks that the current page is even and it does nothing in
1551 this case. Next page is ofdd, so `\.ispicboxafter` invoked by next
1552 `\_endinput` inserts the first part of the image which will be printed on
1553 the next (even) page.
1554 \_cod
1555
1556 \_newbox \.spanpicbox
1557
1558 \_def\.insertSpanImage #1#2[#3]#4(#5)#6{%
1559 \.checkpicbox
1560 \_par \_penalty0
1561 \_tmpdim=\_pagewidth
1562 \_advance\_tmpdim by-\_hoffset
1563 \_global\_setbox\.spanpicbox=\_hbox{\_picwidth=2\_tmpdim \_inspic{#6}}
1564 \_gdef\.startinsertSpanImage {\.insertBot {#1}[#3](#5){\_copy\.spanpicbox \_kern-1.2ex}}
1565 \.doinsertSpanImage
1566 }
1567 \_def\.doinsertSpanImage{%
1568 \_ifodd\_pageno
1569 \_glet\.inspicbox=\.inspicboxafter
1570 \_else
1571 \_ifdim \_dimexpr \_pagegoal-\_pagetotal > \_dimexpr \_ht\.spanpicbox+2em \_relax
1572 \.startinsertSpanImage
1573 \_else
1574 \_glet\.inspicbox=\.inspicboxafter
1575 \_fi
1576 \_fi
1577 }
1578 \_let\.inspicbox=\_useit
1579 \_def\.inspicboxafter #1{%
1580 \_ifodd\_pageno
1581 \.startinsertSpanImage
1582 \_glet\.inspicbox=\_useit
1583 \_fi
1584 }
1585 \_def \_endoutput{%
1586 \_ifvoid\.spanpicbox\_else \.addpicbox\_fi
1587 \_advancepageno
1588 {\_globaldefs=1 \_the\_nextpages \_nextpages={}}%
1589 \_ifnum\_outputpenalty>-20000 \_else\_dosupereject\_fi
1590 }
1591 \_def\.addpicbox{\.inspicbox{\.insertBot{}[](){\_moveleft\_pagewidth\_box\.spanpicbox\_kern-1.2ex}}}
1592
1593 \_def\.checkpicbox{%
1594 \_ifvoid\.spanpicbox\_else \_errmessage{Two span Image/Text at single place not allowed}\_fi
1595 }
1596
1597 \_doc
1598 \`\insertSpanText``{<Title>} [<label>] (<params>) {<text>}` does the same
1599 as `\insertSpanImage`, but the <text> is inserted instead
1600 the image. The `\hsize` is locally set to the desired width of the text
1601 when `<text>` is processed in a `\vbox`,
1602 i.e. to 2*(`\hsize`+`<inner_margin>`).
1603 \_cod
1604
1605 \_long\_def\.insertSpanText #1#2[#3]#4(#5)#6{%
1606 \.checkpicbox
1607 \_par \_penalty0
1608 \_tmpdim=\_pagewidth
1609 \_advance\_tmpdim by-\_hoffset
1610 \_setbox0=\_hbox to2\_tmpdim{\_hss\_vbox{\_hsize=2\_tmpdim
1611 \_leftskip=0pt \_rightskip=0pt \_relax \_kern3pt #6}\_hss}
1612 \_global\_setbox\.spanpicbox=
1613 \_hbox{\_rlap{\White \_vrule width\_wd0 height\_ht0 depth\_dp0}\_box0}
1614 \_global\_ht\.spanpicbox=\_dimexpr\_ht\.spanpicbox-3pt\_relax
1615 \_gdef\.startinsertSpanImage {\.insertBot {#1}[#3](#5){\_copy\.spanpicbox \_kern-1.2ex}}
1616 \.doinsertSpanImage
1617 }
1618 \_nspublic \insertSpanImage \insertSpanText ;
1619
1620 \_doc
1621 \`\putSpanImage` `<chatper>:<verse> {<title>} [<label>] (<params>) {<img-file>}`
1622 runs \^`\insertSpanImage` at the page where the begining of the verse given
1623 by <chapter>:<verse> exists. We register a new action by
1624 \^`\.newaction{<full-vref>}{\.doSpanImage{<title>}[<label>](<params>){<img-file>}}`.\nl
1625 \`\putSpanText` `<chatper>:<verse> {<title>} [<label>] (<params>) {<text>}` \
1626 runs \^`\insertSpanText` at the page where the begining of the verse given
1627 by <chapter>:<verse> exists. The `<text>` is saved to `\spant!\the\.spantxtnum`
1628 and only the name of this macro is registered by the `\.newaction`.
1629
1630 Note that the image/text itself is inserted at the current page $c$ and
1631 $c+1$ or at $c+1$, $c+2$ or at $c+2$, $c+3$.
1632 \_cod
1633
1634 \_newcount\.spantextnum
1635 \_def\.putSpanImage #1 #2#3[#4]#5(#6)#7{% chap:verse {Title} [label] (params) {image-file.pdf}
1636 \_edef\.fullvref{\.gentovref{#1}}%
1637 \_edef\.fullvrefm{\_ea\.renumvref\.fullvref\_relax}%
1638 \_ea\.newaction\_ea{\.fullvrefm}{\.insertSpanImage{#2}[#4](#6){#7}}%
1639 }
1640 \_long\_def\.putSpanText #1 #2#3[#4]#5(#6)#7{% chap:verse {Title} [label] (params) {image-file.pdf}
1641 \_edef\.fullvref{\.gentovref{#1}}%
1642 \_edef\.fullvrefm{\_ea\.renumvref\.fullvref\_relax}%
1643 \_incr\.spantextnum
1644 \_global\_sdef{spant!\_the\.spantextnum}{#7}%
1645 \_ea\.putSpanTextA
1646 \_expanded{{\.fullvrefm}\_ea}\_csname spant!\_the\.spantextnum\_endcsname {#2}[#4](#6)%
1647 }
1648 \_def\.putSpanTextA #1#2#3[#4](#5){\.newaction{#1}{\.insertSpanText{#3}[#4](#5){#2}}}
1649
1650 \_nspublic \putSpanImage \putSpanText ;
1651
1652
1653 \_doc
1654 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1655 \sec Inserting citations to the page
1656 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1657 `\putCite` `<gen-vref> {<text>}` creates a citation <text> inserted to the
1658 top of the page where the verse <gen-vref> is. We regiter a new action by
1659 `\.newaction{<full-vref>}{\dotopCite{<text>}}`.
1660 \_cod
1661
1662 \_def\.putCite #1 #2{% chap:verse {text}
1663 \_edef\.fullvref{\.gentovref{#1}}%
1664 \_edef\.fullvrefm{\_ea\.renumvref\.fullvref\_relax}%
1665 \_ea\.newaction\_ea{\.fullvrefm}{\.dotopCite{#2}}%
1666 }
1667 \_nspublic \putCite ;
1668
1669 \_doc
1670 \`\.dotopCite` `{<text>}` creates the citation text by
1671 `\topinsert`...`\endinsert` from plain
1672 TeX. We distinguish two cases: the citation on a left page and the citation
1673 on a right page. We sawe the page position using `\_ewref` to the .ref
1674 file as `\sxdef{ct!<citenum>}{\.mypage}` and we know the page position in
1675 the second TeX run and use it in the `\ifodd` condition.
1676 The typesetting parameters differ in \"left" and \"right" case.
1677 \_cod
1678
1679 \_newcount\.citenum
1680 \_def\.dotopCite #1{%
1681 \.topinsertnopar
1682 \_typosize[12/16]\_bi
1683 \_incr\.citenum
1684 \_ifodd \_trycs{ct!\_the\.citenum}{0}\_relax
1685 \_leftskip=.3\_hsize plus1fil \_parfillskip=0pt
1686 \_noindent
1687 \_rlap{\_hskip\_hsize \_kern-\_leftskip \_copy\.rqqbox}\_hfill
1688 \_else
1689 \_let\quotedby=\.quotedbyright
1690 \_rightskip=.3\_hsize plus 1fil
1691 \_noindent \_llap{\_copy\.lqqbox}%
1692 \_fi
1693 {\.printCite{#1}\_unskip}\_par
1694 \_ewref\_sxdef{{ct!\_the\.citenum}{\_string\.mypage}}%
1695 % \vskip-.3\baselineskip
1696 \_endinsert
1697 }
1698 \_def\.printCite#1{\_pdfliteral{2 Tr .15 w .9 g}#1\_pdfliteral{0 Tr 0 w 0 g}}
1699 \_def\.printCite#1{{\Grey#1}}
1700
1701 \_def\.topinsertnopar{\_umidfalse \_upagefalse \_begingroup\_setbox0=\_vbox\_bgroup\_resetattrs}
1702
1703 \_doc
1704 The \`\.lqqbox` and \`\.rqqbox` include the graphical marks for quotations. First
1705 one is used at the left pages, second one at the right pages.\nl
1706 The macro `\quotedby{<author>}` puts the author of the quatation to the
1707 next line. The macro `\qutedbyright` (which is used at left pages) prints
1708 the <author> at the last line if there is sufficient space.
1709 \_cod
1710
1711 \_newbox\.lqqbox
1712 \_newbox\.rqqbox
1713 \_setbox\.lqqbox=\_hbox{\_lower3pt\_hbox{\_setfontsize{at70pt}\_bf\LiRed„}}
1714 \_setbox\.rqqbox=\_hbox{\_kern2pt\_lower38pt\_hbox{\_setfontsize{at70pt}\_bf\LiRed“}}
1715 \_ht\.lqqbox=0pt \_dp\.lqqbox=0pt
1716 \_ht\.rqqbox=0pt \_dp\.rqqbox=0pt
1717 \_addto\enquotes{\_setbox0=\_box\.lqqbox \_setbox\.lqqbox=\_box\.rqqbox \_setbox\.rqqbox=\_box0 }
1718
1719 \_def\quotedby{\_par}
1720 \_def\.quotedbyright#1{%
1721 \_unskip\_nobreak\_hfill\_penalty0\_hskip2em
1722 \_null\_nobreak\_hskip\_iindent\_hbox{#1}}
1723
1724 \_doc
1725 The following macros \`\Cite`, \`\insertCite` and \`\swapCites` are used for
1726 insertion of citations to the two-cloumn printed articles.
1727 The \^`\Cite` `<label>{<text>}` simply saves the <text> to the macro
1728 `\c!<article-num>!<label>`.
1729 The \^`\insertCite` `<label><feft-or-right>` inserts the citation declared
1730 by \^`\Cite` `<label>` to the text using `\vadjust`. The variant `\left` and
1731 `\right` is processed or ignored. This depends on the parity of the
1732 current page, which is restored from `.ref` file and saved to the macro
1733 `\cp!<article-num>!<label>`.
1734 \_cod
1735
1736 \_def\.Cite #1#2{\_sdef{c!\_the\.articlenum!#1}{#2}}
1737 \_def\.insertCite #1#2{\_def\.citelabel{#1}%
1738 \_ifx\_left#2\.insertCiteleft
1739 \_else \_ifx#2\_right\.insertCiteright\_else
1740 \_errmessage{\_noexpand\insertCite#1: \_noexpand\left or \_noexpand\right expected}%
1741 \_fi\_fi
1742 }
1743 \_def\.insertCiteleft {%
1744 \_ifnum\.citepg=1
1745 \.printwarn{\_noexpand\.insertCite\.citelabel: \_noexpand\.swapCites activated}\_fi
1746 \_ifodd \_numexpr\_trycs{cp!\_the\.articlenum!\.citelabel}{0}+\.citepg\_relax
1747 \_else \.insertCitelr \_left \_fi
1748 }
1749 \_def\.insertCiteright{%
1750 \_ifodd \_numexpr\_trycs{cp!\_the\.articlenum!\.citelabel}{0}+\.citepg\_relax
1751 \.insertCitelr \_right \_fi
1752 }
1753 \_def\.insertCitelr#1{\_unskip\_vadjust{\_vbox{%
1754 \_ewref\_sxdef{{cp!\_the\.articlenum!\.citelabel}{\_string\.mypage}}%
1755 \_vskip6pt
1756 \_advance\_hsize by\_parindent
1757 \_typosize[12/16]\_bi\Grey
1758 \_ifx#1\_left
1759 \_def\quotedby{\_par\_hfill}
1760 \_rightskip=\_parindent plus1fil \_leftskip=0pt
1761 \_setbox0\_vbox{%
1762 \_medskip \_noindent
1763 \_llap{\_copy\.lqqbox}\_ignorespaces
1764 \.printCite{\_cs{c!\_the\.articlenum!\.citelabel}}\_medskip}%
1765 \_hbox{\_kern-\_parindent\_rlap{\White
1766 \_vrule height\_ht0 width\_hsize}\_box0}%
1767 \_else
1768 \_leftskip=\_parindent plus1fil
1769 \_parfillskip=0pt
1770 \_setbox0\_vbox{%
1771 \_medskip \_noindent
1772 \_rlap{\_hskip\_hsize\_kern-\_parindent\_copy\.rqqbox}\_hfill
1773 \_ignorespaces \.printCite{\_cs{c!\_the\.articlenum!\.citelabel}}\_medskip}%
1774 \_rlap{\_rlap{\White \_vrule height\_ht0 width\_hsize}\_box0}%
1775 \_fi
1776 \_vskip6pt
1777 }}}
1778 \_def\.swapCites{\_def\.citepg{1}}
1779 \_def\.citepg{0}
1780
1781 \_nspublic \Cite \insertCite ;
1782
1783 \_doc
1784 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1785 Insertions into the intro text
1786 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1787 \_cod
1788
1789 %% TBN page 236
1790
1791 \_newcount\.shapenum
1792 \_newdimen\.ii \_newdimen\.w
1793 \_def\.oblom #1 od #2 odsadit #3 {\_par \.ii=#1 \.w=\_hsize
1794 \_ifdim\.ii>\_zo \_advance\.w by-\.ii
1795 \_else \_advance\.w by\.ii \.ii=\_zo \_fi
1796 \.shapenum=1 \_tmpnum=0 \_def\.shapelist{}
1797 \_loop \_ifnum\.shapenum<#2 \_edef\.shapelist{\.shapelist\_zo\_hsize}%
1798 \_advance\.shapenum by1 \_repeat
1799 \_loop \_edef\.shapelist{\.shapelist\.ii\.w}%
1800 \_advance\_tmpnum by1 \_ifnum\_tmpnum<#3 \_repeat
1801 \_advance\.shapenum by#3 \_edef\.shapelist{\.shapelist\_zo\_hsize}
1802 \.doshape}
1803 \_def\.doshape{\_parshape \.shapenum \.shapelist}
1804 \_newcount\.globpar
1805 \_ifx\_partokenset \_undefined \_def\.partoken{\par} \_else \_def\.partoken{\_par} \_fi
1806 \_def\.doshape{\_global\.globpar=0 \_ea\_def\.partoken{\_ifhmode\.shapepar\_fi}}
1807 \_def\.shapepar{\_prevgraf=\.globpar \_parshape\.shapenum\.shapelist
1808 \_endgraf \_global\.globpar=\_prevgraf
1809 \_ifnum \_prevgraf>\.shapenum \_ea\_let\.partoken=\_endgraf \_fi
1810 }
1811
1812 \_def\.Citehereleft #1 (#2) #3{{
1813 \_par
1814 \_def\quotedby{\_par\_hfill}
1815 \_rightskip=\_parindent plus1fil \_leftskip=0pt
1816 \_setbox0\_vbox{{%
1817 \_typosize[12/16]\_bi\Grey
1818 \_hsize=.5\_hsize
1819 \_medskip \_noindent
1820 \_llap{\_copy\.lqqbox}\_ignorespaces
1821 \.printCite{#3}\_medskip}}%
1822 \_tmpdim=\_ht0 \_advance\_tmpdim by\_baselineskip
1823 \_xdef\.lines{\_the\_numexpr \_number\_tmpdim / \_number\_baselineskip \_relax}%
1824 \_nointerlineskip\_vbox to0pt{\_kern#1\_baselineskip #2
1825 \_hbox{\_rlap{\White
1826 \_kern-3mm\_vrule height\_ht0 width.5\_hsize}\_box0}%
1827 \_vss}}
1828 \_tmpdim=\_hsize \_advance\_tmpdim by-2\_leftskip
1829 \.oblom {.5\_tmpdim} od #1 odsadit {\.lines}
1830 }
1831 \_def\.Citehereright #1 (#2) #3{{
1832 \_par
1833 \_def\quotedby{\_par\_parfillskip=0pt \_hfill}
1834 \_leftskip=\_parindent plus1fill \_rightskip=0pt
1835 \_setbox0\_vbox{{%
1836 \_typosize[12/16]\_bi\Grey
1837 \_hsize=.5\_hsize
1838 \_vskip\_medskipamount \_rlap{\_kern\_hsize\_copy\.rqqbox}\_vskip-\_medskipamount
1839 \.printCite{\_noindent\_ignorespaces#3}\_medskip}}%
1840 \_tmpdim=\_ht0 \_advance\_tmpdim by\_baselineskip
1841 \_xdef\.lines{\_the\_numexpr \_number\_tmpdim / \_number\_baselineskip \_relax}%
1842 \_nointerlineskip\_vbox to0pt{\_kern#1\_baselineskip #2
1843 \_hbox to\_hsize{\_hss
1844 \_llap{\White \_vrule height\_ht0 width.5\_hsize \_kern-3mm}%
1845 \_llap{\_box0}}
1846 \_vss}}
1847 \_tmpdim=\_hsize \_advance\_tmpdim by-2\_leftskip
1848 \.oblom {-.5\_tmpdim} od #1 odsadit {\.lines}
1849 }
1850
1851 \_def\.Citehere{\_par \_ifodd\_pageno \_ea\.Citehereright \_else \_ea\.Citehereleft \_fi}
1852
1853 \_nspublic \Citehere ;
1854
1855 \_doc
1856 \`\insertBot` `{<title>} [<label>] (<params>) {<data>}`
1857 inserts a material from `<data>` to the bottom of the current page
1858 or next page if it is unable to fit to the current one.
1859 The material is titled by `<title>` and it can be referred by `<label>`.
1860 The `<params>` can inclue a special setting used locally for the priting
1861 of this material.
1862
1863 \noindent \`\putBot` `<chapter>:<verse> {<title>} [<label>] (<params>) {<data>}`
1864 behaves like `\insertBot`, but the result is printed to the bottom of the
1865 page where the verse `<chapter>:<verse>` is, or to the next page if the
1866 material is unable to fit to the current one.
1867 \_cod
1868
1869 \_def\.insertBot #1#2[#3]#4(#5)#6{% {Title} [label] (params) {data}
1870 \.botinsert
1871 \_leftskip=0pt \_rightskip=0pt \_relax
1872 \.botTitle{#1}[#3]%
1873 \_kern3pt \_nobreak
1874 \_vbox{\_picwidth=\_hsize #5 #6}%
1875 \.endbot
1876 }
1877 \_def\.putBot #1 #2#3[#4]#5(#6)#7{% chap:verse {Title} [label] (params) {image-file.pdf}
1878 \_edef\.fullvref{\.gentovref{#1}}%
1879 \_edef\.fullvrefm{\_ea\.renumvref\.fullvref\_relax}%
1880 \_ea\.newaction\_ea{\.fullvrefm}{\.insertBot{#2}[#4](#6){#7}}%
1881 }
1882 \_nspublic \insertBot \putBot ;
1883
1884 \_doc
1885 \`\.printintro` macro (by default) prints the itroduction of th book from
1886 the \^`\introfile`, prints the title "Introduction" (depending on the
1887 current language and puts all introduction text between \^`\.begblock`
1888 and \^`\.endblock`.
1889 \_cod
1890
1891 \_def\.printintro{%
1892 \.begblock
1893 \_dest[i:\.currbook/]
1894 \.chaptit{\_mtext{intro}}%
1895 \_input{\introfile}
1896 \.endblock
1897 }
1898
1899 \_doc
1900 Text block with grey background splittable to more pages is between
1901 \`\.begblock` and \`\.endblock` macros. It is used for
1902 introduction text. See also OpTeX trick 0031.
1903 \_cod
1904
1905 \_newcount\.blocklevel % nesting level of blocks
1906 \_def\.begblock{\_par\_bgroup
1907 \_advance\.blocklevel by1 \_advance\_leftskip by\_iindent \_rightskip=\_leftskip
1908 \_medskip
1909 \_pdfsavepos \_ea\_wref\_ea\.Xblock\_ea{\_ea{\_the\.blocklevel}B{\_the\_pdflastypos}}
1910 \_nobreak \_medskip
1911 }
1912 \_def\.endblock{\_par\_nobreak\_medskip
1913 \_pdfsavepos \_ea\_wref\_ea\.Xblock\_ea{\_ea{\_the\.blocklevel}E{\_the\_pdflastypos}}
1914 \_medskip \_egroup
1915 }
1916 \_refdecl{%
1917 \_def\.Xblock#1#2#3{\_ifnum#1=1 \_edef\.tmp{frm:\_ea\_ignoresecond\_currpage}^^J
1918 \_unless\_ifcsname \.tmp \_endcsname \_sxdef{\.tmp}{}\_fi^^J
1919 \_sxdef{\.tmp}{\_cs{\.tmp}#2{#3}}\_fi}
1920 }
1921 \_newdimen\.frtop \_newdimen\.frbottom % positions of top and bottom text on the pages
1922 \_def\.frcolor{.93 g } % light grey -- color of blocks.
1923 \_pgbackground={%
1924 \_slet{_opb_tmp}{frm:\_the\_gpageno}
1925 \_ifx\.tmp\_undefined \_def\.tmp{}\_fi
1926 \.frtop=\_dimexpr \_pdfpageheight-\_voffset+\_smallskipamount\_relax
1927 \.frbottom=\_dimexpr\_pdfpageheight-\_voffset-\_vsize-\_medskipamount\_relax
1928 \_ifx\.frnext y \_edef\.tmp{B{\_number\.frtop}\.tmp}\_global\_let\.frnext n\_fi
1929 \_ea\.printframes \.tmp B{0}E{\_number\.frbottom}
1930 \_ifx\.frameslist\_empty \_else
1931 \_pdfliteral{q \.frcolor 1 0 0 1 0 \_bp{-\_pdfpageheight} cm \.frameslist Q}\_fi
1932 }
1933 \_def\.printframes B#1#2E#3{\_ifnum#1=0 \_else
1934 \.printframe {\_hoffset}{#3sp}{\_xhsize}{\_ifnum#1=-1 \_number\.frtop\_else#1\_fi sp-#3sp}
1935 \_ifx^#2^\_else \_global\_let\.frnext=y \_let\.printframes=\_relax \_fi
1936 \_ea\.printframes\_fi
1937 }
1938 \_def\.frameslist{}
1939 \_def\.printframe #1#2#3#4{\_edef\.frameslist{\.frameslist
1940 \_bp{#1} \_bp{#2} \_bp{#3} \_bp{#4} re f }%
1941 }
1942
1943 \_doc
1944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1945 Insertions objects over pictures (maps)
1946 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1947 \_cod
1948
1949 \_doc
1950 \`\putstext``<x-pos> <y-pos> {<text>}`
1951 behaves like `\puttext` from \OpTeX, but moreover, it inserts a
1952 \"white shadow" as a background of the text. It can be used as text
1953 printed over a pictures (maps etc.).\nl
1954 \`\shadowedtext``{text}` creates an `\hbox{<text>}` with \"white shadow"
1955 as background.\nl
1956 \`\shadowparameter` is a number of \"transparency amount" used
1957 for \"white shadows". User can re-define it but it must be done before
1958 first usage of `\putstext` or `\shadowedtext` and it is used for whole
1959 document.
1960 \_cod
1961
1962 \_def\.putstext{\_ea\_ea\_ea\.putstextA\_scantwodimens}
1963 \_def\.putstextA#1#2#3{%
1964 \_setbox0=\_hbox{\.shadowedtext{#3}}%
1965 \_dimen1=#1sp \_dimen2=#2sp \_puttextB
1966 }
1967 \_def\.shadowedtext#1{%
1968 \.insertwhiteshadowresources
1969 \_setbox0=\_hbox{#1}%
1970 \_hbox{\_tmpdim=\_ht0 \_advance\_tmpdim by\_dp0
1971 \_lower\_dp0\_hbox{%
1972 \_pdfliteral{q /trans gs 1 g
1973 \_fornum 1..10\_do{\_oval{\_bp{\_wd0}}{\_bp{\_tmpdim}}{2+##1/2} f } Q}}%
1974 \_box0}%
1975 }
1976 \_def\.insertwhiteshadowresources{%
1977 \_addextgstate{trans}{<</ca \shadowparameter>>}%
1978 \_glet\.insertwhiteshadowresources=\_relax
1979 }
1980 \def\shadowparameter{.1} % default value of "transparency"
1981
1982 \_nspublic \putstext \shadowedtext ;
1983
1984 \_doc
1985 \`\c``[<init-rot>/<step>]{<text>}` prints the `<text>` around a curve.
1986 Each letter or space from `<text>` is processed individually. The first
1987 letter is rotated by `<init>` degrees. Next letters are printed after
1988 `<step>` transformation is applied.
1989 \_cod
1990
1991 \_def\.c[#1/#2]#3{% text podel krivky: \c[init-rotace/repetice]{text}
1992 \_pdfsave\_pdfrotate{#1}\_rlap{\_let\.printwarn=\_ignoreit
1993 \_edef\.tmpb{#3}\_replstring\.tmpb{ }{{ }}\_def\.tmpa{#2}%
1994 \_ea\_foreach\.tmpb\_do{##1\.tmpa}}\_pdfrestore \_kern10mm
1995 }
1996 \_let\c=\_undefined
1997 \_nspublic \c ;
1998
1999 \_doc
2000 \`\town` `<dimen> <dimen>` puts a circle with given \`\townparams`
2001 to the given place `<dimen> <dimen>`. It works like
2002 `\puttext <dimen> <dimen> {<circle>}`.
2003 \_cod
2004
2005 \_def\townparams{ % default parameters of the circle:
2006 \_hhkern=.8pt % diameter of the disc
2007 \_lwidth=.5pt % tickness of the outline
2008 \_fcolor=\Red % color of the inner disc
2009 \_lcolor=\Black % color of the outline
2010 }
2011 \_def\.town {\_ea\_ea\_ea\.townA\_scantwodimens}
2012 \_def\.townA #1#2{\_setbox0=\_hbox{\_incircle[\_hhkern=0pt \_vvkern=0pt \townparams]{}}%
2013 \_dimen1=#1sp \_dimen2=#2sp \_puttextB
2014 }
2015 \_nspublic \town ;
2016
2017 \_doc
2018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2019 \sec Chiasm
2020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2021
2022 The pair \`\begChiasm`...\`\endChiasm` defines chiasm environemnt. It
2023 behaves like `\begitems`...`\enditems`, but
2024 you can use given number of `*` which denotes the indentation level.
2025 The letters A, B, C, etc. will be prefixed automatically and when you are
2026 in the backward phase then C', B', A' are prefixed. You can try:
2027 \begtt
2028 \begChiasm
2029 * Předkové a rané zkušenosti (\<11:10-12:9>)
2030 ** Rané kontakty s ostatními národy (\<12:10-14:24>)
2031 *** Smlouva s Bohem (\<15:1-17:27>)
2032 ** Pozdní kontakty s ostatními národy (\<18:1-21:34>)
2033 * Potomci a smrt (\<22:1-25:18>)
2034 \endChiasm
2035 \endtt
2036 \_cod
2037
2038 \_def\.easylist{\_adef*{\.countlist}}
2039 \_def\.aast{\.countlist}
2040 \_def\.countlist{\_tmpnum=1 \.countlistA}
2041 \_def\.countlistA{\_futurelet\.next\.countlistB}
2042 \_def\.countlistB{\_ifx\.next\.aast \_ea\.countlistC\_else \_ea\.countlistD \_fi}
2043 \_def\.countlistC#1{\_incr\_tmpnum \.countlistA}
2044 \_def\.countlistD{%
2045 \_ifnum\_tmpnum>\_ilevel \_fornum \_ilevel..\_tmpnum-1 \_do{\_begitems\.easylist}\_else
2046 \_ifnum\_tmpnum<\_ilevel \_fornum \_tmpnum..\_ilevel-1 \_do{\_enditems}\_fi\_fi
2047 \_startitem}
2048
2049 \_def\.qq#1{{\_bf#1\_trycs{Level:\_the\_ilevel}{}}\_space\_aftergroup\.qqA}
2050 \_def\.qqA{\_sdef{Level:\_the\_ilevel}{\_rlap{'}}}
2051 \_def\.ChiasmNumbering{\_ea\.qq \_Uchar \_numexpr `A-1+\_ilevel\_relax\_space} % A, B, C, D, etc.
2052 \_sdef{_item:q}{}%for chiasms with no leading alphabet letters
2053 \_sdef{_item:Q}{\.ChiasmNumbering}
2054 \_def\.begChiasm{\_begitems \.easylist \_style Q \_let\_defaultitem=\_printitem}
2055 \_def\.endChiasm{\_fornum 1..\_ilevel \_do{\_enditems}}
2056
2057 \_nspublic \begChiasm \endChiasm ;
2058
2059 \_doc
2060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2061 \sec Outline
2062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2063 The \`\Outline` starts two column format in the introduction text.
2064 Nested lists are
2065 printed into the first colum and comments declated by
2066 \`rightnote``{<comment>}` are printed to the right column.
2067 \_cod
2068
2069 \_newdimen\.colsep
2070 \.colsep=10pt
2071
2072 \_def\.Outline{
2073 \_medskip
2074 % \filbreak
2075 \.chaptit{\_mtext{outline}}%
2076 \_everylist={\_ifcase\_ilevel \_or \_style I \_or \_style A \_or \_style n \_fi}
2077 \_sdef{_item:A}{\_strut\_uppercase\_ea{\_athe\_itemnum}. }
2078 \_sdef{_item:I}{\_strut\_uppercase\_ea{\_romannumeral\_itemnum}. }
2079 \_hsize=.5\_hsize \_advance\_hsize by-\.colsep
2080 \_emergencystretch=40pt
2081 \_leftskip=0pt \_rightskip=0pt
2082 }
2083 \_def\.rightnote#1{\_par
2084 \_setbox0=\_hbox{\_kern\_hsize \_kern\.colsep
2085 \_vtop{\_leftskip=0pt \_kern0pt\_noindent\_strut\_it#1}}
2086 \_ht0=0pt \_dp0=0pt \_box0 \_nointerlineskip
2087 }
2088 \_nspublic \Outline \rightnote ;
2089
2090 \_doc
2091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2092 \sec Timelines
2093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2094 \begitems
2095 * \`\timeline``<num>` sets the total number of years (or other units) in time-line.
2096 * \`\timelinewidth``<dimen>` sets the width of time-line.
2097 * \`\l` is shortcut for `\baselineskip` (an be used in `\vskip` parameter).
2098 \enditems
2099 \_cod
2100
2101 \_def\.l{\_baselineskip}
2102 \_newcount\.timeline \.timeline=100 % default
2103 \_newdimen\.tlwidth \.tlwidth=10cm % default
2104 \_def\.timelinewidth{\_afterassignment\.timelinewidthA\.tlwidth}
2105 \_def\.timelinewidthA{\_par\_hbox to\.tlwidth{}}
2106
2107 \_let\l=\_undefined
2108 \_nspublic \l \timeline \timelinewidth ;
2109
2110 \_doc
2111 All objects used for creating time-line are defined by `\puttext`, i.e.\
2112 they don't shift the current typesetting point.
2113
2114 \`\arrowtext` `<from>..<to> (<settings>) {<text>}`
2115 creates a horizontal line with arrows. Its width and its position is
2116 given by `<from>..<to>` time units. The `<settings>` can include font
2117 selector, color settings of something similar for `<text>`.
2118 The `<text>` is placed to the center of the line.
2119 \_cod
2120
2121 \_def\.arrowtext #1..#2(#3)#4{%
2122 \_puttext \.pos{#1}0pt
2123 {\_lower.745ex\_hbox to\_dimexpr\.pos{#2}-\.pos{#1}{#3\.Larrow{ #4 }\.Rarrow}}
2124 }
2125 \_def\.Larrow{$\leftarrow$\_kern-.8em\_leaders\_vrule height.65ex depth-.42ex\_hfil}
2126 \_def\.Rarrow{\_leaders\_vrule height.65ex depth-.42ex\_hfil\_kern-.8em$\rightarrow$}
2127 \_def\.rule{\_leaders\_vrule height.12ex depth.12ex\_hfil}
2128 \_def\.pos#1{\_expr{#1/\_the\.timeline}\.tlwidth}
2129
2130 \_nspublic \arrowtext ;
2131
2132 \_doc
2133 \`\tlput` `<above/below> <where> <llap or rlap or nothing> (<format ot text>) {<text>}`
2134 puts the <text> to the timeline. The <text> can include more lines
2135 separated by `\cr`. The parameter `<above/below>` is `a` or `b` and means
2136 the <text> position: above
2137 the current point or below it. <where> is the position of the text in time units.
2138 <llap or rlap> is `\llap` or `\llap` and it menans that text is encapsulated
2139 to `\llap`, `\rlap`. If nothing is here the text is centered.
2140 The <format of text> can include the font setting, color setting etc.
2141 \_cod
2142
2143 \_def\.tlput #1 #2 #3(#4)#5{%
2144 \_let\.Lhss=\_hss \_let\.Rhss=\_hss
2145 \_ifx#3\_rlap\_relax \_let\.Lhss=\_relax \_let\.Rhss=\_hss \_fi
2146 \_ifx#3\_llap\_relax \_let\.Lhss=\_hss \_let\.Rhss=\_relax \_fi
2147 \_puttext \.pos{#2}0pt {\_hbox to0pt{\.Lhss #4\.tltext#1{#5}\.Rhss}}
2148 }
2149 \_def\.tltext#1#2{\_ifx#1a\_vbox\_else
2150 \_vtop\_fi{\_kern0pt\_halign{\.Lhss##\.Rhss\_cr\_strut#2\_crcr}}%
2151 }
2152 \_nspublic \tlput ;
2153
2154 \_doc
2155 \`\tline``<from>..<to>` prints the line. Its length and position is given
2156 by `<from>..<to>` time units.\nl
2157 \`\tlines``{<data|separated|by|>}` creates a list of short vertical lines.
2158 Each line is represented by one `|`. The distance between lines (in time
2159 units) are given in the parameter.
2160 \_cod
2161
2162 \_def\.tline #1..#2 {%
2163 \_puttext \.pos{#1}0pt {\_hbox to \_dimexpr\.pos{#2}-\.pos{#1}{\.rule}}
2164 }
2165 \_def\.tlines#1{\_puttext 0pt0pt{\_hbox{\_foreach #1|\_do##1|{\.vrul\_hskip\.pos{0##1}}}}}
2166 \_def\.vrul{\_def\.vrul{\_kern-.12ex\_vrule height.7\.l depth.7\.l width.24ex \_kern-.12ex}}
2167
2168 \_nspublic \tline \tlines ;
2169
2170 \_doc
2171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2172 \sec Typesetting variants
2173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2174
2175 By default, chapter numbers are in the outer margin and quotes characters
2176 too.
2177 The \`\normalchapnumbers` macro moves chater numbers to the left side in the
2178 first paragraph, cquotes characters are removed and outer margins are
2179 reduced because there is no material in them.
2180 \_cod
2181
2182 \_def\.normalchapnumbers{
2183 \_margins/2 a4 (25,25,20,20)mm
2184 \.lrmargin=0pt
2185 \_setbox0=\_box\.lqqbox \_setbox0=\_box\.rqqbox
2186 \_def\.printbeforefirst{%
2187 \_nobreak\_medskip
2188 \.trychapnote
2189 \_hangindent=\_parindent \_hangafter=-2
2190 \_noindent \_llap{\_vbox to0pt
2191 {\_kern-8pt\_hbox{\_setfontsize{at23pt}\_bf\Red\_the\.chapnum\_kern5pt}\_vss}}%
2192 }
2193 }
2194 \_nspublic \normalchapnumbers ;
2195
2196 \_doc
2197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2198 \sec Checking syntax
2199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2200 \_cod
2201
2202 \_def\.checksyntax#1 {%
2203 \_let\processbooks=\_relax
2204 \_ifx\_relax#1\_relax \_else
2205 \_begingroup
2206 \_the\.syntaxmacros
2207 \_wterm{^^J** checking file: #1 **^^J}
2208 \_input{#1}
2209 \_vfil\_break
2210 \_endgroup
2211 \_ea\.checksyntax \_fi
2212 }
2213
2214 \_newtoks\.syntaxmacros
2215 {\_catcode`<=13
2216 \_global\.syntaxmacros={
2217 \_def<#1>{\_bgroup
2218 \_message{checking \_unexpanded{<#1>}}%
2219 \_ifx\_relax#1\_relax \_errmessage{empty link}\.nobref\_else \_afterfi{\.checkbref#1>\.bref#1>}\_fi
2220 \_glet\.linkpre=\.linkpre \_glet\.linkfspec=\.linkfspec
2221 \_egroup
2222 }
2223 \_def\.checkbref#1#2>{%
2224 \_isinlist{.#1#2}{<}\_iftrue \_errmessage{duplicated \_string<}\.nobref\_else
2225 \_ifx"#1\.checkbrefQ #1#2>\_else \.checkbrefD #1#2>\_fi\_fi
2226 }
2227 \_def\.checkbrefQ "#1"#2#3>{\.checkbrefD #2#3>}
2228 \_def\.checkbrefD #1>{%
2229 \_isinlist{.#1}{ }\_iftrue\.checkbrefS#1>\_else\.checkbrefN#1>\_fi
2230 }
2231 \_def\.checkbrefS #1 #2>{\.checkbrefN#2>}
2232 \_def\.checkbrefN #1>{%
2233 \_def\.tmpb{#1}
2234 \_ifx\.tmpb\_empty \_errmessage{missing link data}\.nobref\_else
2235 \_replstring\.tmpb{:}{}\_replstring\.tmpb{-}{}\_replstring\.tmpb{_}{}%
2236 \_replstring\.tmpb{a}{}\_replstring\.tmpb{b}{}\_replstring\.tmpb{c}{}%
2237 \_setbox0=\_hbox{\_tmpnum=0\.tmpb\_relax}%
2238 \_ifdim\_wd0>0pt \_errmessage{nonnumeric link data}\.nobref\_fi
2239 \_fi
2240 }
2241 \_def\.nobref{\_def\.bref##1>{{\Red\_string<##1>}}}
2242 \_def\.currbook{}
2243 \_def\.prelinkB{BK}
2244 \_def\.prelinkC{BK}
2245 \_def\.prelinkV{0}
2246 \_def\nochapbooks{BK}
2247 \_let\<=<
2248
2249 \_def\x/#1/{\_def\.tmpb{#1}%
2250 \_isinlist\.tmpb\x\_iftrue \.badx
2251 \_else \_isinlist\.tmp<\_iftrue \.badx
2252 \_else \_isinlist\.tmp\enditems\_iftrue \.badx \_else \.x/#1/\_fi\_fi\_fi
2253 }
2254 \_def\.badx{\_errmessage{unclosed \_string\x/.../}}
2255
2256 \_def\Article[#1]{}
2257 \_def\Cite #1 {\_par\_noindent{\_bf Cite: }}
2258 \_def\insertCite #1#2{}
2259
2260 \_def\putArticle #1 #2[#3]#4(#5){}
2261 \_def\putCite #1:#2 {\_par\_noindent{\_bf Cite: }}
2262 \_def\putBot #1 #2[#3]#4(#5){\_vbox}
2263
2264 \_def\c[#1/#2]#3{#3}
2265
2266 \_long\_ea\_def\_csname Note\_endcsname #1 #2#3%
2267
2268 {\_par \_let\.nextww\_undefined \_noindent{\_bf Note #1:} #3\_par}
2269 }}
2270 \_nspublic \checksyntax ;
2271
2272 \_doc
2273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2274 \sec Generating templates from templates
2275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2276
2277 The
2278 \`\filegen``{<file-name-template>}<cr><file-content-template><cr>\endfile`
2279 saves <file-name-template> to \`\.filename` and `<file-content-template>`
2280 to \`\.filecontent`. Then it runs a loop over \`\genbooks`.
2281 The `\genbooks` macro is defined by \^`\BookTitle` and user can re-define it.\nl
2282 The \`\.btitle``{<bmark or amark>}` expands to full title of the given book.
2283 \_cod
2284
2285 \_newwrite\.outfile
2286 \_def\.filegen #1 {\_par
2287 \_begingroup \_addto\genbooks{ }\_def\.filename{#1}%
2288 \_setverb \_endlinechar=`\^^J \.filegenA
2289 }
2290 \_ea\_def \_ea\.filegenA \_expanded{#1^^J\_csstring\\endfile#2^^J}{%
2291 \_def\.filecontent{#1}%
2292 \_ea\_foreach\genbooks \_do ##1 {%
2293 \_bgroup
2294 \_ifx^##1^\_else
2295 \_replstring\.filename{@@}{##1}%
2296 \_isfile{\.filename}\_iftrue \_opwarning{file "\.filename" exists already}%
2297 \_else
2298 \_wterm{creating file: \.filename}%
2299 \_immediate\_openout\.outfile={\.filename}%
2300 \_replstring\.filecontent{@@@}{\.btitle{##1}}%
2301 \_replstring\.filecontent{@@}{##1}%
2302 \_immediate\_write\.outfile{\.filecontent}\_immediate\_closeout\.outfile
2303 \_fi\_fi
2304 \_egroup
2305 }%
2306 \_endgroup
2307 }
2308 \_def\.btitle#1{\_ifcsname fb!#1\_endcsname \_trycs{btit!\_cs{fb!#1}}{#1}%
2309 \_else \_trycs{btit!#1}{#1}\fi
2310 }
2311 \_nspublic \filegen ;
2312
2313
2314 \_doc
2315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2316 \sec Other macros
2317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2318 The temporary macros are here. Maybe, they will be (more conceptually) rewritten.
2319 \_cod
2320
2321
2322 \_def\.quotationmarks#1#2{%
2323 \.cnvtext{"}{\.doquotmark}%
2324 \_def\.doquotmark {\_futurelet\.next\.doquotmarkA}%
2325 \_def\.doquotmarkA {%
2326 \_let\.doquotmarkB=#1\relax
2327 \_ea\_ifx\_space\.next \_let\.doquotmarkB=#2\_fi
2328 \_ifx\_space\.next \_let\.doquotmarkB=#2\_fi
2329 \_ifx\_endgraf\.next \_let\.doquotmarkB=#2\_fi
2330 \_ifx\_empty\.next \_let\.doquotmarkB=#2\_fi
2331 \_ifx.\.next \_let\.doquotmarkB=#2\_fi
2332 \_ifx,\.next \_let\.doquotmarkB=#2\_fi
2333 \.doquotmarkB}%
2334 }
2335 \_nspublic \quotationmarks ;
2336
2337 \_def\.chaptit#1{\_line{\_hss\.chapfont\Red#1\_hss}
2338 \_nobreak
2339 }
2340 \_def\.schaptit#1{\_bigskip\.chaptit{#1}\_nobreak\_medskip}
2341
2342 \_def\.subtit#1{\_par
2343 \_ifnum\.currversenum=1 \_else \_medskip\_fi
2344 \_line{\_indent\.subtitfont #1\_hss}\_nobreak
2345 \_ifnum\.currversenum=1 \_vskip-\_medskipamount\_fi
2346 \_smallskip
2347 }
2348 \_def\.subtitfont {\Red\_it}
2349
2350 \_nspublic \chaptit \schaptit \subtit ;
2351
2352 \_sdef{_mt:intro:en}{Introduction} \_sdef{_mt:outline:en}{Outline}
2353 \_sdef{_mt:intro:cs}{Úvod} \_sdef{_mt:outline:cs}{Osnova}
2354
2355 \_def\dopsat{{\Red !!! DOPSAT !!! }}
2356
2357 \_def\.bibleinput#1 {\_bgroup
2358 \_catcode`##=13 \_bgroup\_lccode`~=`## \_lowercase{\_egroup\_let~}=\.processline
2359 \_input{#1}%
2360 \_egroup
2361 }
2362 \_let\FormatedBook=\_ignoreit % for backward compatibility
2363 \_let\CommentedBook=\_ignoreit % for backward compatibility
2364
2365 \_doc
2366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2367 \sec Setting active character and `\outer` macros
2368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2369 Active character \code{<} used for references.
2370 \_cod
2371
2372 \_outer\_def\Note {\.Note}
2373 \_outer\_def\ww {\.ww}
2374 \_outer\_def\ChapterPre {\.ChapterPre}
2375 \_outer\_def\ChapterPost {\.ChapterPost}
2376 \_outer\_def\BookTilte {\.BookTitle}
2377
2378 \_def\_afterload{\_adef<{\.bref}}
2379 \_afterload
2380
2381 \_endnamespace
2382 \_endcode
2383
2384 \_doc
2385 \load [doc]
2386 \outlines{0}
2387
2388 \tit OpBible -- Technical Documentation
2389 \hfil Version: \_opb_version \medskip
2390
2391 The code of the `opbible.opm` macro file is described here.
2392 See also the user documentation in the file `opbible-doc.pdf`.
2393
2394 \notoc\nonum\sec Table of contents
2395 \maketoc
2396
2397 \catcode`\!=11 \catcode`\.=11
2398 \sec Preparatory work
2399 \printdoc opbible.opm
2400
2401 \sec Index
2402
2403 \def\_printii #1&{%
2404 \ifcsname cs:#1\endcsname
2405 \noindent \hskip-\iindent {\tt \link[cs:#1]\Blue{\bslash#1} }\else
2406 \ifcsname cs:^#1\endcsname \noindent \hskip-\iindent {\tt\bslash#1 }\else
2407 \afterfi{\afterfi{\_optexprintii #1&}}\fi\fi }
2408 \def\_pgprintA #1{#1}
2409
2410 \begmulti 3
2411 \makeindex
2412 \endmulti
2413 \bye
2414 \_cod
2415
2416 2023-10-04 0.31 \fmtrepl introduced
2417 2023-09-13 0.30 \.replpre improved
2418 2023-09-12 0.29 \fmtkeep introduced
2419 2023-08-27 0.28 \c switches off the \.printwarn because it expands its parameters
2420 2023-08-27 0.27 Termes if Biblon is unavailable
2421 2023-08-24 0.26 Tech. doc corrections
2422 2023-07-28 0.25 \enquotes swaps the \.lqqbox/\.rqqbox
2423 2023-07-17 0.24 \quotationsmark corrected secondly
2424 2023-07-04 0.23 \ww enables {"} parameters like \vdef
2425 2023-06-24 0.22 \ind: \ignorespaces added, \fmtopoetry with \quotationsmark corrected
2426 \begChiasm: \.keepstyle corrected
2427 2023-04-21 0.21 \_punctpword corrected
2428 2023-04-02 0.20 \_punctpword removes dot after ?, ! and dot.
2429 2023-02-25 0.19 \filegen introduced
2430 2023-01-23 0.18 \reduceref, \noreduceref, \re implemented
2431 2023-01-12 0.17 \cref implemented
2432 2022-12-11 0.16 \putSpanImage, \putSpanText implemented
2433 2022-12-10 0.15 Timeline macros moved to op-bible
2434 2022-12-09 0.14 \insertSpanText introduced
2435 2022-12-09 0.13 beter concept of putting \insertSpanImage's
2436 2022-12-02 0.12 \insertSpanImage introduced
2437 2022-11-18 0.11 \begChiasm, \endChiasm included here
2438 2022-11-05 0.10 \town implemented.
2439 2022-11-04 0.09 \putstext implemented, \leftskip=0pt included to \insertBot.
2440 0.08 \doCNote: bug fixed with undefined \.prevnotepre
2441 \.topinsertnopar introduced, bug with \par in \.dotopCite fixed
2442 2022-08-26 0.07 \.preindbuff implemented, bug with verse 1 with \fmtpoetry fixed
2443 0.06 \printchapnote reimplemented
2444 2022-08-24 0.05 \subtit implemented
2445 2022-08-23 0.04 \fmtfont implemented
2446 2022-08-20 0.03 \fmtpoetry implemented, \begpoetry \endpoetry removed
2447 0.02 \begpoetry, \endpoetry, \ind inplemented,
2448 \def\.buff etc. changed to \gdef\.buff (bug fixed)
2449 2022-08-19 0.01 version released