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:
Ashish Myles
2018-05-27 03:24:30 -04:00
committed by ylemkimon
parent d9fe716d0e
commit 9cde0336d3
6 changed files with 50 additions and 44 deletions

View File

@@ -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",