Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/buildHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ groupTypes.ordgroup = function(group, options) {
};

groupTypes.text = function(group, options) {
const newOptions = options.withFont(group.value.style);
const newOptions = options.withFont(group.value.font);
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.

Calling withFont with a font makes more sense.

const inner = buildExpression(group.value.body, newOptions, true);
for (let i = 0; i < inner.length - 1; i++) {
if (inner[i].tryCombine(inner[i + 1])) {
Expand Down Expand Up @@ -1631,6 +1631,24 @@ groupTypes.mclass = function(group, options) {
return makeSpan([group.value.mclass], elements, options);
};

groupTypes.raisebox = function(group, options) {
const body = groupTypes.sizing({value: {
value: [{
type: "text",
value: {
body: group.value.body,
font: "mathrm", // simulate \textrm
},
}],
size: 6, // simulate \normalsize
}}, options);
const dy = units.calculateSize(group.value.dy.value, options);
return buildCommon.makeVList([{
type: "elem",
elem: body,
}], "shift", -dy, options);
};

/**
* buildGroup is the function that takes a group and calls the correct groupType
* function for it. It also handles the interaction of size and style changes
Expand Down
4 changes: 4 additions & 0 deletions src/buildMathML.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ 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;
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.

👍


/**
* Takes a list of nodes, builds them, and returns a list of the generated
* MathML nodes. A little simpler than the HTML version because we don't do any
Expand Down
19 changes: 17 additions & 2 deletions src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defineFunction("\\sqrt", {
});

// Non-mathy text, possibly in a font
const textFunctionStyles = {
const textFunctionFonts = {
"\\text": undefined, "\\textrm": "mathrm", "\\textsf": "mathsf",
"\\texttt": "mathtt", "\\textnormal": "mathrm", "\\textbf": "mathbf",
"\\textit": "textit",
Expand All @@ -51,7 +51,7 @@ defineFunction([
return {
type: "text",
body: ordargument(body),
style: textFunctionStyles[context.funcName],
font: textFunctionFonts[context.funcName],
};
});

Expand Down Expand Up @@ -650,3 +650,18 @@ defineFunction(["\\begin", "\\end"], {
nameGroup: nameGroup,
};
});

// Box manipulation
defineFunction(["\\raisebox"], {
numArgs: 2,
argTypes: ["size", "text"],
allowedInText: true,
}, function(context, args) {
const amount = args[0];
const body = args[1];
return {
type: "raisebox",
dy: amount,
body: ordargument(body),
};
});
Binary file added test/screenshotter/images/Raisebox-chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/screenshotter/images/Raisebox-firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/screenshotter/ss_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ OverUnderset: |
Phantom: \dfrac{1+\phantom{x^{\blue{2}}} = x}{1+x^{\blue{2}} = x} \left(\vphantom{\int_t} zzz \right) \left( X \hphantom{\frac{\frac X X}{X}} \right)
PrimeSpacing: f'+f_2'+f^{f'}
PrimeSuper: x'^2+x'''^2+x'^2_3+x_3'^2
Raisebox: \frac{a}{a\raisebox{0.5em}{b}} \cdot \frac{a\raisebox{-0.5em}{b}}{a} \cdot \sqrt{a\raisebox{0.5em}{b}} \cdot \sqrt{a\raisebox{-0.5em}{b}} \cdot \sqrt{a\raisebox{0.5em}{b}\raisebox{-0.5em}{b}}
RelativeUnits: |
\begin{array}{ll}
a\kern1emb^{a\kern1emb^{a\kern1emb}} &
Expand Down