summaryrefslogtreecommitdiff
path: root/lib/citation
diff options
context:
space:
mode:
Diffstat (limited to 'lib/citation')
-rw-r--r--lib/citation/book.ml5
-rw-r--r--lib/citation/book.mli19
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/citation/book.ml b/lib/citation/book.ml
index 545e324..2a2b9c0 100644
--- a/lib/citation/book.ml
+++ b/lib/citation/book.ml
@@ -78,6 +78,11 @@ let all = List.map fst table @ tradition_targets
let tokens =
List.concat_map (fun (id, sp) -> List.map (fun s -> (s, id)) sp) table
+let default_spelling id =
+ match List.assoc_opt id table with
+ | Some (first :: _) -> first
+ | Some [] | None -> id
+
let of_token s =
let s = String.trim s in
List.assoc_opt s tokens
diff --git a/lib/citation/book.mli b/lib/citation/book.mli
index 8918bc3..0ca229c 100644
--- a/lib/citation/book.mli
+++ b/lib/citation/book.mli
@@ -36,6 +36,25 @@ 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