diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 19:05:13 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 19:05:13 +0200 |
| commit | 7dbd16cdf5880c0006dffacd09214ee607050b64 (patch) | |
| tree | 01e1ee37a2be97a0b06fad70de975d8007beb702 /test/cli.t | |
| parent | 1aeca948c2a2a82bffaaec65077140aa05f7b3f4 (diff) | |
| parent | 1da70dc7ac03fe33fb92b172a0e26932764170d6 (diff) | |
| download | colitur-7dbd16cdf5880c0006dffacd09214ee607050b64.tar.gz colitur-7dbd16cdf5880c0006dffacd09214ee607050b64.zip | |
Merge branch 'citations-and-sigla'
Citations are parsed into structure and re-rendered, so book names,
abbreviations, punctuation style and numbering tradition become files a
user edits rather than strings frozen in the data.
New lib/citation (Book, Parse, Render, Sigla); [bible] and [sigla]
sections in language files; lang/traditions.ini for numbering; three
config keys and CLI flags. --raw emits every citation byte-for-byte as
stored, bypassing the whole pipeline, so output stays diffable against
lectio and the raw view does not depend on the parser being correct.
Diffstat (limited to 'test/cli.t')
| -rw-r--r-- | test/cli.t | 201 |
1 files changed, 185 insertions, 16 deletions
@@ -420,7 +420,7 @@ CSV emits a header and one row per day: $ colitur emit --format csv --from 2027 --to 2027 | head -2 date,rite,season,season_name,week,slug,name,weekday,rank,rank_name,colour,colour_name,subject,first,gospel,comms - 2027-01-01,ef,christmastide,Tempus Nativitatis,,ef-circumcision,In Octava Nativitatis Domini,Feria VI,class-1,I classis,white,albus,temporal,Titus 2:11-15,Luke 2:21, + 2027-01-01,ef,christmastide,Tempus Nativitatis,,ef-circumcision,In Octava Nativitatis Domini,Feria VI,class-1,I classis,white,albus,temporal,Tit 2:11-15,Luc 2:21, $ colitur emit --format csv --from 2027 --to 2027 | wc -l 366 @@ -519,7 +519,7 @@ place. 1 January 2027 is the Circumcision, kept within the Nativity octave: 2027-01-02 saturday christmastide - ef-christmas-1-saturday class-4 white Officium sanctae Mariae in sabbato $ colitur readings 2027 | head -1 - 2027-01-01 ef-circumcision | Titus 2:11-15 | Luke 2:21 | In Octava Nativitatis Domini + 2027-01-01 ef-circumcision | Tit 2:11-15 | Luc 2:21 | In Octava Nativitatis Domini --raw restores the old byte-exact output -- no trailing field at all, not merely an empty one, because [Lang.raw] is the identity table (lang.mli): @@ -535,6 +535,39 @@ rather than merely asserted: $ colitur readings 2027 --raw | head -1 2027-01-01 ef-circumcision | Titus 2:11-15 | Luke 2:21 +Every citation now renders through a {!Colitur_citation.Sigla.t} (Task 9), +at both places one reaches output -- [View.citation_ref] (`table`/`render`/ +`emit`/`publish`) and `readings`' own `part_ref`. The DEFAULT style +normalises the seven duplicate book spellings the shipped data inherited +from lectio onto ONE name, reconstructed from the citation's PARSED +structure, so stray punctuation the parser already treats as noise +(a trailing full stop or semicolon, a comma used as a chapter/verse +separator) does not survive either. Since Task 10 shipped `la.ini`'s own +`[bible]` section, that one name is a real Latin abbreviation sourced from +the Missal scans, not merely a pick between the data's own two raw +spellings: both `3 Kgs.` and `3 Kings` resolve to `3 Reg`, the Vulgate's own +form (lang/la.ini's own `[bible]` header note, kings_3): + + $ colitur readings 2027 | grep -E '3 Reg' | head -3 + 2027-02-17 ef-lent-ember-wed | 3 Reg 19:3-8 | Matth 12:38-50 | Feria IV Quatuor Temporum Quadragesimae + 2027-02-23 ef-lent-2-tuesday | 3 Reg 17:8-16 | Matth 23:1-12 | Feria III post Dominicam II in Quadragesima + 2027-03-08 ef-lent-4-monday | 3 Reg 3:16-28 | Ioann 2:13-25 | Feria II post Dominicam IV in Quadragesima + +`--raw` passes {!Colitur_citation.Sigla.verbatim}, NEVER a styled `Sigla.t` +built over `Lang.raw` -- the latter would still parse and reformat every +citation, defeating the byte-exact diffing `--raw` exists for. So the +dotted, unnormalised spelling the data actually stores survives `--raw` +untouched, proving the bypass is real and not merely a style that happens +to look unstyled: + + $ colitur readings 2027 --raw | grep -E '3 K(gs|ings)' | head -3 + 2027-02-17 ef-lent-ember-wed | 3 Kgs. 19:3-8 | Matt 12:38-50 + 2027-02-23 ef-lent-2-tuesday | 3 Kings 17:8-16 | Matt 23:1-12 + 2027-03-08 ef-lent-4-monday | 3 Kings 3:16-28 | John 2:13-25 + + $ colitur readings 2027 --raw | grep -c '3 Kgs\.' + 1 + A language file by path (--lang accepts a bare code OR a file path -- a value containing '/' or ending ".ini" is read literally rather than looked up in the installed language directory). The synthetic file below declares @@ -546,6 +579,21 @@ shows the override: $ colitur day 2027 --lang ./lang-xx.ini | head -1 2027-01-01 friday christmastide - ef-circumcision class-1 white TEST FEAST +A book name's own `[bible]` lookup is TOTAL and returns THE KEY on a miss +(e.g. "luke.abbr"), the same contract every other `Lang` lookup keeps -- +rendering that literally into a citation would print "luke.abbr 2:21". +The language file below has no `[bible]` section AT ALL (and, unlike +`lang-xx.ini` above, no `fallback` either, so it can never inherit one +through the chain), pinning the degrade-to-the-data's-own-spelling path +independently of whatever `la.ini`/`en.ini` ship in `[bible]` themselves: +this stays a real witness even after they gain one, where a test relying +on their own current bare state would quietly stop testing anything the +day they do. + + $ printf '[meta]\nlang = yy\n' > lang-no-bible.ini + $ colitur readings 2027 --lang ./lang-no-bible.ini | head -1 + 2027-01-01 ef-circumcision | Titus 2:11-15 | Luke 2:21 + An unknown language is a usage error naming what is available, never a silent fallback to Latin: a booklet quietly printed in the wrong language is worse than one that refuses to print. The exact "(looked in ...)" path is @@ -1204,7 +1252,7 @@ so two dumps of the same table are byte-identical: [meta] lang = la - [celebration] + [bible] $ grep -c '^ef-epiphany ' d.ini 1 @@ -1213,12 +1261,14 @@ slug the engine can produce over 2020-2045: $ colitur lang --check d.ini d.ini: 725 of 725 celebrations named, 0 missing, 0 unknown + d.ini: 104 of 104 book names, 0 missing `--check` reports what is MISSING (a real slug with no entry): $ printf '[meta]\nlang = zz\n[celebration]\nef-epiphany = Test\n' > partial.ini - $ colitur lang --check partial.ini | tail -1 + $ colitur lang --check partial.ini | tail -2 partial.ini: 1 of 725 celebrations named, 724 missing, 0 unknown + partial.ini: 0 of 104 book names, 104 missing `--check` REJECTS an unknown slug (exit 1), so a typo is visible rather than silently dead -- its author would otherwise never learn why the name they @@ -1258,10 +1308,13 @@ literally either): $ XDG_CONFIG_HOME=xdg-test colitur config --show config file: xdg-test/colitur/config.ini (not found) - lang la (default) - template (none) (default) - format (none) (default) - overlay (none) (default) + lang la (default) + template (none) (default) + format (none) (default) + sigla_style la (default) + sigla_book abbr (default) + sigla_tradition vulgate (default) + overlay (none) (default) A flag on the SAME command line previews exactly what it would resolve to on any other command -- `overlay` has no single scalar value, so it is @@ -1269,10 +1322,13 @@ listed one line per effective entry instead: $ XDG_CONFIG_HOME=xdg-test colitur config --show --lang fr --overlay mine.sexp config file: xdg-test/colitur/config.ini (not found) - lang fr (flag) - template (none) (default) - format (none) (default) - overlay mine.sexp (flag) + lang fr (flag) + template (none) (default) + format (none) (default) + sigla_style fr (default) + sigla_book abbr (default) + sigla_tradition vulgate (default) + overlay mine.sexp (flag) A real config file supplies a default that a command with no explicit flag then uses. An unrecognised key and an unrecognised section are each warned @@ -1284,13 +1340,126 @@ differently from a misspelled key inside a recognised one: $ printf '[defaults]\nlang = en\noverlay = /nonexistent/parish.sexp\nbogus = 1\n\n[deafults]\nlang = xx\n' > xdg-test/colitur/config.ini $ XDG_CONFIG_HOME=xdg-test colitur config --show config file: xdg-test/colitur/config.ini (exists) - lang en (config) - template (none) (default) - format (none) (default) - overlay /nonexistent/parish.sexp (config) + lang en (config) + template (none) (default) + format (none) (default) + sigla_style en (default) + sigla_book abbr (default) + sigla_tradition vulgate (default) + overlay /nonexistent/parish.sexp (config) colitur: xdg-test/colitur/config.ini: unknown setting "bogus" (ignored) colitur: xdg-test/colitur/config.ini: unknown section [deafults] (ignored) +`--sigla-style`/`--sigla-book`/`--sigla-tradition` (Task 8) resolve through +the identical flag > config > default precedence as --lang/--template/ +--format, each reported by its own row. `sigla_style` defaults to the +RESOLVED language, not a literal "la" -- a booklet that asked for a +different --lang gets its citations in that language too unless told +otherwise. Run through a fresh XDG_CONFIG_HOME, so this does not depend on +the config file the earlier examples left behind: + + $ XDG_CONFIG_HOME=xdg-sigla colitur config --show --sigla-style pl --sigla-book full --sigla-tradition modern + config file: xdg-sigla/colitur/config.ini (not found) + lang la (default) + template (none) (default) + format (none) (default) + sigla_style pl (flag) + sigla_book full (flag) + sigla_tradition modern (flag) + overlay (none) (default) + +An unrecognised `--sigla-book` is a hard usage ERROR -- exit 2, one line on +stderr -- the same discipline an unrecognised `--lang` gets, never a silent +fallback: `Colitur_citation.Render.with_book` takes a closed variant, not an +arbitrary string, so anything other than "full"/"abbr" could never mean +anything downstream. + + $ XDG_CONFIG_HOME=xdg-sigla colitur config --show --sigla-book bogus + config file: xdg-sigla/colitur/config.ini (not found) + lang la (default) + template (none) (default) + format (none) (default) + sigla_style la (default) + colitur: unknown --sigla-book "bogus" (want "full" or "abbr") + [2] + +An unrecognised `--sigla-tradition`, by contrast, is NOT fatal: it is +resolved for real against lang/traditions.ini (the same reader a future +renderer will use), and a name matching no section there degrades to the +Vulgate with a warning on stderr, exactly as an unknown tradition does +everywhere else in this project -- asking for a renumbering is optional the +way asking for a language is not, so a run is not lost over a typo here. +The warning itself carries lang/traditions.ini's own resolved PATH, which is +absolute and build-tree-specific -- grepped for rather than matched in +full, the same way the pre-existing "unknown language" case above already +sidesteps that same non-portability: + + $ XDG_CONFIG_HOME=xdg-sigla colitur config --show --sigla-tradition nonsense 2>/dev/null + config file: xdg-sigla/colitur/config.ini (not found) + lang la (default) + template (none) (default) + format (none) (default) + sigla_style la (default) + sigla_book abbr (default) + sigla_tradition nonsense (flag) + overlay (none) (default) + $ XDG_CONFIG_HOME=xdg-sigla colitur config --show --sigla-tradition nonsense 2>&1 >/dev/null | grep -c 'no tradition "nonsense"; falling back to the Vulgate' + 1 + +`--sigla-style`/`--sigla-book`/`--sigla-tradition` (Task 9) actually render +a citation on every command that emits one -- `readings`, `table`/`render`, +`emit`, `publish` -- and are refused, rather than silently ignored, on +every command that reads no sanctoral data or renders no citation at all +(`day` included: it prints no `first`/`gospel` field of its own), the same +discipline `--overlay`/`--lang` already get: + + $ colitur day 2027 --sigla-style la > /dev/null + colitur: --sigla-style/--sigla-book/--sigla-tradition have no effect on `day`; refusing rather than ignoring them + [2] + + $ colitur easter 2026 --sigla-book full + colitur: --sigla-style/--sigla-book/--sigla-tradition have no effect on `easter`; refusing rather than ignoring them + [2] + +`--sigla-style` selects a DIFFERENT file's own `[sigla]` section than +`--lang` selects for names -- a booklet may want Polish names but +Latin-convention punctuation. The synthetic file below overrides only +`chapter_verse` (comma instead of colon), leaving `--lang`'s own default +(Latin) name resolution untouched: + + $ printf '[meta]\nlang = zz\n[sigla]\nchapter_verse = "{chapter}, {verses}"\n' > lang-sigla.ini + $ colitur readings 2027 --sigla-style ./lang-sigla.ini | head -1 + 2027-01-01 ef-circumcision | Tit 2, 11-15 | Luc 2, 21 | In Octava Nativitatis Domini + +`--sigla-tradition` renumbers which book an id DENOTES (lang/traditions.ini), +independently of style or naming -- `modern` maps `3 Kings` onto the id +`kings_1`, whose own Latin name la.ini marks CONSTRUCTED: the 1962 Missal +uses Vulgate numbering throughout, so it can contain no incipit for a book +that exists only under a later convention. In Latin the modern tradition +therefore only really moves Kings and Esdras -- Osee, Ionas, Ecclesiasticus +and the Apocalypse keep their Vulgate names either way, because modern +numbering is a vernacular convention: + + $ colitur readings 2027 --sigla-tradition modern | grep '^2027-02-17' + 2027-02-17 ef-lent-ember-wed | 1 Reg 19:3-8 | Matth 12:38-50 | Feria IV Quatuor Temporum Quadragesimae + +Under an English file the same mapping shows its usual face: + + $ colitur readings 2027 --lang en --sigla-tradition modern | grep '^2027-02-17' + 2027-02-17 ef-lent-ember-wed | 1 Kgs 19:3-8 | Matt 12:38-50 | Lenten Ember Wednesday + +`table`/`render`, `emit` and `publish` accept the same three flags too -- +smoke-tested for exit status alone here (a minimal inline template, the +same device the table/render examples above use), since their own +byte-for-byte content is already the golden/emit suites' job, not this +file's: + + $ printf '{{#days}}{{first}}\n{{/days}}' > /tmp/t-sigla.txt + $ colitur table --year 2027 --template /tmp/t-sigla.txt --sigla-book full > /dev/null + $ colitur render --template /tmp/t-sigla.txt --year 2027 --sigla-book full > /dev/null + $ colitur emit --format csv --from 2027 --to 2027 --sigla-book full > /dev/null + $ colitur publish --from 2027 --to 2027 --out /tmp/pub-sigla --sigla-book full > /dev/null + `config` requires --show: $ colitur config |
