Skip to content

fix(odt): markdown styles no longer shadow common styles of styles.xml - #229

Merged
vaceslav merged 2 commits into
mainfrom
fix/odt-markdown-style-names
Sep 26, 2026
Merged

vaceslav merged 2 commits into
mainfrom
fix/odt-markdown-style-names

Conversation

@vaceslav

Copy link
Copy Markdown
Contributor

Found by the new OdtTextStyles coverage tests and checked in LibreOffice (#138). Markdown creates automatic text styles named T{n}. The name had to be free in the part only (content.xml), but a content.xml span can also reference a common (named) style of styles.xml. When that common style was called T3 (a user character style, or one from another generator), processing added an automatic T3 (bold). LibreOffice resolves the automatic style first, so the existing red T3 text turned bold and lost its character style. After a LibreOffice resave, both spans pointed to one bold style.

Changes

  • OdtTextStyles.ReserveNames holds names that new styles must not take. OdtTemplateEngine.Process reserves the style names of styles.xml's office:styles before processing, and CreateUniqueName skips them.
  • OdtPlaceholderProcessor.Styles exposes the style set to the engine (internal).
  • Automatic styles are still per part: a header style in styles.xml can still be T1 while content.xml has its own T1.
  • Test helper: OdtDocumentBuilder.AddCommonStyles adds common styles to styles.xml.

Tests

  • OdtMarkdownTests.NewStyleName_DoesNotShadowACommonStyleOfStylesXml: common T3 (text style) and T4 (list style). The markdown style becomes T5, and the red span keeps T3 with no automatic style of that name.
  • OdtMarkdownTests.HeaderStyles_MayReuseNamesOfContentStyles.
  • OdtLibreOfficeRoundTripTests.MarkdownStyle_DoesNotShadowACommonStyle_InLibreOffice (LibreOffice trait, local): after a resave, the red text keeps T3 and is not bold, and the markdown text is bold. This check failed before the fix (both spans were T1 bold after the resave).
  • Local runs: Release CI build (0 warnings); TriasDev.Templify.Tests net10/9/8 (2,140 each, LibreOffice round trips included); Tools.Tests 63; Converter.Tests 95; dotnet format --verify-no-changes.

Public API impact

None. Unreleased code (OpenDocument support, 1.9.0). Output changes only for templates with a common style named like the next free T{n}.

A new automatic T{n} style could take the name of a common text style referenced from content.xml, which LibreOffice then rendered with the markdown formatting (#138).
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...riasDev.Templify/OpenDocument/OdtTemplateEngine.cs 80.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@vaceslav
vaceslav merged commit f38af46 into main Sep 26, 2026
12 checks passed
@vaceslav
vaceslav deleted the fix/odt-markdown-style-names branch September 26, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants