diff options
Diffstat (limited to 'internal/readings')
| -rw-r--r-- | internal/readings/readings.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/readings/readings.go b/internal/readings/readings.go index 047e901..49c9adc 100644 --- a/internal/readings/readings.go +++ b/internal/readings/readings.go @@ -57,6 +57,31 @@ func Load(cfg config.Config, opts Options) ([]liturgy.Section, liturgy.DayInfo, return filterParts(secs, cfg, opts.All), info, nil } +// GospelCitation returns the gospel's scripture reference from loaded sections: +// the section tagged "ewangelia" (modern) or "evangelium" (traditional), else +// the first section; preferring its Citation, else the reference parsed from its +// heading. Used by the month-calendar export (and mirrors the CLI helper). +func GospelCitation(secs []liturgy.Section) string { + pick := func(s liturgy.Section) string { + if s.Citation != "" { + return s.Citation + } + if c, err := liturgy.ExtractCitation(s.Heading); err == nil { + return c + } + return "" + } + for _, s := range secs { + if s.PartID == "ewangelia" || s.PartID == "evangelium" { + return pick(s) + } + } + if len(secs) > 0 { + return pick(secs[0]) + } + return "" +} + // filterParts keeps only the gospel when !all (PartID "ewangelia" modern or // "evangelium" traditional). When all and the lectionary is traditional, it // keeps only the scripture readings (isTraditionalReading) -- dropping |
