mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 22:18:41 +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.
|
* Simpler types come at the beginning, while complicated types come afterwards.
|
||||||
*/
|
*/
|
||||||
export const groupTypes = {
|
export const groupTypes = {
|
||||||
ordgroup: (group, options) => makeSpan(
|
|
||||||
["mord"], buildExpression(group.value, options, true), options),
|
|
||||||
|
|
||||||
supsub(group, options) {
|
supsub(group, options) {
|
||||||
// Superscript and subscripts are handled in the TeXbook on page
|
// Superscript and subscripts are handled in the TeXbook on page
|
||||||
// 445-446, rules 18(a-f).
|
// 445-446, rules 18(a-f).
|
||||||
|
@@ -79,10 +79,6 @@ export const getVariant = function(group, options) {
|
|||||||
*/
|
*/
|
||||||
export const groupTypes = {};
|
export const groupTypes = {};
|
||||||
|
|
||||||
groupTypes.ordgroup = function(group, options) {
|
|
||||||
return buildExpressionRow(group.value, options);
|
|
||||||
};
|
|
||||||
|
|
||||||
groupTypes.supsub = function(group, options) {
|
groupTypes.supsub = function(group, options) {
|
||||||
// Is the inner group a relevant horizonal brace?
|
// Is the inner group a relevant horizonal brace?
|
||||||
let isBrace = false;
|
let isBrace = false;
|
||||||
@@ -140,21 +136,6 @@ groupTypes.supsub = function(group, options) {
|
|||||||
return node;
|
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
|
* Takes a list of nodes, builds them, and returns a list of the generated
|
||||||
* MathML nodes. Also combine consecutive <mtext> outputs into a single
|
* MathML nodes. Also combine consecutive <mtext> outputs into a single
|
||||||
|
@@ -210,7 +210,7 @@ export function defineFunctionBuilders<NODETYPE: NodeType>({
|
|||||||
type, htmlBuilder, mathmlBuilder,
|
type, htmlBuilder, mathmlBuilder,
|
||||||
}: {|
|
}: {|
|
||||||
type: NODETYPE,
|
type: NODETYPE,
|
||||||
htmlBuilder: HtmlBuilder<NODETYPE>,
|
htmlBuilder?: HtmlBuilder<NODETYPE>,
|
||||||
mathmlBuilder: MathMLBuilder<NODETYPE>,
|
mathmlBuilder: MathMLBuilder<NODETYPE>,
|
||||||
|}) {
|
|}) {
|
||||||
defineFunction({
|
defineFunction({
|
||||||
|
@@ -27,6 +27,7 @@ import "./functions/mclass";
|
|||||||
import "./functions/mod";
|
import "./functions/mod";
|
||||||
import "./functions/op";
|
import "./functions/op";
|
||||||
import "./functions/operatorname";
|
import "./functions/operatorname";
|
||||||
|
import "./functions/ordgroup";
|
||||||
import "./functions/overline";
|
import "./functions/overline";
|
||||||
import "./functions/phantom";
|
import "./functions/phantom";
|
||||||
import "./functions/raisebox";
|
import "./functions/raisebox";
|
||||||
@@ -38,6 +39,7 @@ import "./functions/styling";
|
|||||||
import "./functions/symbolsOp";
|
import "./functions/symbolsOp";
|
||||||
import "./functions/symbolsOrd";
|
import "./functions/symbolsOrd";
|
||||||
import "./functions/symbolsSpacing";
|
import "./functions/symbolsSpacing";
|
||||||
|
import "./functions/tag";
|
||||||
import "./functions/text";
|
import "./functions/text";
|
||||||
import "./functions/underline";
|
import "./functions/underline";
|
||||||
import "./functions/verb";
|
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" |
|
"mtext" | "mn" | "mo" | "mi" | "mspace" |
|
||||||
"mover" | "munder" | "munderover" | "msup" | "msub" |
|
"mover" | "munder" | "munderover" | "msup" | "msub" |
|
||||||
"mfrac" | "mroot" | "msqrt" |
|
"mfrac" | "mroot" | "msqrt" |
|
||||||
"mtable" | "mtr" | "mtd" |
|
"mtable" | "mtr" | "mtd" | "mlabeledtr" |
|
||||||
"mrow" | "menclose" |
|
"mrow" | "menclose" |
|
||||||
"mstyle" | "mpadded" | "mphantom";
|
"mstyle" | "mpadded" | "mphantom";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user