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
- 11:00 AM - 12:15 PM + 11:00 AM
{divineWorshipInfo && Object.entries(divineWorshipInfo).map(([key, value]) => (
@@ -199,7 +213,7 @@ const divineWorshipInfo = currentBulletin ? parseDivineWorship(currentBulletin.d

Scripture Reading

- {currentBulletin.scripture_reading} + {formatScriptureReading(currentBulletin.scripture_reading) || currentBulletin.scripture_reading}
)} diff --git a/astro-church-website/src/pages/bulletin/[id].astro b/astro-church-website/src/pages/bulletin/[id].astro index 9f77cba..7683074 100644 --- a/astro-church-website/src/pages/bulletin/[id].astro +++ b/astro-church-website/src/pages/bulletin/[id].astro @@ -42,8 +42,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(); @@ -60,8 +61,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]) { @@ -75,6 +77,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 = bulletin ? parseSabbathSchool(bulletin.sabbath_school) : null; const divineWorshipInfo = bulletin ? parseDivineWorship(bulletin.divine_worship) : null; const displayDate = bulletin ? formatBulletinDate(bulletin.date) : ''; @@ -166,7 +180,7 @@ const displayDate = bulletin ? formatBulletinDate(bulletin.date) : '';
- 11:00 AM - 12:15 PM + 11:00 AM
{divineWorshipInfo && Object.entries(divineWorshipInfo).map(([key, value]) => (
@@ -196,7 +210,7 @@ const displayDate = bulletin ? formatBulletinDate(bulletin.date) : '';

Scripture Reading

- {bulletin.scripture_reading} + {formatScriptureReading(bulletin.scripture_reading) || bulletin.scripture_reading}
)}