Repository navigation
fix(odt): continue list numbering across loop copies, process header/footer regions, drop dead {{#empty}} markers - #223
Merged
Merged
Conversation
…footer regions, drop dead {{#empty}} markers (#138)
- Loop copies of a text:list now continue the numbering of the first copy
(text:continue-list + xml:id), as DOCX does; also across nested loops and in
table-row loops. Other lists are not changed.
- style:region-left/center/right in headers and footers are processed and validated.
- Remove the {{#empty}}/{{/empty}} marker-paragraph checks (feature removed in #190)
from the ODT engine and DocumentWalker.
Found by the independent review of the OpenDocument support.
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #138 (closed), from the independent review of the OpenDocument support.
Problem
text:listof its own) cloned the list once per iteration. Every clone was a separate list, so LibreOffice rendered1. A / 1. B / 1. C, while the same DOCX template renders1. / 2. / 3.. This also affected DOCX templates converted to ODT by LibreOffice (soffice --convert-to odt) and numbered lists in repeated table rows.style:region-left/-center/-rightinsidestyle:header/style:footerwere neither processed nor validated. Placeholders, conditionals and loops in them were left as they were.{{#empty}}handling (LOW).OdtTemplateEngineand the DOCXDocumentWalkerstill treated paragraphs containing{{#empty}}/{{/empty}}as marker paragraphs, although the feature was removed in refactor: dedupe marker text and quote normalization, remove dead internal code (#155) #190.Fix
OdtTemplateEngine.ExpandLoopmarks every clone of a list with the template list it comes from (an in-memoryXObjectannotation, also through nested loops). AfterOdtUniqueNames.EnsureUnique, the newContinueListNumberingstep gives the first copy still in the document anxml:id(it keeps the template's id or gets an unusedtemplify-listN). Every later copy getstext:continue-list="<that id>", and any copiedcontinue-numberingorxml:idis removed from it.continue-list(ODF 1.2) links the copies even when other lists come between them. Only copies of the same source list are linked, so a list after the loop still restarts. Sub-lists (lists inside a list, including list-item loops) are not changed. Nested loops continue across outer iterations, like the sharednumIdin DOCX.style:region-*are containers inOdtTemplateEngine.ProcessBlockand inOdtTemplateValidator.GetChildSequences(newOdfNames.IsHeaderFooterRegion).{{#empty}}/{{/empty}}checks in both engines. Behavior change: a paragraph that contains the literal text{{#empty}}now gets placeholder replacement like any other paragraph. Before, its placeholders were skipped silently.docs/for-template-authors/libreoffice.md: list numbering continues across loop iterations, and header/footer regions are supported.LibreOffice results (headless LibreOffice 26.8, txt export). Paragraph loop with a numbered list, a second list and text between them:
1. A / 2. B / 3. C, and the second list separately1. / 2. / 3.. A list after the loop:1.. Nested loops:1. 2. | 3. 4.. Table-row loop with a numbered list in a cell:1. 2. 3.. For a DOCX template converted by LibreOffice, the ODT output now matches the DOCX output line for line, including nested loops. Note: LibreOffice Writer drops header regions on load, so for regions the round trip only checks that the processed document opens and converts.Tests
OdtLoopTests: 8 new tests covering continuation, generated ids, unrelated and single-iteration lists left alone, a clone removed by a conditional, nested loops, table-row loops, nested sub-lists and list-item loops.OdtContainerTests.HeaderAndFooterRegions_AreProcessedcovers placeholders, a conditional and a loop in regions.OdtValidationTests.HeaderRegions_AreValidatedcovers a syntax error and loop-scope missing variables in regions.OdtPlaceholderTests/DocumentTemplateProcessorEdgeCaseTests: a paragraph with{{#empty}}text is ordinary text (ODT and DOCX).Category=LibreOffice, run locally):NumberedListsInLoops_ContinueTheirNumberingInLibreOffice,DocxConvertedByLibreOffice_ProcessedAsOdt_MatchesDocxProcessing(ported from the review probe, now expects 1/2/3) andHeaderRegions_ProcessedDocumentOpensInLibreOffice.dotnet format --verify-no-changes,dotnet packandmkdocs build --strict.Public API impact: none. There is one behavior change for the edge case of literal
{{#empty}}text, described above.