Skip to content

fix: preserve superscripts and subscripts in Markdown export - #802

Closed
cau-git wants to merge 1 commit into
mainfrom
codex/preserve-markdown-scripts
Closed

cau-git wants to merge 1 commit into
mainfrom
codex/preserve-markdown-scripts

Conversation

@cau-git

@cau-git cau-git commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Ensures that markdown is output with <sup> or <sub> tags wrapping superscript or subscript.

@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @cau-git, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require two reviewer for test updates 👀 reviews
🟢 Enforce conventional commit —

🔴 Require two reviewer for test updates

Waiting for

  • #approved-reviews-by >= 2
This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cau-git
cau-git requested review from ceberam and vagenas and removed request for vagenas September 29, 2026 19:34
@ceberam

ceberam commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

This may be a duplicate of #661 . If I remember correctly, the main reason that #661 was not yet merged (or even properly reviewed) had to do with a key decision: whether the Markdown serializer/backend in Docling should emit/parse HTML tags in Markdown. Not all Markdown applications support HTML tags in Markdown documents and the rule of thumb was to stick to the basic and extended syntax (e.g., write This **word** is bold instead of This <b>word</b> is bold).
Just FYI, the MarkdownDocumentBackend ignores the inline HTML tags. It has no handler, so the tags themselves are ignored and the enclosed text is captured as plain text without formatting. The exceptions are block-level HTML elements like <div> or <table, which trigger the HTML backend.

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working serialization Output serializers: Markdown, HTML, LaTeX, JSON, plain-text, outline labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 3a3f47ec1b. The analysis read the diff only. It did not run code from this pull request.

The Markdown serializer now wraps subscript text in <sub> tags and superscript text in <sup> tags. The plain-text serializer keeps these as plain text. A new test file covers both cases, in and out of tables.

Topic labels added: bug, serialization.

CI safety: no concern found. A maintainer must still approve CI.

1 related pull request(s) in the same code
PR State Signal Assessment
#720 open changes the same code related: Both PRs edit markdown.py, but in different places. PR 720 adds optional YAML front matter and changes serialize_doc. This PR adds serialize_subscript and serialize_superscript.

Reference data changes

Change Files
text 12
  • text tests/data/doc/constructed_doc.embedded.md.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.placeholder.md.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.referenced.md.gt: +1 / -1 lines
  • text tests/data/doc/constructed_document.yaml.md: +1 / -1 lines
  • text tests/data/doc/constructed_legacy_annot_mark_false.gt.md: +1 / -1 lines
  • text tests/data/doc/constructed_legacy_annot_mark_true.gt.md: +1 / -1 lines
  • text tests/data/doc/constructed_mode_always_valid_false.gt.md: +1 / -1 lines
  • text tests/data/doc/constructed_mode_always_valid_true.gt.md: +1 / -1 lines
  • text tests/data/doc/constructed_mode_auto_valid_false.gt.md: +1 / -1 lines
  • text tests/data/doc/constructed_mode_auto_valid_true.gt.md: +1 / -1 lines
  • text tests/data/doc/constructed_mode_never_valid_false.gt.md: +1 / -1 lines
  • text tests/data/doc/constructed_mode_never_valid_true.gt.md: +1 / -1 lines

Assessment: expected. Each of the 12 files changes by one line. In the base file constructed_mode_auto_valid_true.gt.md, the formatting line shows "subscript superscript" as plain text. The new serialize_subscript and serialize_superscript methods wrap that text in <sub> and <sup> tags. The PR description matches this change.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@PeterStaar-IBM

Copy link
Copy Markdown
Member

duplicate of #661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working serialization Output serializers: Markdown, HTML, LaTeX, JSON, plain-text, outline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants