MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

omitted columnalign attribute of <mtable> interpreted differently by Firefox

Open hbghlyj opened this issue 3 years ago • 3 comments

(I was using TeX input and native MathML output)

In MathML generated by MathJax, columnalign attribute of <mtable> will be omitted if it is same as that of its parent, while in Firefox, without columnalign specified will be centered (as is the default value).

Consequently, in the cases LL and RR, the MathML generated by MathJax will be interpreted differently by Firefox — MathJax will omit the columnalign attribute of the inner <mtable> which will be interpreted as default value center in Firefox, not as expected L or R.

Test code:

\begin{array}{l}1\\{\begin{array}{l}111\\2\end{array}}\end{array}

image MathML generated by MathJax:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mtable columnalign="left" columnspacing="1em" rowspacing="4pt">
    <mtr>
      <mtd>
        <mn>1</mn>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mrow data-mjx-texclass="ORD">
          <mtable columnspacing="1em" rowspacing="4pt">
            <mtr>
              <mtd>
                <mn>111</mn>
              </mtd>
            </mtr>
            <mtr>
              <mtd>
                <mn>2</mn>
              </mtd>
            </mtr>
          </mtable>
        </mrow>
      </mtd>
    </mtr>
  </mtable>
</math>

Then paste into Mozilla MathML tester: image

hbghlyj avatar Jun 24 '22 01:06 hbghlyj

Thanks for the report. The inheritance is not working correctly. I'll work on a fix for the next release.

dpvc avatar Jun 26 '22 21:06 dpvc

I've made a PR to fix the issue, but for now, you can use

MathJax = {
  startup: {
    ready() {
      const {MmlMtd} = MathJax._.core.MmlTree.MmlNodes.mtd;
      const {MML} = MathJax._.core.MmlTree.MML;
      MML[MmlMtd.prototype.kind] = class extends MmlMtd {
        setChildInheritedAttributes(attributes, display, level, prime) {
          for (const key of ['columnalign', 'rowalign', 'groupalign']) {
            if (attributes.hasOwnProperty(key)) {
              attributes = {...attributes};
              delete attributes[key];
            }
          }
          super.setChildInheritedAttributes(attributes, display, level, prime);
        }
      };
      MathJax.startup.defaultReady();
    }
  }
};

as your configuration in order to work around it until the next release.

dpvc avatar Jun 28 '22 12:06 dpvc

I'm reopening so that this gets properly marked as part of the next release.

dpvc avatar Jun 30 '22 13:06 dpvc