Skip to content

fix: inline formulas render inside HTML table cells - #1373

Open
gennaroprota wants to merge 1 commit into
cppalliance:developfrom
gennaroprota:fix/tables_keep_their_inline_formulas
Open

gennaroprota wants to merge 1 commit into
cppalliance:developfrom
gennaroprota:fix/tables_keep_their_inline_formulas

Conversation

@gennaroprota

Copy link
Copy Markdown
Collaborator

An HTML table with a @f$...@f$ formula in a cell was dropped with "HTML

tag not followed by
". Clang models the formula as a verbatim block command, so it ends the paragraph it appears in, and the table parser looks for </table> within one paragraph. A Markdown formula ($...$) kept the table but stayed plain text, because the doc comment traversal never entered table cells.

Changes

  • Source: a paragraph is now visited together with the \f$ formulas and paragraph remainders that continue it (no blank line between), so the table parser sees the whole table and each formula becomes an inline node of its cell. This replaces merging the pieces after the fact, which also appended a paragraph starting with a formula to the paragraph before it, across a blank line. The traversal descends into table cells, so their Markdown is parsed and their references are resolved. The AsciiDoc table template escapes | in a cell, which a formula such as \max(|x|, |y|) would otherwise use to end it.
  • Golden tests: new javadoc/html-table/html-table-math fixture (XML and AsciiDoc). No existing golden changes.

Testing

The new fixture covers the reported table, a Markdown formula in a cell, and paragraphs that start with a formula after a blank line. I checked with Asciidoctor.js that its AsciiDoc table parses into the intended rows and cells.

Documentation

Not needed: the documented behavior of tables and formulas now holds.

Fixes #1370.

Clang models a `\f$...\f$` formula as a verbatim block command, so the
formula ends the paragraph it appears in and the text after it starts a
new one. An HTML table with such a formula in a cell was therefore
spread over several paragraphs, and the table parser, which looks for
`</table>` within one paragraph, warned that the tag was never closed
and dropped the table. A Markdown formula (`$...$`) did not split the
table, but it came out as plain text, because the traversal that parses
inline Markdown never entered table cells.

We now gather a paragraph together with the formulas and paragraph
remainders that continue it, with no blank line between, before visiting
it. The table parser then sees the whole table, and each formula becomes
an inline node of its cell. This replaces merging the pieces after the
fact, which ignored a blank line before a formula and appended a
paragraph that starts with one to the paragraph before it. The traversal
now descends into table cells, so their Markdown is parsed and their
references are resolved.

The AsciiDoc generator emits a formula verbatim, so a `|` in one, as in
`\max(|x|, |y|)`, ended the cell. The table template now escapes it.

Fixes cppalliance#1370.
@github-actions

Copy link
Copy Markdown
Contributor

✨ Highlights

  • 🧪 New golden tests added

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🥇 Golden Tests 59% 280 280 - 4 4 - - -
🛠️ Source 41% 192 134 58 3 - 3 - -
Total 100% 472 414 58 7 4 3 - -

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • tests/golden/fixtures/javadoc/html-table/html-table-math.xml (Golden Tests): 213 lines Δ (+213 / -0)
  • src/mrdocs/AST/ExtractDocComment.cpp (Source): 161 lines Δ (+104 / -57)
  • tests/golden/fixtures/javadoc/html-table/html-table-math.adoc (Golden Tests): 50 lines Δ (+50 / -0)

Generated by 🚫 dangerJS against 426601c

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.21%. Comparing base (6f92577) to head (426601c).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1373   +/-   ##
========================================
  Coverage    83.21%   83.21%           
========================================
  Files           35       35           
  Lines         3670     3670           
  Branches       845      845           
========================================
  Hits          3054     3054           
  Misses         410      410           
  Partials       206      206           
Flag Coverage Δ
bootstrap 83.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1373.mrdocs.prtest2.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-10-30 16:24:43 UTC

This branch has not been deployed

No deployments
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.

Table generation fails if it contains LaTeX formula

2 participants