Revert "Remove trailing commas for IE 9 compatibility"

This reverts commit 4d2e46e7f6.

Having trailing commans makes diffs easier to read as it avoids modifying a
line just to add a trailing comma if there is another item to add at the end
of a list.  There are plans to switch to ES6 notation and to translate that
to ES5 as part of the build process.  Since that translation would remove
trailing commas, the IE9 problems that originally motivated the commit
should vanish soon.
This commit is contained in:
Martin von Gagern
2017-01-11 13:26:00 +01:00
parent 677290336a
commit 53e416e296
30 changed files with 289 additions and 291 deletions

View File

@@ -46,7 +46,7 @@ Options.prototype.extend = function(extension) {
parentStyle: this.style,
parentSize: this.size,
phantom: this.phantom,
font: this.font
font: this.font,
};
for (var key in extension) {
@@ -63,7 +63,7 @@ Options.prototype.extend = function(extension) {
*/
Options.prototype.withStyle = function(style) {
return this.extend({
style: style
style: style,
});
};
@@ -72,7 +72,7 @@ Options.prototype.withStyle = function(style) {
*/
Options.prototype.withSize = function(size) {
return this.extend({
size: size
size: size,
});
};
@@ -81,7 +81,7 @@ Options.prototype.withSize = function(size) {
*/
Options.prototype.withColor = function(color) {
return this.extend({
color: color
color: color,
});
};
@@ -90,7 +90,7 @@ Options.prototype.withColor = function(color) {
*/
Options.prototype.withPhantom = function() {
return this.extend({
phantom: true
phantom: true,
});
};
@@ -99,7 +99,7 @@ Options.prototype.withPhantom = function() {
*/
Options.prototype.withFont = function(font) {
return this.extend({
font: font || this.font
font: font || this.font,
});
};
@@ -171,7 +171,7 @@ var colorMap = {
"katex-grayH": "#3b3e40",
"katex-grayI": "#21242c",
"katex-kaBlue": "#314453",
"katex-kaGreen": "#71B307"
"katex-kaGreen": "#71B307",
};
/**

View File

@@ -277,7 +277,7 @@ Parser.prototype.handleUnsupportedCmd = function() {
"text",
{
body: textordArray,
type: "text"
type: "text",
},
this.mode);
@@ -286,7 +286,7 @@ Parser.prototype.handleUnsupportedCmd = function() {
{
color: this.settings.errorColor,
value: [textNode],
type: "color"
type: "color",
},
this.mode);
@@ -367,7 +367,7 @@ Parser.prototype.parseAtom = function() {
return new ParseNode("supsub", {
base: base,
sup: superscript,
sub: subscript
sub: subscript,
}, this.mode);
} else {
// Otherwise return the original body
@@ -378,12 +378,12 @@ Parser.prototype.parseAtom = function() {
// A list of the size-changing functions, for use in parseImplicitGroup
var sizeFuncs = [
"\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize",
"\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"
"\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge",
];
// A list of the style-changing functions, for use in parseImplicitGroup
var styleFuncs = [
"\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"
"\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle",
];
/**
@@ -422,7 +422,7 @@ Parser.prototype.parseImplicitGroup = function() {
return new ParseNode("leftright", {
body: body,
left: left.value.value,
right: right.value.value
right: right.value.value,
}, this.mode);
} else if (func === "\\begin") {
// begin...end is similar to left...right
@@ -440,7 +440,7 @@ Parser.prototype.parseImplicitGroup = function() {
mode: this.mode,
envName: envName,
parser: this,
positions: args.pop()
positions: args.pop(),
};
var result = env.handler(context, args);
this.expect("\\end", false);
@@ -460,7 +460,7 @@ Parser.prototype.parseImplicitGroup = function() {
return new ParseNode("sizing", {
// Figure out what size to use based on the list of functions above
size: "size" + (utils.indexOf(sizeFuncs, func) + 1),
value: body
value: body,
}, this.mode);
} else if (utils.contains(styleFuncs, func)) {
// If we see a styling function, parse out the implict body
@@ -469,7 +469,7 @@ Parser.prototype.parseImplicitGroup = function() {
// Figure out what style to use by pulling out the style from
// the function name
style: func.slice(1, func.length - 5),
value: body
value: body,
}, this.mode);
} else {
// Defer to parseFunction if it's not a function we handle
@@ -520,7 +520,7 @@ Parser.prototype.callFunction = function(name, args, positions, token) {
funcName: name,
parser: this,
positions: positions,
token: token
token: token,
};
return functions[name].handler(context, args);
};
@@ -731,7 +731,7 @@ Parser.prototype.parseSizeGroup = function(optional) {
}
var data = {
number: +(match[1] + match[2]), // sign + magnitude, cast to number
unit: match[3]
unit: match[3],
};
if (data.unit !== "em" && data.unit !== "ex" && data.unit !== "mu") {
throw new ParseError("Invalid unit: '" + data.unit + "'", res);

View File

@@ -109,7 +109,7 @@ var sizeNames = [
"displaystyle textstyle",
"textstyle",
"scriptstyle",
"scriptscriptstyle"
"scriptscriptstyle",
];
// Reset names for the different sizes
@@ -117,7 +117,7 @@ var resetNames = [
"reset-textstyle",
"reset-textstyle",
"reset-scriptstyle",
"reset-scriptscriptstyle"
"reset-scriptscriptstyle",
];
// Instances of the different styles
@@ -129,7 +129,7 @@ var styles = [
new Style(S, 2, 0.7, false),
new Style(Sc, 2, 0.7, true),
new Style(SS, 3, 0.5, false),
new Style(SSc, 3, 0.5, true)
new Style(SSc, 3, 0.5, true),
];
// Lookup tables for switching from one style to another
@@ -145,5 +145,5 @@ module.exports = {
DISPLAY: styles[D],
TEXT: styles[T],
SCRIPT: styles[S],
SCRIPTSCRIPT: styles[SS]
SCRIPTSCRIPT: styles[SS],
};

View File

@@ -20,14 +20,14 @@ var greekCapitals = [
"\\Upsilon",
"\\Phi",
"\\Psi",
"\\Omega"
"\\Omega",
];
// The following have to be loaded from Main-Italic font, using class mainit
var mainitLetters = [
"\u0131", // dotless i, \imath
"\u0237", // dotless j, \jmath
"\u00a3" // \pounds
"\u00a3", // \pounds
];
/**
@@ -378,7 +378,7 @@ var sizingMultiplier = {
size7: 1.44,
size8: 1.73,
size9: 2.07,
size10: 2.49
size10: 2.49,
};
// A map of spacing functions to their attributes, like size and corresponding
@@ -386,32 +386,32 @@ var sizingMultiplier = {
var spacingFunctions = {
"\\qquad": {
size: "2em",
className: "qquad"
className: "qquad",
},
"\\quad": {
size: "1em",
className: "quad"
className: "quad",
},
"\\enspace": {
size: "0.5em",
className: "enspace"
className: "enspace",
},
"\\;": {
size: "0.277778em",
className: "thickspace"
className: "thickspace",
},
"\\:": {
size: "0.22222em",
className: "mediumspace"
className: "mediumspace",
},
"\\,": {
size: "0.16667em",
className: "thinspace"
className: "thinspace",
},
"\\!": {
size: "-0.16667em",
className: "negativethinspace"
}
className: "negativethinspace",
},
};
/**
@@ -424,15 +424,15 @@ var fontMap = {
// styles
"mathbf": {
variant: "bold",
fontName: "Main-Bold"
fontName: "Main-Bold",
},
"mathrm": {
variant: "normal",
fontName: "Main-Regular"
fontName: "Main-Regular",
},
"textit": {
variant: "italic",
fontName: "Main-Italic"
fontName: "Main-Italic",
},
// "mathit" is missing because it requires the use of two fonts: Main-Italic
@@ -442,28 +442,28 @@ var fontMap = {
// families
"mathbb": {
variant: "double-struck",
fontName: "AMS-Regular"
fontName: "AMS-Regular",
},
"mathcal": {
variant: "script",
fontName: "Caligraphic-Regular"
fontName: "Caligraphic-Regular",
},
"mathfrak": {
variant: "fraktur",
fontName: "Fraktur-Regular"
fontName: "Fraktur-Regular",
},
"mathscr": {
variant: "script",
fontName: "Script-Regular"
fontName: "Script-Regular",
},
"mathsf": {
variant: "sans-serif",
fontName: "SansSerif-Regular"
fontName: "SansSerif-Regular",
},
"mathtt": {
variant: "monospace",
fontName: "Typewriter-Regular"
}
fontName: "Typewriter-Regular",
},
};
module.exports = {
@@ -476,5 +476,5 @@ module.exports = {
makeOrd: makeOrd,
prependChildren: prependChildren,
sizingMultiplier: sizingMultiplier,
spacingFunctions: spacingFunctions
spacingFunctions: spacingFunctions,
};

View File

@@ -114,7 +114,7 @@ var getTypeOfDomTree = function(node) {
}
} else {
if (utils.contains(["mord", "mop", "mbin", "mrel", "mopen", "mclose",
"mpunct", "minner"], node.classes[0])) {
"mpunct", "minner"], node.classes[0])) {
return node.classes[0];
}
}
@@ -344,7 +344,7 @@ groupTypes.supsub = function(group, options) {
sub.height - 0.8 * style.metrics.xHeight);
supsub = buildCommon.makeVList([
{type: "elem", elem: submid}
{type: "elem", elem: submid},
], "shift", subShift, options);
supsub.children[0].style.marginRight = scriptspace;
@@ -361,7 +361,7 @@ groupTypes.supsub = function(group, options) {
sup.depth + 0.25 * style.metrics.xHeight);
supsub = buildCommon.makeVList([
{type: "elem", elem: supmid}
{type: "elem", elem: supmid},
], "shift", -supShift, options);
supsub.children[0].style.marginRight = scriptspace;
@@ -385,7 +385,7 @@ groupTypes.supsub = function(group, options) {
supsub = buildCommon.makeVList([
{type: "elem", elem: submid, shift: subShift},
{type: "elem", elem: supmid, shift: -supShift}
{type: "elem", elem: supmid, shift: -supShift},
], "individualShift", null, options);
// See comment above about subscripts not being shifted
@@ -472,7 +472,7 @@ groupTypes.genfrac = function(group, options) {
frac = buildCommon.makeVList([
{type: "elem", elem: denomreset, shift: denomShift},
{type: "elem", elem: numerreset, shift: -numShift}
{type: "elem", elem: numerreset, shift: -numShift},
], "individualShift", null, options);
} else {
// Rule 15d
@@ -503,7 +503,7 @@ groupTypes.genfrac = function(group, options) {
frac = buildCommon.makeVList([
{type: "elem", elem: denomreset, shift: denomShift},
{type: "elem", elem: mid, shift: midShift},
{type: "elem", elem: numerreset, shift: -numShift}
{type: "elem", elem: numerreset, shift: -numShift},
], "individualShift", null, options);
}
@@ -724,7 +724,7 @@ groupTypes.spacing = function(group, options) {
// generate these.
return makeSpan(
["mspace",
buildCommon.spacingFunctions[group.value].className],
buildCommon.spacingFunctions[group.value].className],
[], options);
}
};
@@ -764,7 +764,7 @@ groupTypes.op = function(group, options) {
// Most operators have a large successor symbol, but these don't.
var noSuccessor = [
"\\smallint"
"\\smallint",
];
var large = false;
@@ -859,7 +859,7 @@ groupTypes.op = function(group, options) {
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5},
{type: "elem", elem: submid},
{type: "kern", size: subKern},
{type: "elem", elem: base}
{type: "elem", elem: base},
], "top", top, options);
// Here, we shift the limits by the slant of the symbol. Note
@@ -874,7 +874,7 @@ groupTypes.op = function(group, options) {
{type: "elem", elem: base},
{type: "kern", size: supKern},
{type: "elem", elem: supmid},
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5}
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5},
], "bottom", bottom, options);
// See comment above about slants
@@ -897,7 +897,7 @@ groupTypes.op = function(group, options) {
{type: "elem", elem: base},
{type: "kern", size: supKern},
{type: "elem", elem: supmid},
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5}
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5},
], "bottom", bottom, options);
// See comment above about slants
@@ -1017,7 +1017,7 @@ groupTypes.overline = function(group, options) {
{type: "elem", elem: innerGroup},
{type: "kern", size: 3 * ruleWidth},
{type: "elem", elem: line},
{type: "kern", size: ruleWidth}
{type: "kern", size: ruleWidth},
], "firstBaseline", null, options);
return makeSpan(["mord", "overline"], [vlist], options);
@@ -1043,7 +1043,7 @@ groupTypes.underline = function(group, options) {
{type: "kern", size: ruleWidth},
{type: "elem", elem: line},
{type: "kern", size: 3 * ruleWidth},
{type: "elem", elem: innerGroup}
{type: "elem", elem: innerGroup},
], "top", innerGroup.height, options);
return makeSpan(["mord", "underline"], [vlist], options);
@@ -1110,7 +1110,7 @@ groupTypes.sqrt = function(group, options) {
{type: "elem", elem: inner},
{type: "kern", size: lineClearance},
{type: "elem", elem: line},
{type: "kern", size: ruleWidth}
{type: "kern", size: ruleWidth},
], "firstBaseline", null, options);
}
@@ -1187,7 +1187,7 @@ groupTypes.styling = function(group, options) {
"display": Style.DISPLAY,
"text": Style.TEXT,
"script": Style.SCRIPT,
"scriptscript": Style.SCRIPTSCRIPT
"scriptscript": Style.SCRIPTSCRIPT,
};
var newStyle = styleMap[group.value.style];
@@ -1444,7 +1444,7 @@ groupTypes.accent = function(group, options) {
accentBody = buildCommon.makeVList([
{type: "elem", elem: body},
{type: "kern", size: -clearance},
{type: "elem", elem: accentBody}
{type: "elem", elem: accentBody},
], "firstBaseline", null, options);
// Shift the accent over by the skew. Note we shift by twice the skew

View File

@@ -195,7 +195,7 @@ groupTypes.genfrac = function(group, options) {
var node = new mathMLTree.MathNode(
"mfrac",
[buildGroup(group.value.numer, options),
buildGroup(group.value.denom, options)]);
buildGroup(group.value.denom, options)]);
if (!group.value.hasBarLine) {
node.setAttribute("linethickness", "0px");
@@ -249,7 +249,7 @@ groupTypes.sqrt = function(group, options) {
node = new mathMLTree.MathNode(
"mroot", [
buildGroup(group.value.body, options),
buildGroup(group.value.index, options)
buildGroup(group.value.index, options),
]);
} else {
node = new mathMLTree.MathNode(
@@ -299,7 +299,7 @@ groupTypes.accent = function(group, options) {
var node = new mathMLTree.MathNode(
"mover",
[buildGroup(group.value.base, options),
accentNode]);
accentNode]);
node.setAttribute("accent", "true");
@@ -417,7 +417,7 @@ groupTypes.styling = function(group, options) {
"display": ["0", "true"],
"text": ["0", "false"],
"script": ["1", "false"],
"scriptscript": ["2", "false"]
"scriptscript": ["2", "false"],
};
var attr = styleAttributes[group.value.style];
@@ -452,7 +452,7 @@ groupTypes.overline = function(group, options) {
var node = new mathMLTree.MathNode(
"mover",
[buildGroup(group.value.body, options),
operator]);
operator]);
node.setAttribute("accent", "true");
return node;
@@ -466,7 +466,7 @@ groupTypes.underline = function(group, options) {
var node = new mathMLTree.MathNode(
"munder",
[buildGroup(group.value.body, options),
operator]);
operator]);
node.setAttribute("accentunder", "true");
return node;

View File

@@ -18,7 +18,7 @@ var buildTree = function(tree, expression, settings) {
// Setup the default options
var options = new Options({
style: startStyle,
size: "size5"
size: "size5",
});
// `buildHTML` sometimes messes with the parse tree (like turning bins ->
@@ -27,7 +27,7 @@ var buildTree = function(tree, expression, settings) {
var htmlNode = buildHTML(tree, options);
var katexNode = makeSpan(["katex"], [
mathMLNode, htmlNode
mathMLNode, htmlNode,
]);
if (settings.displayMode) {

View File

@@ -331,7 +331,7 @@ var stackLargeDelimiters = [
"(", ")", "[", "\\lbrack", "]", "\\rbrack",
"\\{", "\\lbrace", "\\}", "\\rbrace",
"\\lfloor", "\\rfloor", "\\lceil", "\\rceil",
"\\surd"
"\\surd",
];
// delimiters that always stack
@@ -340,12 +340,12 @@ var stackAlwaysDelimiters = [
"\\Uparrow", "\\Downarrow", "\\Updownarrow",
"|", "\\|", "\\vert", "\\Vert",
"\\lvert", "\\rvert", "\\lVert", "\\rVert",
"\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache"
"\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache",
];
// and delimiters that never stack
var stackNeverDelimiters = [
"<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"
"<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt",
];
// Metrics of the different sizes. Found by looking at TeX's output of
@@ -396,7 +396,7 @@ var stackNeverDelimiterSequence = [
{type: "large", size: 1},
{type: "large", size: 2},
{type: "large", size: 3},
{type: "large", size: 4}
{type: "large", size: 4},
];
// Delimiters that always stack try the small delimiters first, then stack
@@ -404,7 +404,7 @@ var stackAlwaysDelimiterSequence = [
{type: "small", style: Style.SCRIPTSCRIPT},
{type: "small", style: Style.SCRIPT},
{type: "small", style: Style.TEXT},
{type: "stack"}
{type: "stack"},
];
// Delimiters that stack when large try the small and then large delimiters, and
@@ -417,7 +417,7 @@ var stackLargeDelimiterSequence = [
{type: "large", size: 2},
{type: "large", size: 3},
{type: "large", size: 4},
{type: "stack"}
{type: "stack"},
];
/**
@@ -546,5 +546,5 @@ var makeLeftRightDelim = function(delim, height, depth, options, mode,
module.exports = {
sizedDelim: makeSizedDelim,
customSizedDelim: makeCustomSizedDelim,
leftRightDelim: makeLeftRightDelim
leftRightDelim: makeLeftRightDelim,
};

View File

@@ -186,7 +186,7 @@ var iCombinations = {
'ï': '\u0131\u0308',
'í': '\u0131\u0301',
// 'ī': '\u0131\u0304', // enable when we add Extended Latin
'ì': '\u0131\u0300'
'ì': '\u0131\u0300',
};
/**
@@ -332,5 +332,5 @@ symbolNode.prototype.toMarkup = function() {
module.exports = {
span: span,
documentFragment: documentFragment,
symbolNode: symbolNode
symbolNode: symbolNode,
};

View File

@@ -75,7 +75,7 @@ function defineEnvironment(names, props, handler) {
greediness: 1,
allowedInText: !!props.allowedInText,
numOptionalArgs: props.numOptionalArgs || 0,
handler: handler
handler: handler,
};
for (var i = 0; i < names.length; ++i) {
module.exports[names[i]] = data;
@@ -85,7 +85,7 @@ function defineEnvironment(names, props, handler) {
// Arrays are part of LaTeX, defined in lttab.dtx so its documentation
// is part of the source2e.pdf file of LaTeX2e source documentation.
defineEnvironment("array", {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var colalign = args[0];
colalign = colalign.value.map ? colalign.value : [colalign];
@@ -94,12 +94,12 @@ defineEnvironment("array", {
if ("lcr".indexOf(ca) !== -1) {
return {
type: "align",
align: ca
align: ca,
};
} else if (ca === "|") {
return {
type: "separator",
separator: "|"
separator: "|",
};
}
throw new ParseError(
@@ -109,7 +109,7 @@ defineEnvironment("array", {
var res = {
type: "array",
cols: cols,
hskipBeforeAndAfter: true // \@preamble in lttab.dtx
hskipBeforeAndAfter: true, // \@preamble in lttab.dtx
};
res = parseArray(context.parser, res);
return res;
@@ -123,7 +123,7 @@ defineEnvironment([
"bmatrix",
"Bmatrix",
"vmatrix",
"Vmatrix"
"Vmatrix",
], {
}, function(context) {
var delimiters = {
@@ -132,18 +132,18 @@ defineEnvironment([
"bmatrix": ["[", "]"],
"Bmatrix": ["\\{", "\\}"],
"vmatrix": ["|", "|"],
"Vmatrix": ["\\Vert", "\\Vert"]
"Vmatrix": ["\\Vert", "\\Vert"],
}[context.envName];
var res = {
type: "array",
hskipBeforeAndAfter: false // \hskip -\arraycolsep in amsmath
hskipBeforeAndAfter: false, // \hskip -\arraycolsep in amsmath
};
res = parseArray(context.parser, res);
if (delimiters) {
res = new ParseNode("leftright", {
body: [res],
left: delimiters[0],
right: delimiters[1]
right: delimiters[1],
}, context.mode);
}
return res;
@@ -165,19 +165,19 @@ defineEnvironment("cases", {
// For now we use the metrics for TEXT style which is what we were
// doing before. Before attempting to get the current style we
// should look at TeX's behavior especially for \over and matrices.
postgap: Style.TEXT.metrics.quad
postgap: Style.TEXT.metrics.quad,
}, {
type: "align",
align: "l",
pregap: 0,
postgap: 0
}]
postgap: 0,
}],
};
res = parseArray(context.parser, res);
res = new ParseNode("leftright", {
body: [res],
left: "\\{",
right: "."
right: ".",
}, context.mode);
return res;
});
@@ -190,7 +190,7 @@ defineEnvironment("aligned", {
}, function(context) {
var res = {
type: "array",
cols: []
cols: [],
};
res = parseArray(context.parser, res);
var emptyGroup = new ParseNode("ordgroup", [], context.mode);
@@ -216,7 +216,7 @@ defineEnvironment("aligned", {
type: "align",
align: align,
pregap: pregap,
postgap: 0
postgap: 0,
};
}
return res;

View File

@@ -54,7 +54,7 @@ var sigmas = {
subDrop: [0.050, 0.071, 0.100], // sigma19
delim1: [2.390, 1.700, 1.980], // sigma20
delim2: [1.010, 1.157, 1.420], // sigma21
axisHeight: [0.250, 0.250, 0.250] // sigma22
axisHeight: [0.250, 0.250, 0.250], // sigma22
};
// These font metrics are extracted from TeX by using
@@ -97,7 +97,7 @@ var metrics = {
bigOpSpacing4: xi12,
bigOpSpacing5: xi13,
ptPerEm: ptPerEm,
doubleRuleSep: doubleRuleSep
doubleRuleSep: doubleRuleSep,
};
// This map contains a mapping from font name and character code to character
@@ -242,7 +242,7 @@ var extraCharacterMap = {
'ь': 'a',
'э': 'e',
'ю': 'm',
'я': 'r'
'я': 'r',
};
/**
@@ -266,7 +266,7 @@ var getCharacterMetrics = function(character, style) {
height: metrics[1],
italic: metrics[2],
skew: metrics[3],
width: metrics[4]
width: metrics[4],
};
}
};
@@ -274,5 +274,5 @@ var getCharacterMetrics = function(character, style) {
module.exports = {
metrics: metrics,
sigmas: sigmas,
getCharacterMetrics: getCharacterMetrics
getCharacterMetrics: getCharacterMetrics,
};

View File

@@ -254,7 +254,7 @@ module.exports = {
"57368": [0.25142, 0.75726, 0, 0],
"57369": [0.25142, 0.75726, 0, 0],
"57370": [0.13597, 0.63597, 0, 0],
"57371": [0.13597, 0.63597, 0, 0]
"57371": [0.13597, 0.63597, 0, 0],
},
"Caligraphic-Regular": {
"48": [0, 0.43056, 0, 0],
@@ -292,7 +292,7 @@ module.exports = {
"87": [0, 0.68333, 0.08222, 0.08334],
"88": [0, 0.68333, 0.14643, 0.13889],
"89": [0.09722, 0.68333, 0.08222, 0.08334],
"90": [0, 0.68333, 0.07944, 0.13889]
"90": [0, 0.68333, 0.07944, 0.13889],
},
"Fraktur-Regular": {
"33": [0, 0.69141, 0, 0],
@@ -385,7 +385,7 @@ module.exports = {
"58116": [0.18906, 0.47534, 0, 0],
"58117": [0, 0.69141, 0, 0],
"58118": [0, 0.62119, 0, 0],
"58119": [0, 0.47534, 0, 0]
"58119": [0, 0.47534, 0, 0],
},
"Main-Bold": {
"33": [0, 0.69444, 0, 0],
@@ -640,7 +640,7 @@ module.exports = {
"10217": [0.25, 0.75, 0, 0],
"10815": [0, 0.68611, 0, 0],
"10927": [0.19667, 0.69667, 0, 0],
"10928": [0.19667, 0.69667, 0, 0]
"10928": [0.19667, 0.69667, 0, 0],
},
"Main-Italic": {
"33": [0, 0.69444, 0.12417, 0],
@@ -760,7 +760,7 @@ module.exports = {
"8217": [0, 0.69444, 0.12417, 0],
"8220": [0, 0.69444, 0.1685, 0],
"8221": [0, 0.69444, 0.06961, 0],
"8463": [0, 0.68889, 0, 0]
"8463": [0, 0.68889, 0, 0],
},
"Main-Regular": {
"32": [0, 0, 0, 0],
@@ -1041,7 +1041,7 @@ module.exports = {
"10236": [0.011, 0.511, 0, 0],
"10815": [0, 0.68333, 0, 0],
"10927": [0.13597, 0.63597, 0, 0],
"10928": [0.13597, 0.63597, 0, 0]
"10928": [0.13597, 0.63597, 0, 0],
},
"Math-BoldItalic": {
"47": [0.19444, 0.69444, 0, 0],
@@ -1137,7 +1137,7 @@ module.exports = {
"981": [0.19444, 0.69444, 0, 0],
"982": [0, 0.44444, 0.03194, 0],
"1009": [0.19444, 0.44444, 0, 0],
"1013": [0, 0.44444, 0, 0]
"1013": [0, 0.44444, 0, 0],
},
"Math-Italic": {
"47": [0.19444, 0.69444, 0, 0],
@@ -1233,7 +1233,7 @@ module.exports = {
"981": [0.19444, 0.69444, 0, 0.08334],
"982": [0, 0.43056, 0.02778, 0],
"1009": [0.19444, 0.43056, 0, 0.08334],
"1013": [0, 0.43056, 0, 0.05556]
"1013": [0, 0.43056, 0, 0.05556],
},
"Math-Regular": {
"65": [0, 0.68333, 0, 0.13889],
@@ -1328,7 +1328,7 @@ module.exports = {
"981": [0.19444, 0.69444, 0, 0.08334],
"982": [0, 0.43056, 0.02778, 0],
"1009": [0.19444, 0.43056, 0, 0.08334],
"1013": [0, 0.43056, 0, 0.05556]
"1013": [0, 0.43056, 0, 0.05556],
},
"SansSerif-Regular": {
"33": [0, 0.69444, 0, 0],
@@ -1447,7 +1447,7 @@ module.exports = {
"8216": [0, 0.69444, 0, 0],
"8217": [0, 0.69444, 0, 0],
"8220": [0, 0.69444, 0, 0],
"8221": [0, 0.69444, 0, 0]
"8221": [0, 0.69444, 0, 0],
},
"Script-Regular": {
"65": [0, 0.7, 0.22925, 0],
@@ -1475,7 +1475,7 @@ module.exports = {
"87": [0, 0.7, 0.27523, 0],
"88": [0, 0.7, 0.26006, 0],
"89": [0, 0.7, 0.2939, 0],
"90": [0, 0.7, 0.24037, 0]
"90": [0, 0.7, 0.24037, 0],
},
"Size1-Regular": {
"40": [0.35001, 0.85, 0, 0],
@@ -1520,7 +1520,7 @@ module.exports = {
"10753": [0.25001, 0.75, 0, 0],
"10754": [0.25001, 0.75, 0, 0],
"10756": [0.25001, 0.75, 0, 0],
"10758": [0.25001, 0.75, 0, 0]
"10758": [0.25001, 0.75, 0, 0],
},
"Size2-Regular": {
"40": [0.65002, 1.15, 0, 0],
@@ -1557,7 +1557,7 @@ module.exports = {
"10753": [0.55001, 1.05, 0, 0],
"10754": [0.55001, 1.05, 0, 0],
"10756": [0.55001, 1.05, 0, 0],
"10758": [0.55001, 1.05, 0, 0]
"10758": [0.55001, 1.05, 0, 0],
},
"Size3-Regular": {
"40": [0.95003, 1.45, 0, 0],
@@ -1578,7 +1578,7 @@ module.exports = {
"8970": [0.95003, 1.45, 0, 0],
"8971": [0.95003, 1.45, 0, 0],
"10216": [0.95003, 1.45, 0, 0],
"10217": [0.95003, 1.45, 0, 0]
"10217": [0.95003, 1.45, 0, 0],
},
"Size4-Regular": {
"40": [1.25003, 1.75, 0, 0],
@@ -1625,7 +1625,7 @@ module.exports = {
"57680": [0, 0.12, 0, 0],
"57681": [0, 0.12, 0, 0],
"57682": [0, 0.12, 0, 0],
"57683": [0, 0.12, 0, 0]
"57683": [0, 0.12, 0, 0],
},
"Typewriter-Regular": {
"33": [0, 0.61111, 0, 0],
@@ -1747,6 +1747,6 @@ module.exports = {
"937": [0, 0.61111, 0, 0],
"2018": [0, 0.61111, 0, 0],
"2019": [0, 0.61111, 0, 0],
"8242": [0, 0.61111, 0, 0]
}
"8242": [0, 0.61111, 0, 0],
},
};

View File

@@ -95,7 +95,7 @@ function defineFunction(names, props, handler) {
allowedInText: !!props.allowedInText,
numOptionalArgs: props.numOptionalArgs || 0,
infix: !!props.infix,
handler: handler
handler: handler,
};
for (var i = 0; i < names.length; ++i) {
module.exports[names[i]] = data;
@@ -115,14 +115,14 @@ var ordargument = function(arg) {
// A normal square root
defineFunction("\\sqrt", {
numArgs: 1,
numOptionalArgs: 1
numOptionalArgs: 1,
}, function(context, args) {
var index = args[0];
var body = args[1];
return {
type: "sqrt",
body: body,
index: index
index: index,
};
});
@@ -130,23 +130,23 @@ defineFunction("\\sqrt", {
var textFunctionStyles = {
"\\text": undefined, "\\textrm": "mathrm", "\\textsf": "mathsf",
"\\texttt": "mathtt", "\\textnormal": "mathrm", "\\textbf": "mathbf",
"\\textit": "textit"
"\\textit": "textit",
};
defineFunction([
"\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal",
"\\textbf", "\\textit"
"\\textbf", "\\textit",
], {
numArgs: 1,
argTypes: ["text"],
greediness: 2,
allowedInText: true
allowedInText: true,
}, function(context, args) {
var body = args[0];
return {
type: "text",
body: ordargument(body),
style: textFunctionStyles[context.funcName]
style: textFunctionStyles[context.funcName],
};
});
@@ -155,36 +155,36 @@ defineFunction("\\color", {
numArgs: 2,
allowedInText: true,
greediness: 3,
argTypes: ["color", "original"]
argTypes: ["color", "original"],
}, function(context, args) {
var color = args[0];
var body = args[1];
return {
type: "color",
color: color.value,
value: ordargument(body)
value: ordargument(body),
};
});
// An overline
defineFunction("\\overline", {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var body = args[0];
return {
type: "overline",
body: body
body: body,
};
});
// An underline
defineFunction("\\underline", {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var body = args[0];
return {
type: "underline",
body: body
body: body,
};
});
@@ -192,7 +192,7 @@ defineFunction("\\underline", {
defineFunction("\\rule", {
numArgs: 2,
numOptionalArgs: 1,
argTypes: ["size", "size", "size"]
argTypes: ["size", "size", "size"],
}, function(context, args) {
var shift = args[0];
var width = args[1];
@@ -201,7 +201,7 @@ defineFunction("\\rule", {
type: "rule",
shift: shift && shift.value,
width: width.value,
height: height.value
height: height.value,
};
});
@@ -209,51 +209,51 @@ defineFunction("\\rule", {
// mu-units. In current KaTeX we relax this; both commands accept any unit.
defineFunction(["\\kern", "\\mkern"], {
numArgs: 1,
argTypes: ["size"]
argTypes: ["size"],
}, function(context, args) {
return {
type: "kern",
dimension: args[0].value
dimension: args[0].value,
};
});
// A KaTeX logo
defineFunction("\\KaTeX", {
numArgs: 0
numArgs: 0,
}, function(context) {
return {
type: "katex"
type: "katex",
};
});
defineFunction("\\phantom", {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var body = args[0];
return {
type: "phantom",
value: ordargument(body)
value: ordargument(body),
};
});
// Math class commands except \mathop
defineFunction([
"\\mathord", "\\mathbin", "\\mathrel", "\\mathopen",
"\\mathclose", "\\mathpunct", "\\mathinner"
"\\mathclose", "\\mathpunct", "\\mathinner",
], {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var body = args[0];
return {
type: "mclass",
mclass: "m" + context.funcName.substr(5),
value: ordargument(body)
value: ordargument(body),
};
});
// Build a relation by placing one symbol on top of another
defineFunction("\\stackrel", {
numArgs: 2
numArgs: 2,
}, function(context, args) {
var top = args[0];
var bottom = args[1];
@@ -263,41 +263,41 @@ defineFunction("\\stackrel", {
limits: true,
alwaysHandleSupSub: true,
symbol: false,
value: ordargument(bottom)
value: ordargument(bottom),
}, bottom.mode);
var supsub = new ParseNode("supsub", {
base: bottomop,
sup: top,
sub: null
sub: null,
}, top.mode);
return {
type: "mclass",
mclass: "mrel",
value: [supsub]
value: [supsub],
};
});
// \mod-type functions
defineFunction("\\bmod", {
numArgs: 0
numArgs: 0,
}, function(context, args) {
return {
type: "mod",
modType: "bmod",
value: null
value: null,
};
});
defineFunction(["\\pod", "\\pmod", "\\mod"], {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var body = args[0];
return {
type: "mod",
modType: context.funcName.substr(1),
value: ordargument(body)
value: ordargument(body),
};
});
@@ -318,7 +318,7 @@ var delimiterSizes = {
"\\big" : {mclass: "mord", size: 1},
"\\Big" : {mclass: "mord", size: 2},
"\\bigg" : {mclass: "mord", size: 3},
"\\Bigg" : {mclass: "mord", size: 4}
"\\Bigg" : {mclass: "mord", size: 4},
};
var delimiters = [
@@ -333,13 +333,13 @@ var delimiters = [
"\\uparrow", "\\Uparrow",
"\\downarrow", "\\Downarrow",
"\\updownarrow", "\\Updownarrow",
"."
".",
];
var fontAliases = {
"\\Bbb": "\\mathbb",
"\\bold": "\\mathbf",
"\\frak": "\\mathfrak"
"\\frak": "\\mathfrak",
};
// Single-argument color functions
@@ -356,17 +356,17 @@ defineFunction([
"\\mintA", "\\mintB", "\\mintC",
"\\grayA", "\\grayB", "\\grayC", "\\grayD", "\\grayE",
"\\grayF", "\\grayG", "\\grayH", "\\grayI",
"\\kaBlue", "\\kaGreen"
"\\kaBlue", "\\kaGreen",
], {
numArgs: 1,
allowedInText: true,
greediness: 3
greediness: 3,
}, function(context, args) {
var body = args[0];
return {
type: "color",
color: "katex-" + context.funcName.slice(1),
value: ordargument(body)
value: ordargument(body),
};
});
@@ -379,44 +379,44 @@ defineFunction([
"\\arcsin", "\\arccos", "\\arctan", "\\arg", "\\cos", "\\cosh",
"\\cot", "\\coth", "\\csc", "\\deg", "\\dim", "\\exp", "\\hom",
"\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh",
"\\tan", "\\tanh"
"\\tan", "\\tanh",
], {
numArgs: 0
numArgs: 0,
}, function(context) {
return {
type: "op",
limits: false,
symbol: false,
body: context.funcName
body: context.funcName,
};
});
// Limits, not symbols
defineFunction([
"\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max",
"\\min", "\\Pr", "\\sup"
"\\min", "\\Pr", "\\sup",
], {
numArgs: 0
numArgs: 0,
}, function(context) {
return {
type: "op",
limits: true,
symbol: false,
body: context.funcName
body: context.funcName,
};
});
// No limits, symbols
defineFunction([
"\\int", "\\iint", "\\iiint", "\\oint"
"\\int", "\\iint", "\\iiint", "\\oint",
], {
numArgs: 0
numArgs: 0,
}, function(context) {
return {
type: "op",
limits: false,
symbol: true,
body: context.funcName
body: context.funcName,
};
});
@@ -424,28 +424,28 @@ defineFunction([
defineFunction([
"\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap",
"\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes",
"\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint"
"\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint",
], {
numArgs: 0
numArgs: 0,
}, function(context) {
return {
type: "op",
limits: true,
symbol: true,
body: context.funcName
body: context.funcName,
};
});
// \mathop class command
defineFunction("\\mathop", {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var body = args[0];
return {
type: "op",
limits: false,
symbol: false,
value: ordargument(body)
value: ordargument(body),
};
});
@@ -453,10 +453,10 @@ defineFunction("\\mathop", {
defineFunction([
"\\dfrac", "\\frac", "\\tfrac",
"\\dbinom", "\\binom", "\\tbinom",
"\\\\atopfrac" // cant be entered directly
"\\\\atopfrac", // cant be entered directly
], {
numArgs: 2,
greediness: 2
greediness: 2,
}, function(context, args) {
var numer = args[0];
var denom = args[1];
@@ -503,19 +503,19 @@ defineFunction([
hasBarLine: hasBarLine,
leftDelim: leftDelim,
rightDelim: rightDelim,
size: size
size: size,
};
});
// Left and right overlap functions
defineFunction(["\\llap", "\\rlap"], {
numArgs: 1,
allowedInText: true
allowedInText: true,
}, function(context, args) {
var body = args[0];
return {
type: context.funcName.slice(1),
body: body
body: body,
};
});
@@ -534,9 +534,9 @@ defineFunction([
"\\bigl", "\\Bigl", "\\biggl", "\\Biggl",
"\\bigr", "\\Bigr", "\\biggr", "\\Biggr",
"\\bigm", "\\Bigm", "\\biggm", "\\Biggm",
"\\big", "\\Big", "\\bigg", "\\Bigg"
"\\big", "\\Big", "\\bigg", "\\Bigg",
], {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var delim = checkDelimiter(args[0], context);
@@ -544,14 +544,14 @@ defineFunction([
type: "delimsizing",
size: delimiterSizes[context.funcName].size,
mclass: delimiterSizes[context.funcName].mclass,
value: delim.value
value: delim.value,
};
});
defineFunction([
"\\left", "\\right"
"\\left", "\\right",
], {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var delim = checkDelimiter(args[0], context);
@@ -559,12 +559,12 @@ defineFunction([
// why this data doesn't match what is in buildHTML.
return {
type: "leftright",
value: delim.value
value: delim.value,
};
});
defineFunction("\\middle", {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var delim = checkDelimiter(args[0], context);
if (!context.parser.leftrightDepth) {
@@ -573,21 +573,21 @@ defineFunction("\\middle", {
return {
type: "middle",
value: delim.value
value: delim.value,
};
});
// Sizing functions (handled in Parser.js explicitly, hence no handler)
defineFunction([
"\\tiny", "\\scriptsize", "\\footnotesize", "\\small",
"\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"
"\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge",
], 0, null);
// Style changing functions (handled in Parser.js explicitly, hence no
// handler)
defineFunction([
"\\displaystyle", "\\textstyle", "\\scriptstyle",
"\\scriptscriptstyle"
"\\scriptscriptstyle",
], 0, null);
defineFunction([
@@ -599,10 +599,10 @@ defineFunction([
"\\mathtt",
// aliases
"\\Bbb", "\\bold", "\\frak"
"\\Bbb", "\\bold", "\\frak",
], {
numArgs: 1,
greediness: 2
greediness: 2,
}, function(context, args) {
var body = args[0];
var func = context.funcName;
@@ -612,31 +612,31 @@ defineFunction([
return {
type: "font",
font: func.slice(1),
body: body
body: body,
};
});
// Accents
defineFunction([
"\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve",
"\\check", "\\hat", "\\vec", "\\dot"
"\\check", "\\hat", "\\vec", "\\dot",
// We don't support expanding accents yet
// "\\widetilde", "\\widehat"
], {
numArgs: 1
numArgs: 1,
}, function(context, args) {
var base = args[0];
return {
type: "accent",
accent: context.funcName,
base: base
base: base,
};
});
// Infix generalized fractions
defineFunction(["\\over", "\\choose", "\\atop"], {
numArgs: 0,
infix: true
infix: true,
}, function(context) {
var replaceWith;
switch (context.funcName) {
@@ -655,7 +655,7 @@ defineFunction(["\\over", "\\choose", "\\atop"], {
return {
type: "infix",
replaceWith: replaceWith,
token: context.token
token: context.token,
};
});
@@ -663,19 +663,19 @@ defineFunction(["\\over", "\\choose", "\\atop"], {
defineFunction(["\\\\", "\\cr"], {
numArgs: 0,
numOptionalArgs: 1,
argTypes: ["size"]
argTypes: ["size"],
}, function(context, args) {
var size = args[0];
return {
type: "cr",
size: size
size: size,
};
});
// Environment delimiters
defineFunction(["\\begin", "\\end"], {
numArgs: 1,
argTypes: ["text"]
argTypes: ["text"],
}, function(context, args) {
var nameGroup = args[0];
if (nameGroup.type !== "ordgroup") {
@@ -688,6 +688,6 @@ defineFunction(["\\begin", "\\end"], {
return {
type: "environment",
name: name,
nameGroup: nameGroup
nameGroup: nameGroup,
};
});

View File

@@ -98,5 +98,5 @@ TextNode.prototype.toMarkup = function() {
module.exports = {
MathNode: MathNode,
TextNode: TextNode
TextNode: TextNode,
};

View File

@@ -27,6 +27,6 @@ function ParseNode(type, value, mode, firstToken, lastToken) {
}
module.exports = {
ParseNode: ParseNode
ParseNode: ParseNode,
};

View File

@@ -18,14 +18,14 @@
module.exports = {
math: {},
text: {}
text: {},
};
function defineSymbol(mode, font, group, replace, name) {
module.exports[mode][name] = {
font: font,
group: group,
replace: replace
replace: replace,
};
}

View File

@@ -11,5 +11,5 @@ var cjkRegex =
module.exports = {
cjkRegex: cjkRegex,
hangulRegex: hangulRegex
hangulRegex: hangulRegex,
};

View File

@@ -51,7 +51,7 @@ var ESCAPE_LOOKUP = {
">": "&gt;",
"<": "&lt;",
"\"": "&quot;",
"'": "&#x27;"
"'": "&#x27;",
};
var ESCAPE_REGEX = /[&><"']/g;
@@ -102,5 +102,5 @@ module.exports = {
hyphenate: hyphenate,
indexOf: indexOf,
setTextContent: setTextContent,
clearNode: clearNode
clearNode: clearNode,
};