aboutsummaryrefslogtreecommitdiff
path: root/lib/render
diff options
context:
space:
mode:
Diffstat (limited to 'lib/render')
-rw-r--r--lib/render/dune5
-rw-r--r--lib/render/view.ml18
-rw-r--r--lib/render/view.mli14
3 files changed, 26 insertions, 11 deletions
diff --git a/lib/render/dune b/lib/render/dune
index 548cf43..26e6d0d 100644
--- a/lib/render/dune
+++ b/lib/render/dune
@@ -1,5 +1,8 @@
(library
(name colitur_render)
- (libraries colitur_kernel colitur_naming sexplib)
+ ; [colitur_citation] backs [View.citation_ref]'s own [Sigla.format] call
+ ; (Task 9): a citation now renders through a caller-supplied style rather
+ ; than passing its stored reference straight through.
+ (libraries colitur_kernel colitur_naming colitur_citation sexplib)
(preprocess
(pps ppx_sexp_conv)))
diff --git a/lib/render/view.ml b/lib/render/view.ml
index 9f489aa..0691ffb 100644
--- a/lib/render/view.ml
+++ b/lib/render/view.ml
@@ -1,6 +1,7 @@
module K = Colitur_kernel
module T = Template
module Lang = Colitur_naming.Lang
+module Sigla = Colitur_citation.Sigla
let str s = T.Str s
let bool b = T.Bool b
@@ -43,11 +44,14 @@ let dow_int = function
| K.Date.Sun -> 0 | K.Date.Mon -> 1 | K.Date.Tue -> 2 | K.Date.Wed -> 3
| K.Date.Thu -> 4 | K.Date.Fri -> 5 | K.Date.Sat -> 6
-let citation_ref cits part =
+(* [sigla] renders the stored reference in the caller's chosen style
+ (Task 9) -- under [Sigla.verbatim] this is the identity, so [--raw]'s
+ own byte-exact contract is unaffected. *)
+let citation_ref ~sigla cits part =
match
List.find_opt (fun (c : K.Citation.t) -> c.K.Citation.part = part) cits
with
- | Some c -> c.K.Citation.reference
+ | Some c -> Sigla.format sigla c.K.Citation.reference
| None -> ""
(* A commemoration's own name resolves through the SAME [lang.celebration]
@@ -85,7 +89,7 @@ let padding_cell dow =
("transferred_in", T.List []); ("transferred_out", T.List []);
("first", str ""); ("gospel", str ""); ("last", bool false) ]
-let day_value ~lang ~vocab (d : ('s, 'r) K.Liturgical_day.t) =
+let day_value ~lang ~sigla ~vocab (d : ('s, 'r) K.Liturgical_day.t) =
let date = d.K.Liturgical_day.date in
let tmp = d.K.Liturgical_day.temporal in
let cel = d.K.Liturgical_day.observed in
@@ -135,8 +139,8 @@ let day_value ~lang ~vocab (d : ('s, 'r) K.Liturgical_day.t) =
[ ("slug", str (K.Slug.to_string c.K.Celebration.slug));
("to", str (K.Date.to_iso8601 dest)) ])
d.K.Liturgical_day.transferred_out) );
- ("first", str (citation_ref d.K.Liturgical_day.citations K.Citation.First));
- ("gospel", str (citation_ref d.K.Liturgical_day.citations K.Citation.Gospel));
+ ("first", str (citation_ref ~sigla d.K.Liturgical_day.citations K.Citation.First));
+ ("gospel", str (citation_ref ~sigla d.K.Liturgical_day.citations K.Citation.Gospel));
(* overwritten per grid row by [set_last]; false in the flat [days] list *)
("last", bool false) ]
@@ -245,8 +249,8 @@ let weekday_headings lang =
T.List
(List.init 7 (fun i -> T.Obj [ ("name", str (Lang.weekday lang i)); ("last", bool (i = 6)) ]))
-let of_days ~lang ~vocab ~rite ~year days =
- let dvs = List.map (fun d -> (d, day_value ~lang ~vocab d)) days in
+let of_days ~lang ~sigla ~vocab ~rite ~year days =
+ let dvs = List.map (fun d -> (d, day_value ~lang ~sigla ~vocab d)) days in
let months =
List.init 12 (fun i ->
let m = i + 1 in
diff --git a/lib/render/view.mli b/lib/render/view.mli
index 81bfc26..d271641 100644
--- a/lib/render/view.mli
+++ b/lib/render/view.mli
@@ -16,13 +16,14 @@
val of_days :
lang:Colitur_naming.Lang.t ->
+ sigla:Colitur_citation.Sigla.t ->
vocab:('s, 'r) Colitur_kernel.Vocab.t ->
rite:string ->
year:int ->
('s, 'r) Colitur_kernel.Liturgical_day.t list ->
Template.value
-(** [of_days ~lang ~vocab ~rite ~year days] where [days] is one civil year,
- 1 January to 31 December, in order. Pure and total.
+(** [of_days ~lang ~sigla ~vocab ~rite ~year days] where [days] is one civil
+ year, 1 January to 31 December, in order. Pure and total.
[lang] resolves every display string -- a day's [name], its localised
[weekday]/[rank_name]/[colour_name]/[season_name], each month's [name],
@@ -35,4 +36,11 @@ val of_days :
[slug] is untouched by [lang] -- it stays the stable machine key,
identical between any two calls that differ only in [lang]. Pass
{!Colitur_naming.Lang.raw} for the pre-naming behaviour, under which
- [name] equals [slug] exactly (this is what CLI [--raw] uses). *)
+ [name] equals [slug] exactly (this is what CLI [--raw] uses).
+
+ [sigla] resolves the [first]/[gospel] citation fields (Task 9): each
+ stored reference is passed through {!Colitur_citation.Sigla.format}
+ rather than emitted verbatim. Pass {!Colitur_citation.Sigla.verbatim}
+ alongside {!Colitur_naming.Lang.raw} for [--raw] -- a styled [Sigla.t]
+ built over [Lang.raw] would still parse and reformat every citation,
+ which defeats the byte-exact diffing [--raw] exists for. *)