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