summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gen-sanctoral.go47
1 files changed, 42 insertions, 5 deletions
diff --git a/scripts/gen-sanctoral.go b/scripts/gen-sanctoral.go
index 6d81d66..db2e490 100644
--- a/scripts/gen-sanctoral.go
+++ b/scripts/gen-sanctoral.go
@@ -61,11 +61,32 @@ func fetchMonth(cal string, y, m int) ([]calDay, error) {
}
var (
- rankMap = map[string]calendar.Rank{"solemnity": calendar.RankSolemnity, "feast": calendar.RankFeast, "memorial": calendar.RankMemorial, "optional memorial": calendar.RankOptional}
+ // "commemoration" is calapi's rank for a saint reduced to a commemoration by a
+ // privileged season (Lent, late Advent, the Christmas octave). Such a saint is
+ // never the observed day, so it maps to an optional memorial for lectio; its
+ // true (higher) rank is recovered from a year where its date is an ordinary
+ // weekday (see rankBand + the highest-rank-wins merge below).
+ rankMap = map[string]calendar.Rank{"solemnity": calendar.RankSolemnity, "feast": calendar.RankFeast, "memorial": calendar.RankMemorial, "optional memorial": calendar.RankOptional, "commemoration": calendar.RankOptional}
slugStripRe = regexp.MustCompile(`[^a-z0-9]+`)
plPrefixRe = regexp.MustCompile(`^(?:Uroczystość|Święto|Wspomnienie(?: obowiązkowe)?)\s+`)
)
+// rankBand orders OF ranks for the highest-rank-wins merge (higher = higher rank).
+func rankBand(r calendar.Rank) int {
+ switch r {
+ case calendar.RankSolemnity:
+ return 5
+ case calendar.RankFeast:
+ return 4
+ case calendar.RankMemorial:
+ return 3
+ case calendar.RankOptional:
+ return 2
+ default:
+ return 0
+ }
+}
+
func slugify(title string) string {
s := strings.ToLower(title)
s = strings.NewReplacer("ł", "l", "æ", "ae", "é", "e", "è", "e", "ô", "o", "ç", "c").Replace(s)
@@ -121,9 +142,13 @@ func main() {
"the-memorial-of-the-blessed-virgin-mary-on-saturday": true, // any free Saturday
}
- // Reference years: cover every weekday so a saint whose date is a Sunday in
- // one year is captured in another. 2025 is past -> niedziela gives pl names.
- for _, y := range []int{2025, 2026, 2027} {
+ // Reference years: enough spread that every fixed date falls on an ordinary
+ // weekday (not a Sunday, not inside a privileged season) in at least one year,
+ // so each saint is seen with its true rank. Start at 2025 (past -> niedziela
+ // gives pl names; also the date of a transferred feast is taken from the first
+ // year it is observed, and 2025 observes Joseph/Annunciation on their proper
+ // fixed dates).
+ for _, y := range []int{2025, 2026, 2027, 2028, 2029} {
for m := 1; m <= 12; m++ {
en, err := fetchMonth("general-en", y, m)
if err != nil {
@@ -167,7 +192,19 @@ func main() {
if slug == "" || movableSkip[slug] {
continue
}
- if _, seen := entries[slug]; seen {
+ // Highest-rank-wins: a saint seen as a commemoration in a
+ // privileged season one year and as its full rank on an ordinary
+ // weekday another year keeps the higher rank. Date/name/pl are
+ // kept from the first (proper-date) occurrence; rank/colour/class
+ // are upgraded.
+ if cur, seen := entries[slug]; seen {
+ if rankBand(rk) > rankBand(calendar.Rank(cur.rank)) {
+ cur.rank = string(rk)
+ cur.colour = c.Colour
+ cur.class = classOf(c.Title)
+ cur.rankNum = c.RankNum
+ entries[slug] = cur
+ }
continue
}
laTitle := ""