mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 05:58:40 +00:00
Use mpadded for \raisebox MathML (#876)
* Use mpadded for \raisebox MathML * Add MathML snapshot
This commit is contained in:
@@ -1640,7 +1640,7 @@ groupTypes.raisebox = function(group, options) {
|
|||||||
value: [{
|
value: [{
|
||||||
type: "text",
|
type: "text",
|
||||||
value: {
|
value: {
|
||||||
body: group.value.body,
|
body: group.value.value,
|
||||||
font: "mathrm", // simulate \textrm
|
font: "mathrm", // simulate \textrm
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
@@ -604,9 +604,13 @@ groupTypes.mclass = function(group, options) {
|
|||||||
return new mathMLTree.MathNode("mstyle", inner);
|
return new mathMLTree.MathNode("mstyle", inner);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Transforms (translation/rotation) don't seem to have a representation
|
groupTypes.raisebox = function(group, options) {
|
||||||
// in MathML, so just treat them like \text{...}
|
const node = new mathMLTree.MathNode(
|
||||||
groupTypes.raisebox = groupTypes.text;
|
"mpadded", [buildGroup(group.value.body, options)]);
|
||||||
|
const dy = group.value.dy.value.number + group.value.dy.value.unit;
|
||||||
|
node.setAttribute("voffset", dy);
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes a list of nodes, builds them, and returns a list of the generated
|
* Takes a list of nodes, builds them, and returns a list of the generated
|
||||||
|
@@ -673,6 +673,7 @@ defineFunction(["\\raisebox"], {
|
|||||||
return {
|
return {
|
||||||
type: "raisebox",
|
type: "raisebox",
|
||||||
dy: amount,
|
dy: amount,
|
||||||
body: ordargument(body),
|
body: body,
|
||||||
|
value: ordargument(body),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@@ -74,6 +74,27 @@ exports[`A MathML builder should make prime operators into <mo> nodes 1`] = `
|
|||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`A MathML builder should use <mpadded> for raisebox 1`] = `
|
||||||
|
|
||||||
|
<math>
|
||||||
|
<semantics>
|
||||||
|
<mrow>
|
||||||
|
<mpadded voffset="0.25em">
|
||||||
|
<mrow>
|
||||||
|
<mtext>
|
||||||
|
b
|
||||||
|
</mtext>
|
||||||
|
</mrow>
|
||||||
|
</mpadded>
|
||||||
|
</mrow>
|
||||||
|
<annotation encoding="application/x-tex">
|
||||||
|
\\raisebox{0.25em}{b}
|
||||||
|
</annotation>
|
||||||
|
</semantics>
|
||||||
|
</math>
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`A MathML builder should use <msupsub> for regular operators 1`] = `
|
exports[`A MathML builder should use <msupsub> for regular operators 1`] = `
|
||||||
|
|
||||||
<math>
|
<math>
|
||||||
|
@@ -50,4 +50,8 @@ describe("A MathML builder", function() {
|
|||||||
it('should use <msupsub> for regular operators', () => {
|
it('should use <msupsub> for regular operators', () => {
|
||||||
expect(getMathML("\\textstyle\\sum_a^b")).toMatchSnapshot();
|
expect(getMathML("\\textstyle\\sum_a^b")).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use <mpadded> for raisebox', () => {
|
||||||
|
expect(getMathML("\\raisebox{0.25em}{b}")).toMatchSnapshot();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user