diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 14:42:56 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 14:42:56 +0200 |
| commit | a13dd6224a095242da54062e4775570c4f16a718 (patch) | |
| tree | 26dd6abe679b7f7955a2dc8bb378d6cd0a157143 /internal/cli/liturgy.go | |
| parent | 8ce330332289882eb5d4b3b60f0f3bbbcaced259 (diff) | |
| download | lectio-a13dd6224a095242da54062e4775570c4f16a718.tar.gz lectio-a13dd6224a095242da54062e4775570c4f16a718.zip | |
feat(cli,caldata): EF feast proper readings — offline text in --liturgy
Added 1962 Epistle+Gospel citations (from missalemeum) to the 15 EF feasts;
--liturgy now resolves + renders the reading text via the corpora (drb/wuj),
incl. deuterocanon (Assumption's Judith epistle). Cross-chapter citations use
their primary range pending multi-chapter parser support.
Diffstat (limited to 'internal/cli/liturgy.go')
| -rw-r--r-- | internal/cli/liturgy.go | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/internal/cli/liturgy.go b/internal/cli/liturgy.go index b1a8874..fc3efae 100644 --- a/internal/cli/liturgy.go +++ b/internal/cli/liturgy.go @@ -6,9 +6,11 @@ import ( "strings" "time" + "github.com/lukaszkasprzak/lectio/internal/bible" "github.com/lukaszkasprzak/lectio/internal/caldata" "github.com/lukaszkasprzak/lectio/internal/calendar" "github.com/lukaszkasprzak/lectio/internal/config" + "github.com/lukaszkasprzak/lectio/internal/render" ) // runLiturgy prints the computed liturgical day for date (default today) using @@ -29,11 +31,36 @@ func runLiturgy(cfg config.Config, date string, stdout, stderr io.Writer) int { fmt.Fprintln(stderr, "lectio: warning:", e) } day := calendar.Compute(d.UTC(), cfg.Selection(), layers) - printLiturgicalDay(stdout, cfg, day) + tbl, _ := bible.LoadBookTable(userBooksTOML()) + printLiturgicalDay(stdout, cfg, tbl, day) return 0 } -func printLiturgicalDay(out io.Writer, cfg config.Config, day calendar.LiturgicalDay) { +// vernacularVersion is the offline corpus used to render reading text: Wujek +// for Polish, Douay-Rheims otherwise (bt is scraped, so it is not used here). +func vernacularVersion(cfg config.Config) string { + if cfg.TraditionalLang == "pl" || cfg.UILanguage == "pl" { + return "wuj" + } + return "drb" +} + +// readingText resolves an English citation and returns its text from version, +// or "" if it does not resolve. +func readingText(tbl *bible.BookTable, version, citation string) string { + engRef, ok := tbl.ParseRef("en", citation) + if !ok { + return "" + } + vs, _ := bible.Lookup(version, engRef) + parts := make([]string, 0, len(vs)) + for _, v := range vs { + parts = append(parts, strings.TrimSpace(v.Text)) + } + return strings.Join(parts, " ") +} + +func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable, day calendar.LiturgicalDay) { fmt.Fprintf(out, "%s %s\n", day.Date.Format("2006-01-02"), day.Weekday.String()) if day.SundayCycle != "" { // OF carries the reading cycles; EF does not fmt.Fprintf(out, "season: %s (week %d · Sunday cycle %s · weekday cycle %s)\n", @@ -47,13 +74,21 @@ func printLiturgicalDay(out io.Writer, cfg config.Config, day calendar.Liturgica fmt.Fprintf(out, " also: %s [%s]\n", n, rankLabel(o.Rank)) } } + vern := vernacularVersion(cfg) for _, m := range day.Observed.Masses { for _, r := range m.Readings { label := r.Part if m.Variant != "" { label = m.Variant + " " + label } - fmt.Fprintf(out, " %-16s %s\n", label+":", r.Citation) + fmt.Fprintf(out, "\n %s (%s):\n", label, r.Citation) + if txt := readingText(tbl, vern, r.Citation); txt != "" { + for _, line := range strings.Split(render.Wrap(txt, 72), "\n") { + fmt.Fprintf(out, " %s\n", line) + } + } else { + fmt.Fprintf(out, " (text not in %s)\n", vern) + } } } } |
