mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-09 21:18:40 +00:00
Move "ordgroup" and "tag" builders into functions/*. (#1339)
* Move "ordgroup" builders to functions/ordgroup.js. * Move "tag" MathML builder to functions/tag.js.
This commit is contained in:
@@ -242,9 +242,6 @@ export const makeNullDelimiter = function(options, classes) {
|
||||
* Simpler types come at the beginning, while complicated types come afterwards.
|
||||
*/
|
||||
export const groupTypes = {
|
||||
ordgroup: (group, options) => makeSpan(
|
||||
["mord"], buildExpression(group.value, options, true), options),
|
||||
|
||||
supsub(group, options) {
|
||||
// Superscript and subscripts are handled in the TeXbook on page
|
||||
// 445-446, rules 18(a-f).
|
||||
|
@@ -79,10 +79,6 @@ export const getVariant = function(group, options) {
|
||||
*/
|
||||
export const groupTypes = {};
|
||||
|
||||
groupTypes.ordgroup = function(group, options) {
|
||||
return buildExpressionRow(group.value, options);
|
||||
};
|
||||
|
||||
groupTypes.supsub = function(group, options) {
|
||||
// Is the inner group a relevant horizonal brace?
|
||||
let isBrace = false;
|
||||
@@ -140,21 +136,6 @@ groupTypes.supsub = function(group, options) {
|
||||
return node;
|
||||
};
|
||||
|
||||
groupTypes.tag = function(group, options) {
|
||||
const table = new mathMLTree.MathNode("mtable", [
|
||||
new mathMLTree.MathNode("mlabeledtr", [
|
||||
new mathMLTree.MathNode("mtd", [
|
||||
buildExpressionRow(group.value.tag, options),
|
||||
]),
|
||||
new mathMLTree.MathNode("mtd", [
|
||||
buildExpressionRow(group.value.body, options),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
table.setAttribute("side", "right");
|
||||
return table;
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a list of nodes, builds them, and returns a list of the generated
|
||||
* MathML nodes. Also combine consecutive <mtext> outputs into a single
|
||||
|
@@ -210,7 +210,7 @@ export function defineFunctionBuilders<NODETYPE: NodeType>({
|
||||
type, htmlBuilder, mathmlBuilder,
|
||||
}: {|
|
||||
type: NODETYPE,
|
||||
htmlBuilder: HtmlBuilder<NODETYPE>,
|
||||
htmlBuilder?: HtmlBuilder<NODETYPE>,
|
||||
mathmlBuilder: MathMLBuilder<NODETYPE>,
|
||||
|}) {
|
||||
defineFunction({
|
||||
|
@@ -27,6 +27,7 @@ import "./functions/mclass";
|
||||
import "./functions/mod";
|
||||
import "./functions/op";
|
||||
import "./functions/operatorname";
|
||||
import "./functions/ordgroup";
|
||||
import "./functions/overline";
|
||||
import "./functions/phantom";
|
||||
import "./functions/raisebox";
|
||||
@@ -38,6 +39,7 @@ import "./functions/styling";
|
||||
import "./functions/symbolsOp";
|
||||
import "./functions/symbolsOrd";
|
||||
import "./functions/symbolsSpacing";
|
||||
import "./functions/tag";
|
||||
import "./functions/text";
|
||||
import "./functions/underline";
|
||||
import "./functions/verb";
|
||||
|
18
src/functions/ordgroup.js
Normal file
18
src/functions/ordgroup.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// @flow
|
||||
import {defineFunctionBuilders} from "../defineFunction";
|
||||
import buildCommon from "../buildCommon";
|
||||
|
||||
import * as html from "../buildHTML";
|
||||
import * as mml from "../buildMathML";
|
||||
|
||||
defineFunctionBuilders({
|
||||
type: "ordgroup",
|
||||
htmlBuilder(group, options) {
|
||||
return buildCommon.makeSpan(
|
||||
["mord"], html.buildExpression(group.value, options, true), options);
|
||||
},
|
||||
mathmlBuilder(group, options) {
|
||||
return mml.buildExpressionRow(group.value, options);
|
||||
},
|
||||
});
|
||||
|
24
src/functions/tag.js
Normal file
24
src/functions/tag.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// @flow
|
||||
import {defineFunctionBuilders} from "../defineFunction";
|
||||
import mathMLTree from "../mathMLTree";
|
||||
|
||||
import * as mml from "../buildMathML";
|
||||
|
||||
defineFunctionBuilders({
|
||||
type: "tag",
|
||||
mathmlBuilder(group, options) {
|
||||
const table = new mathMLTree.MathNode("mtable", [
|
||||
new mathMLTree.MathNode("mlabeledtr", [
|
||||
new mathMLTree.MathNode("mtd", [
|
||||
mml.buildExpressionRow(group.value.tag, options),
|
||||
]),
|
||||
new mathMLTree.MathNode("mtd", [
|
||||
mml.buildExpressionRow(group.value.body, options),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
table.setAttribute("side", "right");
|
||||
return table;
|
||||
},
|
||||
});
|
||||
|
@@ -20,7 +20,7 @@ export type MathNodeType =
|
||||
"mtext" | "mn" | "mo" | "mi" | "mspace" |
|
||||
"mover" | "munder" | "munderover" | "msup" | "msub" |
|
||||
"mfrac" | "mroot" | "msqrt" |
|
||||
"mtable" | "mtr" | "mtd" |
|
||||
"mtable" | "mtr" | "mtd" | "mlabeledtr" |
|
||||
"mrow" | "menclose" |
|
||||
"mstyle" | "mpadded" | "mphantom";
|
||||
|
||||
|
Reference in New Issue
Block a user