diff --git a/controllers/worshipController.js b/controllers/worshipController.js index 70e4a5c..e8651bd 100644 --- a/controllers/worshipController.js +++ b/controllers/worshipController.js @@ -1825,7 +1825,7 @@ function getSection(lines, startPredicate, endPredicates = []) { return lines.slice(start, end); } -function normalizeText(input) { +function normalizeForMatch(input) { return String(input || '') .toLowerCase() .replace(/ä/g, 'ae') @@ -1837,8 +1837,8 @@ function normalizeText(input) { } function isHeading(line, heading) { - const normalizedLine = normalizeText(line).replace(/[:\-–]\s*$/g, ''); - const normalizedHeading = normalizeText(heading).replace(/[:\-–]\s*$/g, ''); + const normalizedLine = normalizeForMatch(line).replace(/[:\-–]\s*$/g, ''); + const normalizedHeading = normalizeForMatch(heading).replace(/[:\-–]\s*$/g, ''); return ( normalizedLine === normalizedHeading || normalizedLine.startsWith(`${normalizedHeading} `) || @@ -1902,7 +1902,7 @@ function buildDetailedItems(lines) { }; const expandedLines = lines.flatMap(splitForYouthAnchors); const isHardSectionBoundary = (line) => { - const n = normalizeText(line); + const n = normalizeForMatch(line); if (!n) return false; return ( n.startsWith('besondere gottesdienste und veranstaltungen') || @@ -1987,7 +1987,7 @@ function buildDetailedItems(lines) { } function isNoiseLine(line) { - const n = normalizeText(line); + const n = normalizeForMatch(line); return ( n.includes('impressum') || n.includes('redaktionsschluss') || @@ -2064,7 +2064,7 @@ function extractRegularTermineDetails(lines) { const seen = new Set(); const isAnchorLine = (line) => anchors.some((r) => r.test(line)); const isSubHeadingLike = (line) => { - const t = normalizeText(line); + const t = normalizeForMatch(line); return ( /^kinder und jugendliche$/.test(t) || /^kinder und jugend$/.test(t) || @@ -2120,7 +2120,7 @@ function isLikelyDayNameLine(line) { if (!line) return false; if (hasDateOrTime(line)) return false; if (looksLikeHeading(line)) return false; - const t = normalizeText(line); + const t = normalizeForMatch(line); return ( /advent|trinitatis|epiphanias|ostern|pfingsten|sonntag|montag|dienstag|mittwoch|donnerstag|freitag|samstag/.test(t) && t.length < 80 @@ -2229,7 +2229,7 @@ function extractWorshipBlocks(lines) { } function buildEventSignature(line) { - const text = normalizeText(line); + const text = normalizeForMatch(line); const anchorPatterns = [ /kinderkirche/, /kigosabo|kindergottesdienst/,