Skip to content

OpenDocument/ODT writer: use predefined styles.#11672

Merged
jgm merged 1 commit into
mainfrom
odt_styles
May 27, 2026
Merged

OpenDocument/ODT writer: use predefined styles.#11672
jgm merged 1 commit into
mainfrom
odt_styles

Conversation

@jgm
Copy link
Copy Markdown
Owner

@jgm jgm commented May 27, 2026

Previously the OpenDocument writer emitted a fresh automatic style (L1..Ln, P1..Pn, T1..Tn) for nearly every list, list-item paragraph, block quote, preformatted block, and inline text style. This produced large ODT files, made --reference-doc customization ineffective (the user's predefined styles were never referenced), and gave each list its own indentation independent of any containing block quote.

This commit teaches the writer to reference the predefined styles that LibreOffice ships and that pandoc's reference.odt now exports:

  • Bullet lists use List_20_1; ordered lists with default start and decimal format use Numbering_20_1. Non-default ordered lists generate a single named override style (Pandoc_Numbering_N) memoised by (ListNumberStyle, ListNumberDelim); a non-default start value with the default format is expressed via text:start-value on the text:list element instead of a new style.
  • List-item paragraphs use List_20_Bullet[_Tight] and List_20_Number[_Tight]. The Tight variants are pandoc-specific (zero top/bottom margin) and are injected into the user's reference.odt if missing, just like the Skylighting token styles.
  • Block quotes use the predefined Quotations paragraph style directly. Nested block quotes use a single automatic style that inherits from Quotations and only adds extra margin-left, so a list inside a block quote now inherits its container's indent (ODF output Blockquotes should not have a non-style indent applied #2747).
  • Preformatted blocks use Preformatted_20_Text directly.
  • Emphasis, Strong, Strikeout, Subscript, Superscript and Code spans use the predefined Emphasis, Strong_20_Emphasis, Strikeout, Subscript, Superscript and Source_20_Text text styles.
  • paraStyle/paraStyleFromParent no longer emit a wrapper automatic style when its only attribute would be parent-style-name; the parent name is returned directly.

Closes #9136.
Closes #5086.
Closes #2747.
Closes #3426.
Closes #7336.

Co-authored by: Claude Opus 4.7.

Previously the OpenDocument writer emitted a fresh automatic style
(L1..Ln, P1..Pn, T1..Tn) for nearly every list, list-item paragraph,
block quote, preformatted block, and inline text style.  This produced
large ODT files, made `--reference-doc` customization ineffective (the
user's predefined styles were never referenced), and gave each list its
own indentation independent of any containing block quote.

This commit teaches the writer to reference the predefined styles that
LibreOffice ships and that pandoc's reference.odt now exports:

- Bullet lists use `List_20_1`; ordered lists with default start and
  decimal format use `Numbering_20_1`.  Non-default ordered lists
  generate a single named override style (`Pandoc_Numbering_N`)
  memoised by (ListNumberStyle, ListNumberDelim); a non-default start
  value with the default format is expressed via `text:start-value`
  on the `text:list` element instead of a new style.
- List-item paragraphs use `List_20_Bullet[_Tight]` and
  `List_20_Number[_Tight]`.  The Tight variants are pandoc-specific
  (zero top/bottom margin) and are injected into the user's
  reference.odt if missing, just like the Skylighting token styles.
- Block quotes use the predefined `Quotations` paragraph style
  directly.  Nested block quotes use a single automatic style that
  inherits from Quotations and only adds extra margin-left, so a list
  inside a block quote now inherits its container's indent (#2747).
- Preformatted blocks use `Preformatted_20_Text` directly.
- Emphasis, Strong, Strikeout, Subscript, Superscript and Code spans
  use the predefined `Emphasis`, `Strong_20_Emphasis`, `Strikeout`,
  `Subscript`, `Superscript` and `Source_20_Text` text styles.
- `paraStyle`/`paraStyleFromParent` no longer emit a wrapper automatic
  style when its only attribute would be `parent-style-name`; the
  parent name is returned directly.

Closes #9136.
Closes #5086.
Closes #2747.
Closes #3426.
Closes #7336.

Co-authored by: Claude Opus 4.7.
@jgm jgm merged commit 1c7cfb2 into main May 27, 2026
7 of 10 checks passed
@jgm jgm deleted the odt_styles branch May 27, 2026 16:10
smc181002 pushed a commit to smc181002/pandoc that referenced this pull request May 29, 2026
Previously the OpenDocument writer emitted a fresh automatic style
(L1..Ln, P1..Pn, T1..Tn) for nearly every list, list-item paragraph,
block quote, preformatted block, and inline text style.  This produced
large ODT files, made `--reference-doc` customization ineffective (the
user's predefined styles were never referenced), and gave each list its
own indentation independent of any containing block quote.

This commit teaches the writer to reference the predefined styles that
LibreOffice ships and that pandoc's reference.odt now exports:

- Bullet lists use `List_20_1`; ordered lists with default start and
  decimal format use `Numbering_20_1`.  Non-default ordered lists
  generate a single named override style (`Pandoc_Numbering_N`)
  memoised by (ListNumberStyle, ListNumberDelim); a non-default start
  value with the default format is expressed via `text:start-value`
  on the `text:list` element instead of a new style.
- List-item paragraphs use `List_20_Bullet[_Tight]` and
  `List_20_Number[_Tight]`.  The Tight variants are pandoc-specific
  (zero top/bottom margin) and are injected into the user's
  reference.odt if missing, just like the Skylighting token styles.
- Block quotes use the predefined `Quotations` paragraph style
  directly.  Nested block quotes use a single automatic style that
  inherits from Quotations and only adds extra margin-left, so a list
  inside a block quote now inherits its container's indent (jgm#2747).
- Preformatted blocks use `Preformatted_20_Text` directly.
- Emphasis, Strong, Strikeout, Subscript, Superscript and Code spans
  use the predefined `Emphasis`, `Strong_20_Emphasis`, `Strikeout`,
  `Subscript`, `Superscript` and `Source_20_Text` text styles.
- `paraStyle`/`paraStyleFromParent` no longer emit a wrapper automatic
  style when its only attribute would be `parent-style-name`; the
  parent name is returned directly.

Closes jgm#9136.
Closes jgm#5086.
Closes jgm#2747.
Closes jgm#3426.
Closes jgm#7336.

Co-authored by: Claude Opus 4.7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment