diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 14:23:55 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 14:23:55 +0200 |
| commit | a87f2fafbda90cc9eeb32ea856356c34e1d880b0 (patch) | |
| tree | 20d1a9ab2bca099e1fdf8afd6391321de1119b50 /internal/render | |
| parent | e54b24308e42addad396a13f9f53a60e5f6468d5 (diff) | |
| download | lectio-a87f2fafbda90cc9eeb32ea856356c34e1d880b0.tar.gz lectio-a87f2fafbda90cc9eeb32ea856356c34e1d880b0.zip | |
grb: strip SBLGNT apparatus markers (U+2E00–U+2E0D); render: show scripture ref in traditional headings; v0.12.0
Diffstat (limited to 'internal/render')
| -rw-r--r-- | internal/render/render.go | 16 | ||||
| -rw-r--r-- | internal/render/render_test.go | 18 |
2 files changed, 34 insertions, 0 deletions
diff --git a/internal/render/render.go b/internal/render/render.go index 7ba8ebd..6cdb939 100644 --- a/internal/render/render.go +++ b/internal/render/render.go @@ -65,6 +65,22 @@ func LocalizeHeading(heading, partID, lang string) string { return heading } +// HeadingWithRef returns a section's localised heading with its scripture +// reference appended in parentheses when the heading does not already carry +// one. The modern (niedziela) heading already embeds its citation -- e.g. +// "Ewangelia (J 20, 1. 11-18)" -- while the traditional (missalemeum) heading +// is a bare label ("Gospel"/"Ewangelia") with the reference only in +// sec.Citation; this appends it so every reading shows where it is from, +// uniformly across cli/tui/web. The citation is source-form (like the modern +// one), never translated. +func HeadingWithRef(sec liturgy.Section, lang string) string { + heading := LocalizeHeading(sec.Heading, sec.PartID, lang) + if sec.Citation != "" && !strings.Contains(heading, "(") { + heading += " (" + sec.Citation + ")" + } + return heading +} + // versionSystem maps a bible version to the Psalter system bible.ToEnglishRef // expects: vul/grb/wuj follow the Vulgate/Septuagint numbering, drb follows // the Hebrew chapter with the DRB title-fold verse shift. Ported from diff --git a/internal/render/render_test.go b/internal/render/render_test.go index 496dc23..e2a26fc 100644 --- a/internal/render/render_test.go +++ b/internal/render/render_test.go @@ -181,6 +181,24 @@ func TestGatherVersesLabelLang(t *testing.T) { // replaced by its en label, the citation kept exactly as scraped, and every // other case (pl, unknown/traditional partID, prefix mismatch) is a safe // no-op that returns heading unchanged. +func TestHeadingWithRef(t *testing.T) { + // Traditional-style: a bare label plus Citation -> reference appended. + trad := liturgy.Section{Heading: "Gospel", Citation: "Luke 16:1-9", PartID: "evangelium"} + if got := HeadingWithRef(trad, "en"); got != "Gospel (Luke 16:1-9)" { + t.Errorf("traditional heading = %q, want %q", got, "Gospel (Luke 16:1-9)") + } + // Modern-style: heading already carries "(...)" -> not doubled; the pl label + // is still localised to en. + modern := liturgy.Section{Heading: "Ewangelia (J 20, 1. 11-18)", Citation: "J 20, 1. 11-18", PartID: "ewangelia"} + if got := HeadingWithRef(modern, "en"); got != "Gospel (J 20, 1. 11-18)" { + t.Errorf("modern heading = %q", got) + } + // No citation -> unchanged. + if got := HeadingWithRef(liturgy.Section{Heading: "Gospel", PartID: "evangelium"}, "en"); got != "Gospel" { + t.Errorf("no-citation heading = %q", got) + } +} + func TestLocalizeHeading(t *testing.T) { cases := []struct { name, heading, partID, lang, want string |
