Skip to content

feat(odf): sub/superscript, percent line-height, first-line indent#611

Merged
andiwand merged 5 commits into
mainfrom
feat/odf-style-improvements
Jul 16, 2026
Merged

feat(odf): sub/superscript, percent line-height, first-line indent#611
andiwand merged 5 commits into
mainfrom
feat/odf-style-improvements

Conversation

@andiwand

@andiwand andiwand commented Jul 16, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Three low-hanging fruits from the ODF feature checklist (src/odr/internal/odf/README.md):

Superscript / subscript (style:text-position)

New public FontPosition enum and TextStyle::font_position. Both value components are read: the position (super/sub, or a signed percent offset mapped by sign) and the optional relative font size, which scales the inherited size the same way percent fo:font-size already does. The HTML renderer emits vertical-align:super/sub/baseline on the inline x-s spans, so e.g. super 58% on a 12pt base renders as font-size:6.96pt;vertical-align:super;.

Percent line-height

fo:line-height percent values were dropped (// TODO). ODF percent line-height is relative to the font size, which is exactly CSS line-height: % semantics, so it now passes straight through. Percent margins remain dropped since their ODF semantics don't map to CSS.

First-line indent (fo:text-indent)

New ParagraphStyle::text_indent, read from paragraph properties and rendered as text-indent.

Tests

  • Document.odt_text_position on style-various-1.odt (super 58% / sub 58% paragraphs, including the 12pt → 6.96pt scaling)
  • Document.odt_line_height_and_text_indent on file-sample_100kB.odt (line-height:120% inherited via Text_20_body, 0.25in heading indent)
  • All ODF html output tests and the docx suite pass locally (TextStyle and the renderer are shared).

Note on reference outputs

Many odt fixtures use percent line-height, so their rendered output genuinely changes — the visual comparison against test/data/reference-output will need the references regenerated when this lands.

- style:text-position: new public FontPosition enum + TextStyle::font_position;
  both value components are read - the position ("super"/"sub" or a signed
  percent offset) and the optional relative font size, which scales the
  inherited size like percent font-size does. Rendered as vertical-align.
- fo:line-height: percent values were dropped; they are relative to the font
  size, matching CSS line-height semantics, so they now pass through.
  Percent margins remain dropped.
- fo:text-indent: new ParagraphStyle::text_indent, rendered as text-indent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KH4XvPFfdUvH7HMp8rmqZT

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 423c35174d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/odr/internal/odf/odf_style.cpp
Comment thread src/odr/internal/html/document_style.cpp Outdated
andiwand and others added 3 commits July 16, 2026 21:20
Addresses review feedback on #611: a CSS percentage line-height on the
x-p block resolves against the block's (inherited) font size, while the
document text font size is emitted on nested x-s spans. A unitless ratio
inherits per element and recomputes against each element's own font
size, matching ODF percent line-height semantics.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AEvWWwe1EyeWH7ANHoAvPH
Regenerated after the sub/superscript, percent line-height (now emitted
as a unitless ratio), and first-line indent changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AEvWWwe1EyeWH7ANHoAvPH
@andiwand
andiwand enabled auto-merge (squash) July 16, 2026 19:55
@andiwand
andiwand merged commit ca4d7b1 into main Jul 16, 2026
11 checks passed
@andiwand
andiwand deleted the feat/odf-style-improvements branch July 16, 2026 20:55
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.

1 participant