diff --git a/src/Parser.js b/src/Parser.js index 75ffad22..e43a8a2a 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -313,7 +313,7 @@ export default class Parser { const textordArray = []; for (let i = 0; i < text.length; i++) { - textordArray.push({type: "textord", mode: "text", value: text[i]}); + textordArray.push({type: "textord", mode: "text", text: text[i]}); } const textNode = { @@ -387,7 +387,7 @@ export default class Parser { if (superscript) { throw new ParseError("Double superscript", lex); } - const prime = {type: "textord", mode: this.mode, value: "\\prime"}; + const prime = {type: "textord", mode: this.mode, text: "\\prime"}; // Many primes can be grouped together, so we handle this here const primes = [prime]; @@ -750,7 +750,7 @@ export default class Parser { return newArgument({ type: "color-token", mode: this.mode, - value: match[0], + color: match[0], }, res); } @@ -859,15 +859,15 @@ export default class Parser { let n = group.length - 1; for (let i = 0; i < n; ++i) { const a = group[i]; - // $FlowFixMe: Not every node type has a `value` property. - const v = a.value; - if (v === "-" && group[i + 1].value === "-") { - if (i + 1 < n && group[i + 2].value === "-") { + // $FlowFixMe: Not every node type has a `text` property. + const v = a.text; + if (v === "-" && group[i + 1].text === "-") { + if (i + 1 < n && group[i + 2].text === "-") { group.splice(i, 3, { type: "textord", mode: "text", loc: SourceLocation.range(a, group[i + 2]), - value: "---", + text: "---", }); n -= 2; } else { @@ -875,17 +875,17 @@ export default class Parser { type: "textord", mode: "text", loc: SourceLocation.range(a, group[i + 1]), - value: "--", + text: "--", }); n -= 1; } } - if ((v === "'" || v === "`") && group[i + 1].value === v) { + if ((v === "'" || v === "`") && group[i + 1].text === v) { group.splice(i, 2, { type: "textord", mode: "text", loc: SourceLocation.range(a, group[i + 1]), - value: v + v, + text: v + v, }); n -= 1; } @@ -1016,7 +1016,7 @@ export default class Parser { mode: this.mode, family, loc, - value: text, + text, }; } else { // $FlowFixMe @@ -1024,7 +1024,7 @@ export default class Parser { type: group, mode: this.mode, loc, - value: text, + text, }; } symbol = s; @@ -1044,7 +1044,7 @@ export default class Parser { type: "textord", mode: this.mode, loc: SourceLocation.range(nucleus), - value: text, + text, }; } else { return null; // EOF, ^, _, {, }, etc. diff --git a/src/buildCommon.js b/src/buildCommon.js index 410544ce..5ba78f4c 100644 --- a/src/buildCommon.js +++ b/src/buildCommon.js @@ -237,28 +237,28 @@ const makeOrd = function( type: "mathord" | "textord", ): HtmlDocumentFragment | domTree.symbolNode { const mode = group.mode; - const value = group.value; + const text = group.text; const classes = ["mord"]; // Math mode or Old font (i.e. \rm) const isFont = mode === "math" || (mode === "text" && options.font); const fontOrFamily = isFont ? options.font : options.fontFamily; - if (value.charCodeAt(0) === 0xD835) { + if (text.charCodeAt(0) === 0xD835) { // surrogate pairs get special treatment - const [wideFontName, wideFontClass] = wideCharacterFont(value, mode); - return makeSymbol(value, wideFontName, mode, options, + const [wideFontName, wideFontClass] = wideCharacterFont(text, mode); + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); } else if (fontOrFamily) { let fontName; let fontClasses; if (fontOrFamily === "boldsymbol") { - const fontData = boldsymbol(value, mode, options, classes); + const fontData = boldsymbol(text, mode, options, classes); fontName = fontData.fontName; fontClasses = [fontData.fontClass]; } else if (fontOrFamily === "mathit" || - utils.contains(mainitLetters, value)) { - const fontData = mathit(value, mode, options, classes); + utils.contains(mainitLetters, text)) { + const fontData = mathit(text, mode, options, classes); fontName = fontData.fontName; fontClasses = [fontData.fontClass]; } else if (isFont) { @@ -270,23 +270,23 @@ const makeOrd = function( fontClasses = [fontOrFamily, options.fontWeight, options.fontShape]; } - if (lookupSymbol(value, fontName, mode).metrics) { - return makeSymbol(value, fontName, mode, options, + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); - } else if (ligatures.hasOwnProperty(value) && + } else if (ligatures.hasOwnProperty(text) && fontName.substr(0, 10) === "Typewriter") { // Deconstruct ligatures in monospace fonts (\texttt, \tt). const parts = []; - for (let i = 0; i < value.length; i++) { - parts.push(makeSymbol(value[i], fontName, mode, options, + for (let i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); } return makeFragment(parts); } else { - return mathDefault(value, mode, options, classes, type); + return mathDefault(text, mode, options, classes, type); } } else { - return mathDefault(value, mode, options, classes, type); + return mathDefault(text, mode, options, classes, type); } }; diff --git a/src/buildMathML.js b/src/buildMathML.js index dddb05bd..124ce974 100644 --- a/src/buildMathML.js +++ b/src/buildMathML.js @@ -96,17 +96,17 @@ export const getVariant = function( return "bold-italic"; } - let value = group.value; - if (utils.contains(["\\imath", "\\jmath"], value)) { + let text = group.text; + if (utils.contains(["\\imath", "\\jmath"], text)) { return null; } - if (symbols[mode][value] && symbols[mode][value].replace) { - value = symbols[mode][value].replace; + if (symbols[mode][text] && symbols[mode][text].replace) { + text = symbols[mode][text].replace; } const fontName = buildCommon.fontMap[font].fontName; - if (getCharacterMetrics(value, fontName, mode)) { + if (getCharacterMetrics(text, fontName, mode)) { return buildCommon.fontMap[font].variant; } diff --git a/src/defineFunction.js b/src/defineFunction.js index a07efdc0..65d8f269 100644 --- a/src/defineFunction.js +++ b/src/defineFunction.js @@ -104,13 +104,8 @@ type FunctionDefSpec = {| // Properties that control how the functions are parsed. props: FunctionPropSpec, - // The handler is called to handle these functions and their arguments. - // The function should return an object with the following keys: - // - type: The type of element that this is. This is then used in - // buildHTML/buildMathML to determine which function - // should be called to build this node into a DOM node - // Any other data can be added to the object, which will be passed - // in to the function in buildHTML/buildMathML as `group.value`. + // The handler is called to handle these functions and their arguments and + // returns a `ParseNode`. handler: ?FunctionHandler, // This function returns an object representing the DOM structure to be diff --git a/src/domTree.js b/src/domTree.js index 450bac9c..d39a13f9 100644 --- a/src/domTree.js +++ b/src/domTree.js @@ -266,7 +266,7 @@ const iCombinations = { * whether it has CSS classes, styles, or needs italic correction. */ class symbolNode implements HtmlDomNode { - value: string; + text: string; height: number; depth: number; italic: number; @@ -277,7 +277,7 @@ class symbolNode implements HtmlDomNode { style: CssStyle; constructor( - value: string, + text: string, height?: number, depth?: number, italic?: number, @@ -286,7 +286,7 @@ class symbolNode implements HtmlDomNode { classes?: string[], style?: CssStyle, ) { - this.value = value; + this.text = text; this.height = height || 0; this.depth = depth || 0; this.italic = italic || 0; @@ -303,13 +303,13 @@ class symbolNode implements HtmlDomNode { // We use CSS class names like cjk_fallback, hangul_fallback and // brahmic_fallback. See ./unicodeScripts.js for the set of possible // script names - const script = scriptFromCodepoint(this.value.charCodeAt(0)); + const script = scriptFromCodepoint(this.text.charCodeAt(0)); if (script) { this.classes.push(script + "_fallback"); } - if (/[îïíì]/.test(this.value)) { // add ī when we add Extended Latin - this.value = iCombinations[this.value]; + if (/[îïíì]/.test(this.text)) { // add ī when we add Extended Latin + this.text = iCombinations[this.text]; } } @@ -338,7 +338,7 @@ class symbolNode implements HtmlDomNode { return false; } } - this.value += sibling.value; + this.text += sibling.text; this.height = Math.max(this.height, sibling.height); this.depth = Math.max(this.depth, sibling.depth); this.italic = sibling.italic; @@ -350,7 +350,7 @@ class symbolNode implements HtmlDomNode { * created if it is needed. */ toNode(): Node { - const node = document.createTextNode(this.value); + const node = document.createTextNode(this.text); let span = null; if (this.italic > 0) { @@ -412,7 +412,7 @@ class symbolNode implements HtmlDomNode { markup += " style=\"" + utils.escape(styles) + "\""; } - const escaped = utils.escape(this.value); + const escaped = utils.escape(this.text); if (needsSpan) { markup += ">"; markup += escaped; diff --git a/src/environments/array.js b/src/environments/array.js index 42d2f2cf..7aed466f 100644 --- a/src/environments/array.js +++ b/src/environments/array.js @@ -407,7 +407,7 @@ const alignedHandler = function(context, args) { let arg0 = ""; for (let i = 0; i < ordgroup.value.length; i++) { const textord = assertNodeType(ordgroup.value[i], "textord"); - arg0 += textord.value; + arg0 += textord.text; } numMaths = Number(arg0); numCols = numMaths * 2; @@ -474,7 +474,7 @@ defineEnvironment({ symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").value; const cols = colalign.map(function(nde) { const node = assertSymbolNodeType(nde); - const ca = node.value; + const ca = node.text; if ("lcr".indexOf(ca) !== -1) { return { type: "align", diff --git a/src/functions/char.js b/src/functions/char.js index da1197d2..3cd610fd 100644 --- a/src/functions/char.js +++ b/src/functions/char.js @@ -19,7 +19,7 @@ defineFunction({ let number = ""; for (let i = 0; i < group.length; i++) { const node = assertNodeType(group[i], "textord"); - number += node.value; + number += node.text; } const code = parseInt(number); if (isNaN(code)) { @@ -28,7 +28,7 @@ defineFunction({ return { type: "textord", mode: parser.mode, - value: String.fromCharCode(code), + text: String.fromCharCode(code), }; }, }); diff --git a/src/functions/color.js b/src/functions/color.js index 197569fc..0cfc24a9 100644 --- a/src/functions/color.js +++ b/src/functions/color.js @@ -41,12 +41,12 @@ defineFunction({ argTypes: ["color", "original"], }, handler({parser}, args) { - const color = assertNodeType(args[0], "color-token"); + const color = assertNodeType(args[0], "color-token").color; const body = args[1]; return { type: "color", mode: parser.mode, - color: color.value, + color, body: ordargument(body), }; }, @@ -100,7 +100,7 @@ defineFunction({ argTypes: ["color"], }, handler({parser, breakOnTokenText}, args) { - const color = assertNodeType(args[0], "color-token"); + const color = assertNodeType(args[0], "color-token").color; // If we see a styling function, parse out the implicit body const body = parser.parseExpression(true, breakOnTokenText); @@ -108,7 +108,7 @@ defineFunction({ return { type: "color", mode: parser.mode, - color: color.value, + color, body, }; }, diff --git a/src/functions/delimsizing.js b/src/functions/delimsizing.js index 47e7d7b1..2c078860 100644 --- a/src/functions/delimsizing.js +++ b/src/functions/delimsizing.js @@ -59,13 +59,13 @@ function checkDelimiter( context: FunctionContext, ): SymbolParseNode { const symDelim = checkSymbolNodeType(delim); - if (symDelim && utils.contains(delimiters, symDelim.value)) { + if (symDelim && utils.contains(delimiters, symDelim.text)) { return symDelim; } else { throw new ParseError( "Invalid delimiter: '" + // $FlowFixMe, do not polyfill - (symDelim ? symDelim.value : JSON["stringify"](delim)) + + (symDelim ? symDelim.text : JSON["stringify"](delim)) + "' after '" + context.funcName + "'", delim); } } @@ -89,7 +89,7 @@ defineFunction({ mode: context.parser.mode, size: delimiterSizes[context.funcName].size, mclass: delimiterSizes[context.funcName].mclass, - delim: delim.value, + delim: delim.text, }; }, htmlBuilder: (group, options) => { @@ -148,7 +148,7 @@ defineFunction({ return { type: "leftright-right", mode: context.parser.mode, - delim: checkDelimiter(args[0], context).value, + delim: checkDelimiter(args[0], context).text, }; }, }); @@ -179,7 +179,7 @@ defineFunction({ type: "leftright", mode: parser.mode, body, - left: delim.value, + left: delim.text, right: assertNodeType(right, "leftright-right").delim, }; }, @@ -298,7 +298,7 @@ defineFunction({ return { type: "middle", mode: context.parser.mode, - delim: delim.value, + delim: delim.text, }; }, htmlBuilder: (group, options) => { diff --git a/src/functions/enclose.js b/src/functions/enclose.js index 04c2e482..487ebf2d 100644 --- a/src/functions/enclose.js +++ b/src/functions/enclose.js @@ -55,9 +55,9 @@ const htmlBuilder = (group, options) => { imgShift = inner.depth + vertPad; if (group.backgroundColor) { - img.style.backgroundColor = group.backgroundColor.value; + img.style.backgroundColor = group.backgroundColor; if (group.borderColor) { - img.style.borderColor = group.borderColor.value; + img.style.borderColor = group.borderColor; } } } @@ -132,7 +132,7 @@ const mathmlBuilder = (group, options) => { break; } if (group.backgroundColor) { - node.setAttribute("mathbackground", group.backgroundColor.value); + node.setAttribute("mathbackground", group.backgroundColor); } return node; }; @@ -147,7 +147,7 @@ defineFunction({ argTypes: ["color", "text"], }, handler({parser, funcName}, args, optArgs) { - const color = assertNodeType(args[0], "color-token"); + const color = assertNodeType(args[0], "color-token").color; const body = args[1]; return { type: "enclose", @@ -171,15 +171,15 @@ defineFunction({ argTypes: ["color", "color", "text"], }, handler({parser, funcName}, args, optArgs) { - const borderColor = assertNodeType(args[0], "color-token"); - const backgroundColor = assertNodeType(args[1], "color-token"); + const borderColor = assertNodeType(args[0], "color-token").color; + const backgroundColor = assertNodeType(args[1], "color-token").color; const body = args[2]; return { type: "enclose", mode: parser.mode, label: funcName, - backgroundColor: backgroundColor, - borderColor: borderColor, + backgroundColor, + borderColor, body, }; }, diff --git a/src/functions/environment.js b/src/functions/environment.js index d8077b26..e9b09e1e 100644 --- a/src/functions/environment.js +++ b/src/functions/environment.js @@ -19,7 +19,7 @@ defineFunction({ } let name = ""; for (let i = 0; i < nameGroup.value.length; ++i) { - name += assertNodeType(nameGroup.value[i], "textord").value; + name += assertNodeType(nameGroup.value[i], "textord").text; } return { type: "environment", diff --git a/src/functions/genfrac.js b/src/functions/genfrac.js index 65473462..6a1e6d46 100644 --- a/src/functions/genfrac.js +++ b/src/functions/genfrac.js @@ -369,7 +369,7 @@ defineFunction({ } else { leftNode = assertAtomFamily(args[0], "open"); } - const leftDelim = delimFromValue(leftNode.value); + const leftDelim = delimFromValue(leftNode.text); let rightNode = checkNodeType(args[1], "ordgroup"); if (rightNode) { @@ -377,7 +377,7 @@ defineFunction({ } else { rightNode = assertAtomFamily(args[1], "close"); } - const rightDelim = delimFromValue(rightNode.value); + const rightDelim = delimFromValue(rightNode.text); const barNode = assertNodeType(args[2], "size"); let hasBarLine; @@ -398,11 +398,11 @@ defineFunction({ if (styl) { if (styl.value.length > 0) { const textOrd = assertNodeType(styl.value[0], "textord"); - size = stylArray[Number(textOrd.value)]; + size = stylArray[Number(textOrd.text)]; } } else { styl = assertNodeType(args[3], "textord"); - size = stylArray[Number(styl.value)]; + size = stylArray[Number(styl.text)]; } return { diff --git a/src/functions/href.js b/src/functions/href.js index 28b9f6a0..697de3ea 100644 --- a/src/functions/href.js +++ b/src/functions/href.js @@ -56,7 +56,7 @@ defineFunction({ chars.push({ type: "textord", mode: "text", - value: c, + text: c, }); } const body = { diff --git a/src/functions/operatorname.js b/src/functions/operatorname.js index 36e27b73..5764ed94 100644 --- a/src/functions/operatorname.js +++ b/src/functions/operatorname.js @@ -27,13 +27,13 @@ defineFunction({ htmlBuilder: (group, options) => { if (group.body.length > 0) { const body = group.body.map(child => { - // $FlowFixMe: Check if the node has a string `value` property. - const childValue = child.value; - if (typeof childValue === "string") { + // $FlowFixMe: Check if the node has a string `text` property. + const childText = child.text; + if (typeof childText === "string") { return { type: "textord", mode: child.mode, - value: childValue, + text: childText, }; } else { return child; @@ -49,7 +49,7 @@ defineFunction({ if (child instanceof domTree.symbolNode) { // Per amsopn package, // change minus to hyphen and \ast to asterisk - child.value = child.value.replace(/\u2212/, "-") + child.text = child.text.replace(/\u2212/, "-") .replace(/\u2217/, "*"); } } diff --git a/src/functions/smash.js b/src/functions/smash.js index 793efdcf..ac112cd8 100644 --- a/src/functions/smash.js +++ b/src/functions/smash.js @@ -27,8 +27,8 @@ defineFunction({ let letter = ""; for (let i = 0; i < tbArg.value.length; ++i) { const node = tbArg.value[i]; - // $FlowFixMe: Not every node type has a `value` property. - letter = node.value; + // $FlowFixMe: Not every node type has a `text` property. + letter = node.text; if (letter === "t") { smashHeight = true; } else if (letter === "b") { diff --git a/src/functions/symbolsOp.js b/src/functions/symbolsOp.js index 79f685ed..78d6ff2f 100644 --- a/src/functions/symbolsOp.js +++ b/src/functions/symbolsOp.js @@ -11,11 +11,11 @@ defineFunctionBuilders({ type: "atom", htmlBuilder(group, options) { return buildCommon.mathsym( - group.value, group.mode, options, ["m" + group.family]); + group.text, group.mode, options, ["m" + group.family]); }, mathmlBuilder(group, options) { const node = new mathMLTree.MathNode( - "mo", [mml.makeText(group.value, group.mode)]); + "mo", [mml.makeText(group.text, group.mode)]); if (group.family === "bin") { const variant = mml.getVariant(group, options); if (variant === "bold-italic") { diff --git a/src/functions/symbolsOrd.js b/src/functions/symbolsOrd.js index 1f3e78cf..0121f84f 100644 --- a/src/functions/symbolsOrd.js +++ b/src/functions/symbolsOrd.js @@ -24,7 +24,7 @@ defineFunctionBuilders({ mathmlBuilder(group: ParseNode<"mathord">, options) { const node = new mathMLTree.MathNode( "mi", - [mml.makeText(group.value, group.mode, options)]); + [mml.makeText(group.text, group.mode, options)]); const variant = mml.getVariant(group, options) || "italic"; if (variant !== defaultVariant[node.type]) { @@ -40,17 +40,17 @@ defineFunctionBuilders({ return buildCommon.makeOrd(group, options, "textord"); }, mathmlBuilder(group: ParseNode<"textord">, options) { - const text = mml.makeText(group.value, group.mode, options); + const text = mml.makeText(group.text, group.mode, options); const variant = mml.getVariant(group, options) || "normal"; let node; if (group.mode === 'text') { node = new mathMLTree.MathNode("mtext", [text]); - } else if (/[0-9]/.test(group.value)) { + } else if (/[0-9]/.test(group.text)) { // TODO(kevinb) merge adjacent nodes // do it as a post processing step node = new mathMLTree.MathNode("mn", [text]); - } else if (group.value === "\\prime") { + } else if (group.text === "\\prime") { node = new mathMLTree.MathNode("mo", [text]); } else { node = new mathMLTree.MathNode("mi", [text]); diff --git a/src/functions/symbolsSpacing.js b/src/functions/symbolsSpacing.js index 78ace473..b80a9019 100644 --- a/src/functions/symbolsSpacing.js +++ b/src/functions/symbolsSpacing.js @@ -9,8 +9,8 @@ import ParseError from "../ParseError"; defineFunctionBuilders({ type: "spacing", htmlBuilder(group, options) { - if (buildCommon.regularSpace.hasOwnProperty(group.value)) { - const className = buildCommon.regularSpace[group.value].className || ""; + if (buildCommon.regularSpace.hasOwnProperty(group.text)) { + const className = buildCommon.regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these // things has an entry in the symbols table, so these will be turned // into appropriate outputs. @@ -20,29 +20,29 @@ defineFunctionBuilders({ return ord; } else { return buildCommon.makeSpan(["mspace", className], - [buildCommon.mathsym(group.value, group.mode, options)], + [buildCommon.mathsym(group.text, group.mode, options)], options); } - } else if (buildCommon.cssSpace.hasOwnProperty(group.value)) { + } else if (buildCommon.cssSpace.hasOwnProperty(group.text)) { // Spaces based on just a CSS class. return buildCommon.makeSpan( - ["mspace", buildCommon.cssSpace[group.value]], + ["mspace", buildCommon.cssSpace[group.text]], [], options); } else { - throw new ParseError(`Unknown type of space "${group.value}"`); + throw new ParseError(`Unknown type of space "${group.text}"`); } }, mathmlBuilder(group, options) { let node; - if (buildCommon.regularSpace.hasOwnProperty(group.value)) { + if (buildCommon.regularSpace.hasOwnProperty(group.text)) { node = new mathMLTree.MathNode( "mtext", [new mathMLTree.TextNode("\u00a0")]); - } else if (buildCommon.cssSpace.hasOwnProperty(group.value)) { + } else if (buildCommon.cssSpace.hasOwnProperty(group.text)) { // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored return new mathMLTree.MathNode("mspace"); } else { - throw new ParseError(`Unknown type of space "${group.value}"`); + throw new ParseError(`Unknown type of space "${group.text}"`); } return node; diff --git a/src/parseNode.js b/src/parseNode.js index 165977b9..2809c80a 100644 --- a/src/parseNode.js +++ b/src/parseNode.js @@ -47,7 +47,7 @@ type ParseNodeTypes = { type: "color-token", mode: Mode, loc?: ?SourceLocation, - value: string, + color: string, |}, // To avoid requiring run-time type assertions, this more carefully captures // the requirements on the fields per the op.js htmlBuilder logic: @@ -137,38 +137,38 @@ type ParseNodeTypes = { family: Atom, mode: Mode, loc?: ?SourceLocation, - value: string, + text: string, |}, "mathord": {| type: "mathord", mode: Mode, loc?: ?SourceLocation, - value: string, + text: string, |}, "spacing": {| type: "spacing", mode: Mode, loc?: ?SourceLocation, - value: string, + text: string, |}, "textord": {| type: "textord", mode: Mode, loc?: ?SourceLocation, - value: string, + text: string, |}, // These "-token" types don't have corresponding HTML/MathML builders. "accent-token": {| type: "accent-token", mode: Mode, loc?: ?SourceLocation, - value: string, + text: string, |}, "op-token": {| type: "op-token", mode: Mode, loc?: ?SourceLocation, - value: string, + text: string, |}, // From functions.js and functions/*.js. See also "color", "op", "styling", // and "text" above. @@ -211,8 +211,8 @@ type ParseNodeTypes = { mode: Mode, loc?: ?SourceLocation, label: string, - backgroundColor?: ParseNode<"color-token">, - borderColor?: ParseNode<"color-token">, + backgroundColor?: string, + borderColor?: string, body: AnyParseNode, |}, "environment": {| diff --git a/test/__snapshots__/katex-spec.js.snap b/test/__snapshots__/katex-spec.js.snap index 1ee4bdbe..3855200a 100755 --- a/test/__snapshots__/katex-spec.js.snap +++ b/test/__snapshots__/katex-spec.js.snap @@ -25,7 +25,7 @@ exports[`A begin/end parser should grab \\arraystretch 1`] = ` "start": 36 }, "mode": "math", - "value": "a" + "text": "a" } ] } @@ -51,7 +51,7 @@ exports[`A begin/end parser should grab \\arraystretch 1`] = ` "start": 38 }, "mode": "math", - "value": "b" + "text": "b" } ] } @@ -79,7 +79,7 @@ exports[`A begin/end parser should grab \\arraystretch 1`] = ` "start": 41 }, "mode": "math", - "value": "c" + "text": "c" } ] } @@ -105,7 +105,7 @@ exports[`A begin/end parser should grab \\arraystretch 1`] = ` "start": 43 }, "mode": "math", - "value": "d" + "text": "d" } ] } @@ -146,7 +146,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "a", + "text": "a", "width": 0.52859 }, { @@ -189,7 +189,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "b", + "text": "b", "width": 0.42917 }, { @@ -227,7 +227,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "=", + "text": "=", "width": 0.89444 } ], @@ -277,7 +277,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0.05556, "style": { }, - "value": "c", + "text": "c", "width": 0.43276 }, { @@ -315,7 +315,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "+", + "text": "+", "width": 0.89444 } ], @@ -365,7 +365,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0.16667, "style": { }, - "value": "d", + "text": "d", "width": 0.52049 }, { @@ -403,7 +403,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "+", + "text": "+", "width": 0.89444 }, { @@ -418,7 +418,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "+", + "text": "+", "width": 0.89444 } ], @@ -468,7 +468,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0.05556, "style": { }, - "value": "e", + "text": "e", "width": 0.46563 }, { @@ -491,7 +491,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "x", + "text": "x", "width": 0.65903 }, { @@ -506,7 +506,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "y", + "text": "y", "width": 0.59028 }, { @@ -521,7 +521,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0, "style": { }, - "value": "z", + "text": "z", "width": 0.55509 } ], @@ -556,7 +556,7 @@ exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = "skew": 0.16667, "style": { }, - "value": "f", + "text": "f", "width": 0.48959 } ] @@ -569,13 +569,13 @@ exports[`A parse tree generator generates a tree 1`] = ` "base": { "type": "mathord", "mode": "math", - "value": "\\\\sigma" + "text": "\\\\sigma" }, "mode": "math", "sup": { "type": "textord", "mode": "math", - "value": "2" + "text": "2" } } ] @@ -598,7 +598,7 @@ exports[`A parser that does not throw on unsupported commands should build katex "skew": 0, "style": { }, - "value": "2^2^2", + "text": "2^2^2", "width": 0 } ], @@ -635,7 +635,7 @@ exports[`An implicit group parser within optional groups should work style comma { "type": "mathord", "mode": "math", - "value": "x" + "text": "x" } ] }, @@ -649,7 +649,7 @@ exports[`An implicit group parser within optional groups should work style comma { "type": "textord", "mode": "math", - "value": "3" + "text": "3" } ], "mode": "math", @@ -673,7 +673,7 @@ exports[`An implicit group parser within optional groups should work with \\colo { "type": "mathord", "mode": "math", - "value": "x" + "text": "x" } ] }, @@ -687,7 +687,7 @@ exports[`An implicit group parser within optional groups should work with \\colo { "type": "textord", "mode": "math", - "value": "3" + "text": "3" } ], "color": "red", @@ -711,7 +711,7 @@ exports[`An implicit group parser within optional groups should work with old fo { "type": "mathord", "mode": "math", - "value": "x" + "text": "x" } ] }, @@ -728,7 +728,7 @@ exports[`An implicit group parser within optional groups should work with old fo { "type": "textord", "mode": "math", - "value": "3" + "text": "3" } ] }, @@ -753,7 +753,7 @@ exports[`An implicit group parser within optional groups should work with sizing { "type": "mathord", "mode": "math", - "value": "x" + "text": "x" } ] }, @@ -767,7 +767,7 @@ exports[`An implicit group parser within optional groups should work with sizing { "type": "textord", "mode": "math", - "value": "3" + "text": "3" } ], "mode": "math", diff --git a/test/katex-spec.js b/test/katex-spec.js index bcd28ccd..1037cbf4 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -596,10 +596,10 @@ describe("An over/brace/brack parser", function() { const parse = getParsed(nestedOverExpression)[0]; expect(parse.type).toEqual("genfrac"); expect(parse.numer.value[0].type).toEqual("genfrac"); - expect(parse.numer.value[0].numer.value[0].value).toEqual("1"); - expect(parse.numer.value[0].denom.value[0].value).toEqual("2"); + expect(parse.numer.value[0].numer.value[0].text).toEqual("1"); + expect(parse.numer.value[0].denom.value[0].text).toEqual("2"); expect(parse.denom).toBeDefined(); - expect(parse.denom.value[0].value).toEqual("3"); + expect(parse.denom.value[0].text).toEqual("3"); }); it("should fail with multiple overs in the same group", function() { @@ -711,7 +711,7 @@ describe("A text parser", function() { const parse = getParsed(leadingSpaceTextExpression)[0]; // [m, o, o] expect(parse.body).toHaveLength(3); - expect(parse.body.map(n => n.value).join("")).toBe("moo"); + expect(parse.body.map(n => n.text).join("")).toBe("moo"); }); it("should parse math within text group", function() { @@ -1089,14 +1089,14 @@ describe("A non-braced kern parser", function() { const abParse3 = getParsed(abKern3); expect(abParse1).toHaveLength(3); - expect(abParse1[0].value).toEqual("a"); - expect(abParse1[2].value).toEqual("b"); + expect(abParse1[0].text).toEqual("a"); + expect(abParse1[2].text).toEqual("b"); expect(abParse2).toHaveLength(3); - expect(abParse2[0].value).toEqual("a"); - expect(abParse2[2].value).toEqual("b"); + expect(abParse2[0].text).toEqual("a"); + expect(abParse2[2].text).toEqual("b"); expect(abParse3).toHaveLength(3); - expect(abParse3[0].value).toEqual("a"); - expect(abParse3[2].value).toEqual("b"); + expect(abParse3[0].text).toEqual("a"); + expect(abParse3[2].text).toEqual("b"); }); it("should not parse invalid units", function() { @@ -1119,9 +1119,9 @@ describe("A non-braced kern parser", function() { const abParse = getParsed(abKern); expect(abParse).toHaveLength(3); - expect(abParse[0].value).toEqual("a"); + expect(abParse[0].text).toEqual("a"); expect(abParse[1].dimension.unit).toEqual("mu"); - expect(abParse[2].value).toEqual("b"); + expect(abParse[2].text).toEqual("b"); }); }); @@ -1474,7 +1474,7 @@ describe("A style change parser", function() { const displayBody = displayNode.body; expect(displayBody).toHaveLength(2); - expect(displayBody[0].value).toEqual("e"); + expect(displayBody[0].text).toEqual("e"); }); }); @@ -1547,10 +1547,10 @@ describe("A font parser", function() { expect(bf.type).toEqual("font"); expect(bf.font).toEqual("mathbf"); expect(bf.body.value).toHaveLength(3); - expect(bf.body.value[0].value).toEqual("a"); + expect(bf.body.value[0].text).toEqual("a"); expect(bf.body.value[1].type).toEqual("font"); expect(bf.body.value[1].font).toEqual("mathrm"); - expect(bf.body.value[2].value).toEqual("c"); + expect(bf.body.value[2].text).toEqual("c"); }); it("should have the correct greediness", function() {