mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 11:48:41 +00:00
Improve MathML for \tag (#1915)
* Improve MathML for \tag * Make a duplicate pad * Add TODO * Add semi-colon
This commit is contained in:
@@ -4,21 +4,37 @@ import mathMLTree from "../mathMLTree";
|
||||
|
||||
import * as mml from "../buildMathML";
|
||||
|
||||
const pad = () => {
|
||||
const padNode = new mathMLTree.MathNode("mtd", []);
|
||||
padNode.setAttribute("width", "50%");
|
||||
return padNode;
|
||||
};
|
||||
|
||||
defineFunctionBuilders({
|
||||
type: "tag",
|
||||
mathmlBuilder(group, options) {
|
||||
const table = new mathMLTree.MathNode("mtable", [
|
||||
new mathMLTree.MathNode("mlabeledtr", [
|
||||
new mathMLTree.MathNode("mtd", [
|
||||
mml.buildExpressionRow(group.tag, options),
|
||||
]),
|
||||
new mathMLTree.MathNode("mtr", [
|
||||
pad(),
|
||||
new mathMLTree.MathNode("mtd", [
|
||||
mml.buildExpressionRow(group.body, options),
|
||||
]),
|
||||
pad(),
|
||||
new mathMLTree.MathNode("mtd", [
|
||||
mml.buildExpressionRow(group.tag, options),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
table.setAttribute("side", "right");
|
||||
table.setAttribute("width", "100%");
|
||||
return table;
|
||||
|
||||
// TODO: Left-aligned tags.
|
||||
// Currently, the group and options passed here do not contain
|
||||
// enough info to set tag alignment. `leqno` is in Settings but it is
|
||||
// not passed to Options. On the HTML side, leqno is
|
||||
// set by a CSS class applied in buildTree.js. That would have worked
|
||||
// in MathML if browsers supported <mlabeledtr>. Since they don't, we
|
||||
// need to rewrite the way this function is called.
|
||||
},
|
||||
});
|
||||
|
||||
|
@@ -774,12 +774,9 @@ exports[`A MathML builder tags use <mlabeledtr> 1`] = `
|
||||
|
||||
<math>
|
||||
<semantics>
|
||||
<mtable side="right">
|
||||
<mlabeledtr>
|
||||
<mtd>
|
||||
<mtext>
|
||||
(hi)
|
||||
</mtext>
|
||||
<mtable width="100%">
|
||||
<mtr>
|
||||
<mtd width="50%">
|
||||
</mtd>
|
||||
<mtd>
|
||||
<mrow>
|
||||
@@ -799,7 +796,14 @@ exports[`A MathML builder tags use <mlabeledtr> 1`] = `
|
||||
</msup>
|
||||
</mrow>
|
||||
</mtd>
|
||||
</mlabeledtr>
|
||||
<mtd width="50%">
|
||||
</mtd>
|
||||
<mtd>
|
||||
<mtext>
|
||||
(hi)
|
||||
</mtext>
|
||||
</mtd>
|
||||
</mtr>
|
||||
</mtable>
|
||||
<annotation encoding="application/x-tex">
|
||||
\\tag{hi} x+y^2
|
||||
|
Reference in New Issue
Block a user