diff --git a/scripts/odf/fillOdtTemplate.js b/scripts/odf/fillOdtTemplate.js index fdf8663..678b9aa 100644 --- a/scripts/odf/fillOdtTemplate.js +++ b/scripts/odf/fillOdtTemplate.js @@ -299,7 +299,7 @@ const elseMarker = '{:else}' const closingIfMarker = '{/if}' const eachStartMarkerRegex = /{#each\s+([^}]+?)\s+as\s+([^}]+?)\s*}/; -const eachClosingBlockMarker = '{/each}' +const eachClosingMarker = '{/each}' @@ -366,7 +366,7 @@ function fillTemplatedOdtElement(rootElement, compartment) { /** * Looking for {/each} */ - const isEachClosingBlock = text.includes(eachClosingBlockMarker) + const isEachClosingBlock = text.includes(eachClosingMarker) if(isEachClosingBlock) { @@ -836,9 +836,11 @@ function fillTemplatedOdtDocument(document, compartment) { ...findAllMatches(fullText, elseMarker), ...findAllMatches(fullText, closingIfMarker), ...findAllMatches(fullText, eachStartMarkerRegex), - ...findAllMatches(fullText, eachClosingBlockMarker) + ...findAllMatches(fullText, eachClosingMarker) ]; + console.log('positionedMarkers', positionedMarkers) + // If no markers found, skip this container if(positionedMarkers.length >= 1) { @@ -995,7 +997,7 @@ function fillTemplatedOdtDocument(document, compartment) { let matchIndex; // looking for a block marker - for(const marker of [ifStartMarkerRegex, elseMarker, closingIfMarker, eachStartMarkerRegex, eachClosingBlockMarker]) { + for(const marker of [ifStartMarkerRegex, elseMarker, closingIfMarker, eachStartMarkerRegex, eachClosingMarker]) { if(typeof marker === 'string') { const index = remainingText.indexOf(marker) diff --git a/tests/fixtures/liste-nombres-avec-formattage.odt b/tests/fixtures/liste-nombres-avec-formattage.odt index 5109986..9b96798 100644 Binary files a/tests/fixtures/liste-nombres-avec-formattage.odt and b/tests/fixtures/liste-nombres-avec-formattage.odt differ