diff --git a/astro-church-website/src/pages/bulletin.astro b/astro-church-website/src/pages/bulletin.astro index f8486e5..d8e5a35 100644 --- a/astro-church-website/src/pages/bulletin.astro +++ b/astro-church-website/src/pages/bulletin.astro @@ -67,8 +67,9 @@ const parseSabbathSchool = (text) => { let currentKey = ''; lines.forEach(line => { - if (line.includes(':')) { - currentKey = line.replace(':', '').trim(); + // Look for lines that end with a colon followed by optional whitespace + if (line.match(/:\s*$/)) { + currentKey = line.replace(/:.*$/, '').trim(); result[currentKey] = ''; } else if (currentKey && line.trim()) { result[currentKey] = line.trim(); @@ -85,8 +86,9 @@ const parseDivineWorship = (text) => { let currentKey = ''; lines.forEach(line => { - if (line.includes(':')) { - currentKey = line.replace(':', '').trim(); + // Look for lines that end with a colon followed by optional whitespace + if (line.match(/:\s*$/)) { + currentKey = line.replace(/:.*$/, '').trim(); result[currentKey] = ''; } else if (currentKey && line.trim()) { if (result[currentKey]) { @@ -100,6 +102,18 @@ const parseDivineWorship = (text) => { return result; }; +// Helper function to format scripture references +const formatScriptureReading = (text) => { + if (!text) return null; + + // Handle common scripture reference formats + return text + .replace(/([A-Za-z]+)\s*(\d+)(\d{2}):/g, '$1 $2:$3') // Fix Ecclesiastes1214: to Ecclesiastes 12:14 + .replace(/([A-Za-z]+)(\d+):/g, '$1 $2:') // Fix other similar patterns + .replace(/\s+/g, ' ') // Normalize whitespace + .trim(); +}; + const sabbathSchoolInfo = currentBulletin ? parseSabbathSchool(currentBulletin.sabbath_school) : null; const divineWorshipInfo = currentBulletin ? parseDivineWorship(currentBulletin.divine_worship) : null; --- @@ -169,7 +183,7 @@ const divineWorshipInfo = currentBulletin ? parseDivineWorship(currentBulletin.d