Skip to content

Fixes data-latex content for Table Rows#1528

Open
zorkow wants to merge 2 commits into
developfrom
fix/table_latex
Open

Fixes data-latex content for Table Rows#1528
zorkow wants to merge 2 commits into
developfrom
fix/table_latex

Conversation

@zorkow

@zorkow zorkow commented Jul 12, 2026

Copy link
Copy Markdown
Member

Rows in Tables did not get a meaningful data-latex attribute. E.g., for \begin{array}{c}a\end{array} we got data-latex="{c}".
This PR fixes this by explicitly collecting the LaTeX elements and then adding them to the final node, combined with &.

@zorkow zorkow requested a review from dpvc July 12, 2026 08:07
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.47%. Comparing base (05c4055) to head (1d90849).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##           develop    #1528     +/-   ##
==========================================
  Coverage    86.47%   86.47%             
==========================================
  Files          340      340             
  Lines        86178    86224     +46     
  Branches      4856     3218   -1638     
==========================================
+ Hits         74520    74566     +46     
  Misses       11658    11658             

☔ 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.

@dpvc dpvc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a big improvement, but there still seem to be some issues. Those are probably actually problems with the attributes of the child nodes in many cases. Perhaps they can be improved? (I haven't looked into the problem, but it may be due to modifying the parser.string value for substitutions.)

"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\begin{numcases}{f(x)=} 1 &amp; if $x &gt; 0$ \\\\ 0 &amp; otherwise \\end{numcases}" display="block">
<mtable columnalign="right left left left" columnspacing="0em 1em" rowspacing=".2em" data-break-align="top top top" data-latex="\\begin{numcases}{f(x)=} 1 &amp; if $x &gt; 0$ \\\\ 0 &amp; otherwise \\end{numcases}">
<mlabeledtr data-latex="{f(x)=}">
<mlabeledtr data-latex="1&amp;&amp;">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The result here is a bit strange. The second column is blank (probably because numcases is handling the text-mode material internally), but the second &amp; is wrong. Is this due to the mlabeledtr having an extra child for the tag?

The same is true for all the other tests as well.

<mtable columnalign="right left left left" columnspacing="0em 1em" rowspacing=".2em" data-break-align="top top top" data-latex="\\begin{numcases}{f(x)=} 1 &amp; if $x &gt; 0$ \\\\ 0 &amp; otherwise \\end{numcases}">
<mlabeledtr data-latex="{f(x)=}">
<mlabeledtr data-latex="1&amp;&amp;">
<mtd id="mjx-eqn:1">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this mtd have a data-latex attribute for the tag?

"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\begin{array}{cc} a &amp; \\cellcolor{red} b \\\\ \\cellcolor{yellow} c &amp; d \\end{array}" display="block">
<mtable columnspacing="1em" rowspacing="4pt" columnalign="center center" data-frame-styles="" framespacing=".5em .125em" data-latex="\\begin{array}{cc} a &amp; \\cellcolor{red} b \\\\ \\cellcolor{yellow} c &amp; d \\end{array}">
<mtr data-latex="{cc}">
<mtr data-latex="a&amp;b">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is missing the \cellcolor{red} before the b. Can that be captured as well?

</mtd>
</mtr>
<mtr data-latex="{cc}">
<mtr data-latex="c&amp;d">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similarly, \cellcolor{yellow} is missing before c.

"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\begin{array}{cc} a &amp; b \\cellcolor{red} \\end{array}" display="block">
<mtable columnspacing="1em" rowspacing="4pt" columnalign="center center" data-frame-styles="" framespacing=".5em .125em" data-latex="\\begin{array}{cc} a &amp; b \\cellcolor{red} \\end{array}">
<mtr data-latex="{cc}">
<mtr data-latex="a&amp;\\cellcolor{red}">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here you capture \cellcolor{red} but missing the preceding b. Of course, that is probably due to the b being missing from the data-latex attribute of the mi at line 73 below.

"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\newenvironment{boxed}{\\begin{array}{|c|c|}\\hline}{\\\\\\hline\\end{array}}\\begin{boxed}\\begin{boxed}a&amp;b\\\\c&amp;d\\end{boxed} &amp; X \\end{boxed}" display="block">
<mtable columnspacing="1em" rowspacing="4pt" columnalign="center center" columnlines="solid" framespacing=".5em .125em" frame="solid" data-latex="{array}">
<mtr data-latex="{|c|c|}">
<mtr data-latex="{array}&amp;X">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The {array} doesn't seem right, here.

"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\begin{align}a=b\\label{A}\\\\ c&amp;=d \\label{B}\\end{align}" display="block">
<mtable displaystyle="true" columnalign="right left" columnspacing="0em" rowspacing="3pt" data-break-align="bottom top" data-latex="\\begin{align}a=b\\label{A}\\\\ c&amp;=d \\label{B}\\end{align}">
<mlabeledtr>
<mlabeledtr data-latex="a=\\label{A}">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The b is missing before the \label, here. Similarly in the tests below.

"<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\begin{CD}A @&gt;a&gt;&gt; B\\\\@VVbV @VVcV\\\\C @&gt;d&gt;&gt; D\\end{CD}" display="block">
<mtable columnspacing="5pt" rowspacing="5pt" displaystyle="true" data-latex="\\begin{CD}A @&gt;a&gt;&gt; B\\\\@VVbV @VVcV\\\\C @&gt;d&gt;&gt; D\\end{CD}">
<mtr>
<mtr data-latex="A&amp;&amp;B">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm wondering if the blank column can capture the arrows somehow. These are constructed as raw MathML, so that may be hard to get.

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