mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 12:18:39 +00:00
Correct (type-wise) raisebox's usage of sizing's buildHtml. (#1361)
* Correct (type-wise) raisebox's usage of sizing's buildHtml. * Move HTML and MathML groupTypes into defineFunction. Currently, functions defined in functions/* import all exports from buildHtml and buildMathML, but they should never use `groupTypes` directly as it loses type-safety. They should instead use more type-safe `htmlBuilder`s and `mathmlBuilder`s exported directly from other definitions `functions/*` to allow flow to catch errors. * Rename groupTypes to groupBuilders.
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
import defineFunction, {ordargument} from "../defineFunction";
|
||||
import buildCommon from "../buildCommon";
|
||||
import mathMLTree from "../mathMLTree";
|
||||
import {assertNodeType} from "../ParseNode";
|
||||
import ParseNode, {assertNodeType} from "../ParseNode";
|
||||
import {calculateSize} from "../units";
|
||||
|
||||
import * as html from "../buildHTML";
|
||||
import * as mml from "../buildMathML";
|
||||
import * as sizing from "./sizing";
|
||||
|
||||
// Box manipulation
|
||||
defineFunction({
|
||||
@@ -28,16 +28,17 @@ defineFunction({
|
||||
};
|
||||
},
|
||||
htmlBuilder(group, options) {
|
||||
const body = html.groupTypes.sizing({value: {
|
||||
value: [{
|
||||
type: "text",
|
||||
value: {
|
||||
body: group.value.value,
|
||||
font: "mathrm", // simulate \textrm
|
||||
},
|
||||
}],
|
||||
const text = new ParseNode("text", {
|
||||
type: "text",
|
||||
body: group.value.value,
|
||||
font: "mathrm", // simulate \textrm
|
||||
}, group.mode);
|
||||
const sizedText = new ParseNode("sizing", {
|
||||
type: "sizing",
|
||||
value: [text],
|
||||
size: 6, // simulate \normalsize
|
||||
}}, options);
|
||||
}, group.mode);
|
||||
const body = sizing.htmlBuilder(sizedText, options);
|
||||
const dy = calculateSize(group.value.dy.value, options);
|
||||
return buildCommon.makeVList({
|
||||
positionType: "shift",
|
||||
|
Reference in New Issue
Block a user