aboutsummaryrefslogtreecommitdiff
path: root/lib/citation/book.mli
blob: 4e91c6c5533b6b8e6e1689dc9b0a02b4120084b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
(* SPDX-License-Identifier: AGPL-3.0-or-later *)

(** Bible books: one canonical id per book, and the tradition that decides
    which book an id denotes.

    Ids follow the VULGATE structure ([kings_3], [esdras_2],
    [ecclesiasticus]), because the Vulgate is the default tradition and the
    shipped 1962 data is Vulgate throughout. An id is internal -- it is never
    shown to a reader, exactly as a slug is never shown. *)

type id

val to_string : id -> string

(** Resolve one spelling as it appears in the data. Returns [None] for
    anything not in {!tokens}.

    SIXTEEN books arrive in more than one spelling, surveyed across all
    three citation-bearing files ([lectionary.sexp], [sanctoral.sexp],
    [commons.sexp] -- not the lectionary alone, which undercounts: the
    sanctoral propers alone carry more citations than the lectionary does).
    Most are a dotted/undotted pair ([Isa]/[Isa.], [3 Kgs.]/[3 Kings], and
    others); two also carry a MODERN spelling sitting inside otherwise-
    Vulgate data ([Sir] alongside [Ecclus]/[Eccli], [Rev] alongside [Apoc]).
    All of this is INHERITED from lectio's own ini, which is itself
    generated from missalemeum/Divinum Officium -- it is not a colitur
    transcription error, and the data is deliberately left untouched. Every
    accepted spelling resolves here to the same, single Vulgate id: [Sir]
    resolves to [ecclesiasticus] and [Rev] to [apocalypse], never to the
    tradition-only targets [sirach]/[revelation] -- see those below. *)
val of_token : string -> id option

(** Every id surveyed against the EF's own three citation-bearing files
    (lectionary, sanctoral propers, commons) -- for coverage checks: every
    SHIPPED language file's [\[bible\]] section is asserted complete over
    this list (test_lang_coverage.ml). NOT every id {!of_token} can resolve:
    book.ml's own [of_lectionary_table] adds a further ~25 ids the OF's
    English-canonical lectionary cites that no EF file ever needed and that
    no primary EF source attests a Latin title for -- resolvable ([of_token]/
    {!default_spelling} both cover them) but deliberately excluded here,
    rather than either fabricating an uncited Latin name or weakening this
    list's own completeness promise for the ids that DO have one. Such a
    book still renders, in its own English spelling ({!default_spelling}'s
    own fallback), never a raw internal id. *)
val all : id list

(** Every accepted spelling paired with its id. *)
val tokens : (string * id) list

(** The first spelling registered for an id -- the form the shipped data
    itself uses ([luke] -> ["Luke"], [kings_3] -> ["3 Kings"]).

    This is the FALLBACK display name, and it exists because the obvious
    alternative is actively worse. A language file's [\[bible\]] lookup is
    total and returns THE KEY on a miss, so a book with no entry would
    otherwise render as ["luke.abbr 5:12-14"]. Falling back here instead makes
    an unnamed book render as ["Luke 5:12-14"] -- exactly what colitur printed
    before this feature existed. The degraded case is the OLD behaviour, not a
    broken page, the same principle {!Colitur_naming.Lang} states for its own
    key-returning misses.

    An id with no registered spelling -- only a {!tradition} target such as
    [kings_1] or [sirach], which the Vulgate data never cites -- returns the id
    itself. Reachable only from a user language file that selects a tradition
    without naming its target books; every SHIPPED language file is asserted
    complete over {!all}. *)
val default_spelling : id -> string

(** A numbering tradition: which book an id denotes. Separate from NAMING
    (what a book is called), which lives in a language file's [\[bible\]]
    section, because naming varies by language and this does not -- "modern
    numbering" is the same decision in Latin, Polish and English. *)
type tradition

(** The identity tradition: the Vulgate, as the 1962 Missal prints it. The
    default; colitur never silently renumbers. *)
val vulgate : tradition

(** Build a tradition from an ini section's fields. An entry naming an
    unknown id on either side is IGNORED, not fatal: a traditions file
    written for a newer colitur must still work on an older one. Use
    {!unknown_fields} to report them. *)
val tradition_of_fields : (string * string) list -> tradition

(** The fields {!tradition_of_fields} silently dropped -- either side naming
    an id outside {!all}. Never raises; a caller that cares can report these,
    a caller that does not can ignore the return value entirely. *)
val unknown_fields : (string * string) list -> string list

val map : tradition -> id -> id

(** Whether [id] names a book with exactly one chapter (Jude, Philemon,
    2 John, 3 John), conventionally cited by verse alone with no chapter
    number ("Jude 17", not "Jude 1:17"). {!Colitur_citation.Parse.parse}
    consults this to avoid misreading a leading verse number as a chapter
    -- see book.ml's own citation for the real citation this was found on. *)
val is_single_chapter : id -> bool