Centralize antiphon opening-doubling logic across all hours

The same idiom (splitNamedAntiphon + isDoubleOrHigher(...) ? full :
incipit) was copy-pasted at 11 call sites across 8 hour files. Add one
shared openingAntiphon(antiphon, winner) helper in resolve-common.ts
and use it everywhere a psalm/canticle antiphon's opening form is
decided. Pure dedup, no behavior change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F25189JqjXddUhU9hM9nUS
This commit is contained in:
2026-08-24 07:13:38 -04:00
parent f8de318b7f
commit 8f55ec6931
9 changed files with 55 additions and 36 deletions
+14 -1
View File
@@ -6,7 +6,7 @@ import { getSaintRecord } from '../calendar/feasts';
import { resolveActiveOctave, activeOctavesFor, octaveGoverningPrivilegedDay, isAtLeast } from '../calendar';
import { getTemporalFeastRecord } from '../calendar/temporal-feasts';
import { isInTriduum } from '../calendar/temporal';
import { splitAntiphon } from './antiphon';
import { splitAntiphon, isDoubleOrHigher } from './antiphon';
import vespersMagnificatAntiphonsData from '../data/hours/vespers-magnificat-antiphons.yml';
type BilingualText = Partial<Record<string, string>>;
@@ -692,6 +692,19 @@ export function splitNamedAntiphon(antiphon: ResolvedText): {
return { incipit: { text: incipitText, status: incipitStatus }, full: { text: fullText, status: fullStatus } };
}
/** The antiphon actually shown *before* a psalm/canticle: full text on a
* Double-rank winner or higher, incipit only below that (see
* `isDoubleOrHigher`'s own doc comment for the underlying rule) — the one
* idiom every hour's psalmody independently repeated (`splitNamedAntiphon`
* + `isDoubleOrHigher(...) ? full : incipit`) before being centralized
* here. The closing repeat after the psalm/canticle is always `full`,
* unconditionally, at each call site — this helper only decides the
* opening. */
export function openingAntiphon(antiphon: ResolvedText, winner: DayWinner): ResolvedText {
const { incipit, full } = splitNamedAntiphon(antiphon);
return isDoubleOrHigher(winner) ? full : incipit;
}
/** Fixed wording, same as lauds.ts's weekday-canticle Gloria Patri —
* appended after every psalm (hours/index.ts) except during the Sacred
* Triduum. Not "verified" via verifiedText() because it's boilerplate