mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 19:28:39 +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: [{
|
||||
type: "text",
|
||||
value: {
|
||||
body: group.value.body,
|
||||
body: group.value.value,
|
||||
font: "mathrm", // simulate \textrm
|
||||
},
|
||||
}],
|
||||
|
@@ -604,9 +604,13 @@ groupTypes.mclass = function(group, options) {
|
||||
return new mathMLTree.MathNode("mstyle", inner);
|
||||
};
|
||||
|
||||
// Transforms (translation/rotation) don't seem to have a representation
|
||||
// in MathML, so just treat them like \text{...}
|
||||
groupTypes.raisebox = groupTypes.text;
|
||||
groupTypes.raisebox = function(group, options) {
|
||||
const node = new mathMLTree.MathNode(
|
||||
"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
|
||||
|
@@ -673,6 +673,7 @@ defineFunction(["\\raisebox"], {
|
||||
return {
|
||||
type: "raisebox",
|
||||
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`] = `
|
||||
|
||||
<math>
|
||||
|
@@ -50,4 +50,8 @@ describe("A MathML builder", function() {
|
||||
it('should use <msupsub> for regular operators', () => {
|
||||
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