diff --git a/frontend/script.js b/frontend/script.js index 042bf6c..bb7722b 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -1058,13 +1058,27 @@ function updateLiedblatt() { const stropheDiv = document.createElement('div'); stropheDiv.classList.add('strophe'); - // Entferne alle
Tags aus dem Strophentext und füge die Nummer am Anfang hinzu - const strophenText = strophen[index].replace(/<\/?p>/g, '').trim(); + // Ersetze
Tags durch
Tags und entferne die schließenden
/g, '').replace(/<\/p>/g, '
');
- // Füge einen Zeilenumbruch nach jeder Strophe hinzu, außer nach der letzten
- const lineBreak = arrayIndex < selectedStrophen.length - 1 ? '
${index + 1}. ${strophenText}${lineBreak}
`; + // Erstelle den erstenTag mit der Nummerierung und dem ersten Teil der Strophe + const pElementWithNumber = document.createElement('p'); + pElementWithNumber.innerHTML = `${index + 1}. ${strophenTextArray[0]}`; + stropheDiv.appendChild(pElementWithNumber); + + // Füge die restlichen Teile des Strophentexts in eigene
Tags ein + for (let i = 1; i < strophenTextArray.length; i++) { + if (strophenTextArray[i].trim() !== '') { + const pElement = document.createElement('p'); + pElement.textContent = strophenTextArray[i]; + stropheDiv.appendChild(pElement); + } + } + + // Füge das stropheDiv zum content hinzu content.appendChild(stropheDiv); }); } @@ -2175,9 +2189,9 @@ async function generatePDF(format) { for (const element of elements) { // Überspringe leere Paragraphen und zusätzliche leere Paragraphen nach Strophen - if (element.tagName === 'P' && element.textContent.trim() === '' && !element.closest('.strophe')) { - continue; - } +// if (element.tagName === 'div' && element.textContent.trim() === '' && !element.closest('.strophe')) { +// continue; +// } // Überspringe alleinstehende Strophennummern if (element.tagName === 'STRONG' && /^\d+\.$/.test(element.textContent.trim())) { @@ -2213,14 +2227,13 @@ async function generatePDF(format) { }; // Strophen-Nummerierung hinzufügen - let textContent = element.innerText; - if (element.tagName === 'P' && element.closest('.lied, .liturgie')) { - if (element.classList.contains('strophe') || element.closest('.strophe')) { - strophenCounter++; - textContent = `${strophenCounter}. ${textContent.replace(/^\d+\.\s*/, '')}`; - lastElementWasStrophe = true; - } - } + let textContent = element.innerText; +// if (element.classList.contains('strophe') || element.closest('.strophe')) { +// strophenCounter++; +// textContent = `${strophenCounter}. ${textContent.replace(/^\d+\.\s*/, '')}`; +// lastElementWasStrophe = true; +// } + // Wenn das vorherige Element eine Überschrift oder Copyright war, verringern wir den Abstand if (lastElementType === 'heading' && isCopyright) {