Remove trailing commas for IE 9 compatibility

Summary: IE 9 doesn't like trailing commas. When we introduced eslint, we added
a bunch of trailing commas, which makes IE 9 sad.

Test Plan:
 - `make lint`
 - Visit http://localhost:7936/ using IE 9 on browserstack.
 - See that the math loads, and there are no errors in the F12 developer tools.

@kevinb
This commit is contained in:
Emily Eisenberg 2017-01-06 19:06:01 -08:00
parent 74d55ee0ea
commit 4d2e46e7f6
31 changed files with 292 additions and 290 deletions

View File

@ -4,7 +4,9 @@
"brace-style": [2, "1tbs", { "allowSingleLine": true }], "brace-style": [2, "1tbs", { "allowSingleLine": true }],
// We'd possibly like to remove the 'properties': 'never' one day. // We'd possibly like to remove the 'properties': 'never' one day.
"camelcase": [2, { "properties": "never" }], "camelcase": [2, { "properties": "never" }],
"comma-dangle": [2, "always-multiline"], // IE 9 doesn't like trailing commas. TODO(emily): change this back to
// always-multiline once we babelify the code.
"comma-dangle": [2, "never"],
"comma-spacing": [2, { "before": false, "after": true }], "comma-spacing": [2, { "before": false, "after": true }],
"constructor-super": 2, "constructor-super": 2,
"curly": 2, "curly": 2,

View File

@ -13,7 +13,7 @@ beforeEach(function() {
compare: function(actual, left, right, result) { compare: function(actual, left, right, result) {
var message = { var message = {
pass: true, pass: true,
message: "'" + actual + "' split correctly", message: "'" + actual + "' split correctly"
}; };
var startData = [{type: "text", data: actual}]; var startData = [{type: "text", data: actual}];
@ -59,9 +59,9 @@ beforeEach(function() {
} }
return message; return message;
}, }
}; };
}, }
}); });
}); });
@ -75,7 +75,7 @@ describe("A delimiter splitter", function() {
"(", ")", "(", ")",
[ [
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "text", data: "( world"}, {type: "text", data: "( world"}
]); ]);
}); });
@ -83,7 +83,7 @@ describe("A delimiter splitter", function() {
expect("hello ) world").toSplitInto( expect("hello ) world").toSplitInto(
"(", ")", "(", ")",
[ [
{type: "text", data: "hello ) world"}, {type: "text", data: "hello ) world"}
]); ]);
}); });
@ -94,7 +94,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "math", data: " world ", {type: "math", data: " world ",
rawData: "( world )", display: false}, rawData: "( world )", display: false},
{type: "text", data: " boo"}, {type: "text", data: " boo"}
]); ]);
}); });
@ -105,7 +105,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "math", data: " world ", {type: "math", data: " world ",
rawData: "[[ world ]]", display: false}, rawData: "[[ world ]]", display: false},
{type: "text", data: " boo"}, {type: "text", data: " boo"}
]); ]);
}); });
@ -119,7 +119,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: " boo "}, {type: "text", data: " boo "},
{type: "math", data: " more ", {type: "math", data: " more ",
rawData: "( more )", display: false}, rawData: "( more )", display: false},
{type: "text", data: " stuff"}, {type: "text", data: " stuff"}
]); ]);
}); });
@ -131,7 +131,7 @@ describe("A delimiter splitter", function() {
{type: "math", data: " world ", {type: "math", data: " world ",
rawData: "( world )", display: false}, rawData: "( world )", display: false},
{type: "text", data: " boo "}, {type: "text", data: " boo "},
{type: "text", data: "( left"}, {type: "text", data: "( left"}
]); ]);
}); });
@ -142,7 +142,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "math", data: " world { ) } ", {type: "math", data: " world { ) } ",
rawData: "( world { ) } )", display: false}, rawData: "( world { ) } )", display: false},
{type: "text", data: " boo"}, {type: "text", data: " boo"}
]); ]);
expect("hello ( world { { } ) } ) boo").toSplitInto( expect("hello ( world { { } ) } ) boo").toSplitInto(
@ -151,7 +151,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "math", data: " world { { } ) } ", {type: "math", data: " world { { } ) } ",
rawData: "( world { { } ) } )", display: false}, rawData: "( world { { } ) } )", display: false},
{type: "text", data: " boo"}, {type: "text", data: " boo"}
]); ]);
}); });
@ -162,7 +162,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "math", data: " world \\) ", {type: "math", data: " world \\) ",
rawData: "( world \\) )", display: false}, rawData: "( world \\) )", display: false},
{type: "text", data: " boo"}, {type: "text", data: " boo"}
]); ]);
/* TODO(emily): make this work maybe? /* TODO(emily): make this work maybe?
@ -184,7 +184,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "math", data: " world ", {type: "math", data: " world ",
rawData: "$ world $", display: false}, rawData: "$ world $", display: false},
{type: "text", data: " boo"}, {type: "text", data: " boo"}
]); ]);
}); });
@ -196,7 +196,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "math", data: " world ", {type: "math", data: " world ",
rawData: "( world )", display: true}, rawData: "( world )", display: true},
{type: "text", data: " boo"}, {type: "text", data: " boo"}
]); ]);
}); });
@ -204,7 +204,7 @@ describe("A delimiter splitter", function() {
var startData = [ var startData = [
{type: "text", data: "hello ( world ) boo"}, {type: "text", data: "hello ( world ) boo"},
{type: "math", data: "math", rawData: "(math)", display: true}, {type: "math", data: "math", rawData: "(math)", display: true},
{type: "text", data: "hello ( world ) boo"}, {type: "text", data: "hello ( world ) boo"}
]; ];
expect(splitAtDelimiters(startData, "(", ")", false)).toEqual( expect(splitAtDelimiters(startData, "(", ")", false)).toEqual(
@ -217,7 +217,7 @@ describe("A delimiter splitter", function() {
{type: "text", data: "hello "}, {type: "text", data: "hello "},
{type: "math", data: " world ", {type: "math", data: " world ",
rawData: "( world )", display: false}, rawData: "( world )", display: false},
{type: "text", data: " boo"}, {type: "text", data: " boo"}
]); ]);
}); });
@ -225,7 +225,7 @@ describe("A delimiter splitter", function() {
var startData = [ var startData = [
{type: "text", data: "hello ( world ) boo"}, {type: "text", data: "hello ( world ) boo"},
{type: "math", data: "hello ( world ) boo", {type: "math", data: "hello ( world ) boo",
rawData: "(hello ( world ) boo)", display: true}, rawData: "(hello ( world ) boo)", display: true}
]; ];
expect(splitAtDelimiters(startData, "(", ")", false)).toEqual( expect(splitAtDelimiters(startData, "(", ")", false)).toEqual(
@ -235,7 +235,7 @@ describe("A delimiter splitter", function() {
rawData: "( world )", display: false}, rawData: "( world )", display: false},
{type: "text", data: " boo"}, {type: "text", data: " boo"},
{type: "math", data: "hello ( world ) boo", {type: "math", data: "hello ( world ) boo",
rawData: "(hello ( world ) boo)", display: true}, rawData: "(hello ( world ) boo)", display: true}
]); ]);
}); });
}); });

View File

@ -27,7 +27,7 @@ var renderMathInText = function(text, delimiters) {
var math = data[i].data; var math = data[i].data;
try { try {
katex.render(math, span, { katex.render(math, span, {
displayMode: data[i].display, displayMode: data[i].display
}); });
} catch (e) { } catch (e) {
if (!(e instanceof katex.ParseError)) { if (!(e instanceof katex.ParseError)) {
@ -73,14 +73,14 @@ var defaultOptions = {
delimiters: [ delimiters: [
{left: "$$", right: "$$", display: true}, {left: "$$", right: "$$", display: true},
{left: "\\[", right: "\\]", display: true}, {left: "\\[", right: "\\]", display: true},
{left: "\\(", right: "\\)", display: false}, {left: "\\(", right: "\\)", display: false}
// LaTeX uses this, but it ruins the display of normal `$` in text: // LaTeX uses this, but it ruins the display of normal `$` in text:
// {left: "$", right: "$", display: false}, // {left: "$", right: "$", display: false},
], ],
ignoredTags: [ ignoredTags: [
"script", "noscript", "style", "textarea", "pre", "code", "script", "noscript", "style", "textarea", "pre", "code"
], ]
}; };
var extend = function(obj) { var extend = function(obj) {

View File

@ -43,7 +43,7 @@ var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) {
currIndex = nextIndex; currIndex = nextIndex;
finalData.push({ finalData.push({
type: "text", type: "text",
data: text.slice(0, currIndex), data: text.slice(0, currIndex)
}); });
lookingForLeft = false; lookingForLeft = false;
} }
@ -57,7 +57,7 @@ var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) {
finalData.push({ finalData.push({
type: "text", type: "text",
data: text.slice(currIndex, nextIndex), data: text.slice(currIndex, nextIndex)
}); });
currIndex = nextIndex; currIndex = nextIndex;
@ -78,7 +78,7 @@ var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) {
rawData: text.slice( rawData: text.slice(
currIndex, currIndex,
nextIndex + rightDelim.length), nextIndex + rightDelim.length),
display: display, display: display
}); });
currIndex = nextIndex + rightDelim.length; currIndex = nextIndex + rightDelim.length;
@ -89,7 +89,7 @@ var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) {
finalData.push({ finalData.push({
type: "text", type: "text",
data: text.slice(currIndex), data: text.slice(currIndex)
}); });
} else { } else {
finalData.push(startData[i]); finalData.push(startData[i]);

View File

@ -25,52 +25,52 @@ var opts = require("nomnom")
.option("browser", { .option("browser", {
abbr: "b", abbr: "b",
"default": "firefox", "default": "firefox",
help: "Name of the browser to use", help: "Name of the browser to use"
}) })
.option("container", { .option("container", {
abbr: "c", abbr: "c",
type: "string", type: "string",
help: "Name or ID of a running docker container to contact", help: "Name or ID of a running docker container to contact"
}) })
.option("seleniumURL", { .option("seleniumURL", {
full: "selenium-url", full: "selenium-url",
help: "Full URL of the Selenium web driver", help: "Full URL of the Selenium web driver"
}) })
.option("seleniumIP", { .option("seleniumIP", {
full: "selenium-ip", full: "selenium-ip",
help: "IP address of the Selenium web driver", help: "IP address of the Selenium web driver"
}) })
.option("seleniumPort", { .option("seleniumPort", {
full: "selenium-port", full: "selenium-port",
"default": 4444, "default": 4444,
help: "Port number of the Selenium web driver", help: "Port number of the Selenium web driver"
}) })
.option("katexURL", { .option("katexURL", {
full: "katex-url", full: "katex-url",
help: "Full URL of the KaTeX development server", help: "Full URL of the KaTeX development server"
}) })
.option("katexIP", { .option("katexIP", {
full: "katex-ip", full: "katex-ip",
help: "Full URL of the KaTeX development server", help: "Full URL of the KaTeX development server"
}) })
.option("katexPort", { .option("katexPort", {
full: "katex-port", full: "katex-port",
help: "Port number of the KaTeX development server", help: "Port number of the KaTeX development server"
}) })
.option("include", { .option("include", {
abbr: "i", abbr: "i",
help: "Comma-separated list of test cases to process", help: "Comma-separated list of test cases to process"
}) })
.option("exclude", { .option("exclude", {
abbr: "x", abbr: "x",
help: "Comma-separated list of test cases to exclude", help: "Comma-separated list of test cases to exclude"
}) })
.option("verify", { .option("verify", {
flag: true, flag: true,
help: "Check whether screenshot matches current file content", help: "Check whether screenshot matches current file content"
}) })
.option("wait", { .option("wait", {
help: "Wait this many seconds between page load and screenshot", help: "Wait this many seconds between page load and screenshot"
}) })
.parse(); .parse();
@ -208,7 +208,7 @@ function tryConnect() {
} }
var sock = net.connect({ var sock = net.connect({
host: seleniumIP, host: seleniumIP,
port: +seleniumPort, port: +seleniumPort
}); });
sock.on("connect", function() { sock.on("connect", function() {
sock.end(); sock.end();
@ -278,7 +278,7 @@ function imageDimensions(img) {
return { return {
buf: buf, buf: buf,
width: buf.readUInt32BE(16), width: buf.readUInt32BE(16),
height: buf.readUInt32BE(20), height: buf.readUInt32BE(20)
}; };
} }
@ -399,7 +399,7 @@ function takeScreenshot(key) {
} }
} }
var opt = new jspngopt.Optimizer({ var opt = new jspngopt.Optimizer({
pako: pako, pako: pako
}); });
var buf = opt.bufferSync(img.buf); var buf = opt.bufferSync(img.buf);
if (loadExpected) { if (loadExpected) {

View File

@ -48,7 +48,7 @@ Q.all([
readFile(path.join(ssDir, "test.tex"), "utf-8"), readFile(path.join(ssDir, "test.tex"), "utf-8"),
ensureDir(tmpDir), ensureDir(tmpDir),
ensureDir(teximgDir), ensureDir(teximgDir),
ensureDir(diffDir), ensureDir(diffDir)
]).spread(function(data) { ]).spread(function(data) {
template = data; template = data;
// dirs have been created, template has been read, now rasterize. // dirs have been created, template has been read, now rasterize.
@ -79,14 +79,14 @@ function processTestCase(key) {
var fftLatex = writeFile(texFile, tex).then(function() { var fftLatex = writeFile(texFile, tex).then(function() {
// Step 2: call "pdflatex key" to create key.pdf // Step 2: call "pdflatex key" to create key.pdf
return execFile("pdflatex", [ return execFile("pdflatex", [
"-interaction", "nonstopmode", key, "-interaction", "nonstopmode", key
], {cwd: tmpDir}); ], {cwd: tmpDir});
}).then(function() { }).then(function() {
console.log("Typeset " + key); console.log("Typeset " + key);
// Step 3: call "convert ... key.pdf key.png" to create key.png // Step 3: call "convert ... key.pdf key.png" to create key.png
return execFile("convert", [ return execFile("convert", [
"-density", dpi, "-units", "PixelsPerInch", "-flatten", "-density", dpi, "-units", "PixelsPerInch", "-flatten",
"-depth", "8", pdfFile, pngFile, "-depth", "8", pdfFile, pngFile
]); ]);
}).then(function() { }).then(function() {
console.log("Rasterized " + key); console.log("Rasterized " + key);
@ -167,7 +167,7 @@ function processTestCase(key) {
// First image is red, second green, third blue channel of result // First image is red, second green, third blue channel of result
"-channel", "RGB", "-combine", "-channel", "RGB", "-combine",
"-trim", // remove everything with the same color as the corners "-trim", // remove everything with the same color as the corners
diffFile, // output file name diffFile // output file name
]); ]);
}).then(function() { }).then(function() {
console.log("Compared " + key); console.log("Compared " + key);
@ -244,7 +244,7 @@ function fftImage(image) {
real: real, real: real,
imag: imag, imag: imag,
width: image.width, width: image.width,
height: image.height, height: image.height
}; };
} }

View File

@ -70,5 +70,5 @@ module.exports = {
* to change. Use at your own risk. * to change. Use at your own risk.
*/ */
__parse: generateParseTree, __parse: generateParseTree,
ParseError: ParseError, ParseError: ParseError
}; };

View File

@ -17,7 +17,7 @@
"devDependencies": { "devDependencies": {
"browserify": "^10.2.4", "browserify": "^10.2.4",
"clean-css": "~2.2.15", "clean-css": "~2.2.15",
"eslint": "^1.10.2", "eslint": "^1.10.3",
"express": "~3.3.3", "express": "~3.3.3",
"glob": "^5.0.15", "glob": "^5.0.15",
"jasmine": "^2.3.2", "jasmine": "^2.3.2",

View File

@ -64,7 +64,7 @@ app.get("/katex.css", function(req, res, next) {
less.render(data, { less.render(data, {
paths: [path.join(__dirname, "static")], paths: [path.join(__dirname, "static")],
filename: "katex.less", filename: "katex.less"
}, function(err, output) { }, function(err, output) {
if (err) { if (err) {
console.error(String(err)); console.error(String(err));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -331,7 +331,7 @@ var stackLargeDelimiters = [
"(", ")", "[", "\\lbrack", "]", "\\rbrack", "(", ")", "[", "\\lbrack", "]", "\\rbrack",
"\\{", "\\lbrace", "\\}", "\\rbrace", "\\{", "\\lbrace", "\\}", "\\rbrace",
"\\lfloor", "\\rfloor", "\\lceil", "\\rceil", "\\lfloor", "\\rfloor", "\\lceil", "\\rceil",
"\\surd", "\\surd"
]; ];
// delimiters that always stack // delimiters that always stack
@ -340,12 +340,12 @@ var stackAlwaysDelimiters = [
"\\Uparrow", "\\Downarrow", "\\Updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow",
"|", "\\|", "\\vert", "\\Vert", "|", "\\|", "\\vert", "\\Vert",
"\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lvert", "\\rvert", "\\lVert", "\\rVert",
"\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache", "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache"
]; ];
// and delimiters that never stack // and delimiters that never stack
var stackNeverDelimiters = [ 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 // 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: 1},
{type: "large", size: 2}, {type: "large", size: 2},
{type: "large", size: 3}, {type: "large", size: 3},
{type: "large", size: 4}, {type: "large", size: 4}
]; ];
// Delimiters that always stack try the small delimiters first, then stack // 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.SCRIPTSCRIPT},
{type: "small", style: Style.SCRIPT}, {type: "small", style: Style.SCRIPT},
{type: "small", style: Style.TEXT}, {type: "small", style: Style.TEXT},
{type: "stack"}, {type: "stack"}
]; ];
// Delimiters that stack when large try the small and then large delimiters, and // 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: 2},
{type: "large", size: 3}, {type: "large", size: 3},
{type: "large", size: 4}, {type: "large", size: 4},
{type: "stack"}, {type: "stack"}
]; ];
/** /**
@ -546,5 +546,5 @@ var makeLeftRightDelim = function(delim, height, depth, options, mode,
module.exports = { module.exports = {
sizedDelim: makeSizedDelim, sizedDelim: makeSizedDelim,
customSizedDelim: makeCustomSizedDelim, customSizedDelim: makeCustomSizedDelim,
leftRightDelim: makeLeftRightDelim, leftRightDelim: makeLeftRightDelim
}; };

View File

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

View File

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

View File

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

View File

@ -254,7 +254,7 @@ module.exports = {
"57368": [0.25142, 0.75726, 0, 0], "57368": [0.25142, 0.75726, 0, 0],
"57369": [0.25142, 0.75726, 0, 0], "57369": [0.25142, 0.75726, 0, 0],
"57370": [0.13597, 0.63597, 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": { "Caligraphic-Regular": {
"48": [0, 0.43056, 0, 0], "48": [0, 0.43056, 0, 0],
@ -292,7 +292,7 @@ module.exports = {
"87": [0, 0.68333, 0.08222, 0.08334], "87": [0, 0.68333, 0.08222, 0.08334],
"88": [0, 0.68333, 0.14643, 0.13889], "88": [0, 0.68333, 0.14643, 0.13889],
"89": [0.09722, 0.68333, 0.08222, 0.08334], "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": { "Fraktur-Regular": {
"33": [0, 0.69141, 0, 0], "33": [0, 0.69141, 0, 0],
@ -385,7 +385,7 @@ module.exports = {
"58116": [0.18906, 0.47534, 0, 0], "58116": [0.18906, 0.47534, 0, 0],
"58117": [0, 0.69141, 0, 0], "58117": [0, 0.69141, 0, 0],
"58118": [0, 0.62119, 0, 0], "58118": [0, 0.62119, 0, 0],
"58119": [0, 0.47534, 0, 0], "58119": [0, 0.47534, 0, 0]
}, },
"Main-Bold": { "Main-Bold": {
"33": [0, 0.69444, 0, 0], "33": [0, 0.69444, 0, 0],
@ -640,7 +640,7 @@ module.exports = {
"10217": [0.25, 0.75, 0, 0], "10217": [0.25, 0.75, 0, 0],
"10815": [0, 0.68611, 0, 0], "10815": [0, 0.68611, 0, 0],
"10927": [0.19667, 0.69667, 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": { "Main-Italic": {
"33": [0, 0.69444, 0.12417, 0], "33": [0, 0.69444, 0.12417, 0],
@ -760,7 +760,7 @@ module.exports = {
"8217": [0, 0.69444, 0.12417, 0], "8217": [0, 0.69444, 0.12417, 0],
"8220": [0, 0.69444, 0.1685, 0], "8220": [0, 0.69444, 0.1685, 0],
"8221": [0, 0.69444, 0.06961, 0], "8221": [0, 0.69444, 0.06961, 0],
"8463": [0, 0.68889, 0, 0], "8463": [0, 0.68889, 0, 0]
}, },
"Main-Regular": { "Main-Regular": {
"32": [0, 0, 0, 0], "32": [0, 0, 0, 0],
@ -1041,7 +1041,7 @@ module.exports = {
"10236": [0.011, 0.511, 0, 0], "10236": [0.011, 0.511, 0, 0],
"10815": [0, 0.68333, 0, 0], "10815": [0, 0.68333, 0, 0],
"10927": [0.13597, 0.63597, 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": { "Math-BoldItalic": {
"47": [0.19444, 0.69444, 0, 0], "47": [0.19444, 0.69444, 0, 0],
@ -1137,7 +1137,7 @@ module.exports = {
"981": [0.19444, 0.69444, 0, 0], "981": [0.19444, 0.69444, 0, 0],
"982": [0, 0.44444, 0.03194, 0], "982": [0, 0.44444, 0.03194, 0],
"1009": [0.19444, 0.44444, 0, 0], "1009": [0.19444, 0.44444, 0, 0],
"1013": [0, 0.44444, 0, 0], "1013": [0, 0.44444, 0, 0]
}, },
"Math-Italic": { "Math-Italic": {
"47": [0.19444, 0.69444, 0, 0], "47": [0.19444, 0.69444, 0, 0],
@ -1233,7 +1233,7 @@ module.exports = {
"981": [0.19444, 0.69444, 0, 0.08334], "981": [0.19444, 0.69444, 0, 0.08334],
"982": [0, 0.43056, 0.02778, 0], "982": [0, 0.43056, 0.02778, 0],
"1009": [0.19444, 0.43056, 0, 0.08334], "1009": [0.19444, 0.43056, 0, 0.08334],
"1013": [0, 0.43056, 0, 0.05556], "1013": [0, 0.43056, 0, 0.05556]
}, },
"Math-Regular": { "Math-Regular": {
"65": [0, 0.68333, 0, 0.13889], "65": [0, 0.68333, 0, 0.13889],
@ -1328,7 +1328,7 @@ module.exports = {
"981": [0.19444, 0.69444, 0, 0.08334], "981": [0.19444, 0.69444, 0, 0.08334],
"982": [0, 0.43056, 0.02778, 0], "982": [0, 0.43056, 0.02778, 0],
"1009": [0.19444, 0.43056, 0, 0.08334], "1009": [0.19444, 0.43056, 0, 0.08334],
"1013": [0, 0.43056, 0, 0.05556], "1013": [0, 0.43056, 0, 0.05556]
}, },
"SansSerif-Regular": { "SansSerif-Regular": {
"33": [0, 0.69444, 0, 0], "33": [0, 0.69444, 0, 0],
@ -1447,7 +1447,7 @@ module.exports = {
"8216": [0, 0.69444, 0, 0], "8216": [0, 0.69444, 0, 0],
"8217": [0, 0.69444, 0, 0], "8217": [0, 0.69444, 0, 0],
"8220": [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": { "Script-Regular": {
"65": [0, 0.7, 0.22925, 0], "65": [0, 0.7, 0.22925, 0],
@ -1475,7 +1475,7 @@ module.exports = {
"87": [0, 0.7, 0.27523, 0], "87": [0, 0.7, 0.27523, 0],
"88": [0, 0.7, 0.26006, 0], "88": [0, 0.7, 0.26006, 0],
"89": [0, 0.7, 0.2939, 0], "89": [0, 0.7, 0.2939, 0],
"90": [0, 0.7, 0.24037, 0], "90": [0, 0.7, 0.24037, 0]
}, },
"Size1-Regular": { "Size1-Regular": {
"40": [0.35001, 0.85, 0, 0], "40": [0.35001, 0.85, 0, 0],
@ -1520,7 +1520,7 @@ module.exports = {
"10753": [0.25001, 0.75, 0, 0], "10753": [0.25001, 0.75, 0, 0],
"10754": [0.25001, 0.75, 0, 0], "10754": [0.25001, 0.75, 0, 0],
"10756": [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": { "Size2-Regular": {
"40": [0.65002, 1.15, 0, 0], "40": [0.65002, 1.15, 0, 0],
@ -1557,7 +1557,7 @@ module.exports = {
"10753": [0.55001, 1.05, 0, 0], "10753": [0.55001, 1.05, 0, 0],
"10754": [0.55001, 1.05, 0, 0], "10754": [0.55001, 1.05, 0, 0],
"10756": [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": { "Size3-Regular": {
"40": [0.95003, 1.45, 0, 0], "40": [0.95003, 1.45, 0, 0],
@ -1578,7 +1578,7 @@ module.exports = {
"8970": [0.95003, 1.45, 0, 0], "8970": [0.95003, 1.45, 0, 0],
"8971": [0.95003, 1.45, 0, 0], "8971": [0.95003, 1.45, 0, 0],
"10216": [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": { "Size4-Regular": {
"40": [1.25003, 1.75, 0, 0], "40": [1.25003, 1.75, 0, 0],
@ -1625,7 +1625,7 @@ module.exports = {
"57680": [0, 0.12, 0, 0], "57680": [0, 0.12, 0, 0],
"57681": [0, 0.12, 0, 0], "57681": [0, 0.12, 0, 0],
"57682": [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": { "Typewriter-Regular": {
"33": [0, 0.61111, 0, 0], "33": [0, 0.61111, 0, 0],
@ -1747,6 +1747,6 @@ module.exports = {
"937": [0, 0.61111, 0, 0], "937": [0, 0.61111, 0, 0],
"2018": [0, 0.61111, 0, 0], "2018": [0, 0.61111, 0, 0],
"2019": [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, allowedInText: !!props.allowedInText,
numOptionalArgs: props.numOptionalArgs || 0, numOptionalArgs: props.numOptionalArgs || 0,
infix: !!props.infix, infix: !!props.infix,
handler: handler, handler: handler
}; };
for (var i = 0; i < names.length; ++i) { for (var i = 0; i < names.length; ++i) {
module.exports[names[i]] = data; module.exports[names[i]] = data;
@ -115,14 +115,14 @@ var ordargument = function(arg) {
// A normal square root // A normal square root
defineFunction("\\sqrt", { defineFunction("\\sqrt", {
numArgs: 1, numArgs: 1,
numOptionalArgs: 1, numOptionalArgs: 1
}, function(context, args) { }, function(context, args) {
var index = args[0]; var index = args[0];
var body = args[1]; var body = args[1];
return { return {
type: "sqrt", type: "sqrt",
body: body, body: body,
index: index, index: index
}; };
}); });
@ -130,23 +130,23 @@ defineFunction("\\sqrt", {
var textFunctionStyles = { var textFunctionStyles = {
"\\text": undefined, "\\textrm": "mathrm", "\\textsf": "mathsf", "\\text": undefined, "\\textrm": "mathrm", "\\textsf": "mathsf",
"\\texttt": "mathtt", "\\textnormal": "mathrm", "\\textbf": "mathbf", "\\texttt": "mathtt", "\\textnormal": "mathrm", "\\textbf": "mathbf",
"\\textit": "textit", "\\textit": "textit"
}; };
defineFunction([ defineFunction([
"\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal",
"\\textbf", "\\textit", "\\textbf", "\\textit"
], { ], {
numArgs: 1, numArgs: 1,
argTypes: ["text"], argTypes: ["text"],
greediness: 2, greediness: 2,
allowedInText: true, allowedInText: true
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: "text", type: "text",
body: ordargument(body), body: ordargument(body),
style: textFunctionStyles[context.funcName], style: textFunctionStyles[context.funcName]
}; };
}); });
@ -155,36 +155,36 @@ defineFunction("\\color", {
numArgs: 2, numArgs: 2,
allowedInText: true, allowedInText: true,
greediness: 3, greediness: 3,
argTypes: ["color", "original"], argTypes: ["color", "original"]
}, function(context, args) { }, function(context, args) {
var color = args[0]; var color = args[0];
var body = args[1]; var body = args[1];
return { return {
type: "color", type: "color",
color: color.value, color: color.value,
value: ordargument(body), value: ordargument(body)
}; };
}); });
// An overline // An overline
defineFunction("\\overline", { defineFunction("\\overline", {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: "overline", type: "overline",
body: body, body: body
}; };
}); });
// An underline // An underline
defineFunction("\\underline", { defineFunction("\\underline", {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: "underline", type: "underline",
body: body, body: body
}; };
}); });
@ -192,7 +192,7 @@ defineFunction("\\underline", {
defineFunction("\\rule", { defineFunction("\\rule", {
numArgs: 2, numArgs: 2,
numOptionalArgs: 1, numOptionalArgs: 1,
argTypes: ["size", "size", "size"], argTypes: ["size", "size", "size"]
}, function(context, args) { }, function(context, args) {
var shift = args[0]; var shift = args[0];
var width = args[1]; var width = args[1];
@ -201,7 +201,7 @@ defineFunction("\\rule", {
type: "rule", type: "rule",
shift: shift && shift.value, shift: shift && shift.value,
width: width.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. // mu-units. In current KaTeX we relax this; both commands accept any unit.
defineFunction(["\\kern", "\\mkern"], { defineFunction(["\\kern", "\\mkern"], {
numArgs: 1, numArgs: 1,
argTypes: ["size"], argTypes: ["size"]
}, function(context, args) { }, function(context, args) {
return { return {
type: "kern", type: "kern",
dimension: args[0].value, dimension: args[0].value
}; };
}); });
// A KaTeX logo // A KaTeX logo
defineFunction("\\KaTeX", { defineFunction("\\KaTeX", {
numArgs: 0, numArgs: 0
}, function(context) { }, function(context) {
return { return {
type: "katex", type: "katex"
}; };
}); });
defineFunction("\\phantom", { defineFunction("\\phantom", {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: "phantom", type: "phantom",
value: ordargument(body), value: ordargument(body)
}; };
}); });
// Math class commands except \mathop // Math class commands except \mathop
defineFunction([ defineFunction([
"\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathord", "\\mathbin", "\\mathrel", "\\mathopen",
"\\mathclose", "\\mathpunct", "\\mathinner", "\\mathclose", "\\mathpunct", "\\mathinner"
], { ], {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: "mclass", type: "mclass",
mclass: "m" + context.funcName.substr(5), mclass: "m" + context.funcName.substr(5),
value: ordargument(body), value: ordargument(body)
}; };
}); });
// Build a relation by placing one symbol on top of another // Build a relation by placing one symbol on top of another
defineFunction("\\stackrel", { defineFunction("\\stackrel", {
numArgs: 2, numArgs: 2
}, function(context, args) { }, function(context, args) {
var top = args[0]; var top = args[0];
var bottom = args[1]; var bottom = args[1];
@ -263,41 +263,41 @@ defineFunction("\\stackrel", {
limits: true, limits: true,
alwaysHandleSupSub: true, alwaysHandleSupSub: true,
symbol: false, symbol: false,
value: ordargument(bottom), value: ordargument(bottom)
}, bottom.mode); }, bottom.mode);
var supsub = new ParseNode("supsub", { var supsub = new ParseNode("supsub", {
base: bottomop, base: bottomop,
sup: top, sup: top,
sub: null, sub: null
}, top.mode); }, top.mode);
return { return {
type: "mclass", type: "mclass",
mclass: "mrel", mclass: "mrel",
value: [supsub], value: [supsub]
}; };
}); });
// \mod-type functions // \mod-type functions
defineFunction("\\bmod", { defineFunction("\\bmod", {
numArgs: 0, numArgs: 0
}, function(context, args) { }, function(context, args) {
return { return {
type: "mod", type: "mod",
modType: "bmod", modType: "bmod",
value: null, value: null
}; };
}); });
defineFunction(["\\pod", "\\pmod", "\\mod"], { defineFunction(["\\pod", "\\pmod", "\\mod"], {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: "mod", type: "mod",
modType: context.funcName.substr(1), 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: 1},
"\\Big" : {mclass: "mord", size: 2}, "\\Big" : {mclass: "mord", size: 2},
"\\bigg" : {mclass: "mord", size: 3}, "\\bigg" : {mclass: "mord", size: 3},
"\\Bigg" : {mclass: "mord", size: 4}, "\\Bigg" : {mclass: "mord", size: 4}
}; };
var delimiters = [ var delimiters = [
@ -333,13 +333,13 @@ var delimiters = [
"\\uparrow", "\\Uparrow", "\\uparrow", "\\Uparrow",
"\\downarrow", "\\Downarrow", "\\downarrow", "\\Downarrow",
"\\updownarrow", "\\Updownarrow", "\\updownarrow", "\\Updownarrow",
".", "."
]; ];
var fontAliases = { var fontAliases = {
"\\Bbb": "\\mathbb", "\\Bbb": "\\mathbb",
"\\bold": "\\mathbf", "\\bold": "\\mathbf",
"\\frak": "\\mathfrak", "\\frak": "\\mathfrak"
}; };
// Single-argument color functions // Single-argument color functions
@ -356,17 +356,17 @@ defineFunction([
"\\mintA", "\\mintB", "\\mintC", "\\mintA", "\\mintB", "\\mintC",
"\\grayA", "\\grayB", "\\grayC", "\\grayD", "\\grayE", "\\grayA", "\\grayB", "\\grayC", "\\grayD", "\\grayE",
"\\grayF", "\\grayG", "\\grayH", "\\grayI", "\\grayF", "\\grayG", "\\grayH", "\\grayI",
"\\kaBlue", "\\kaGreen", "\\kaBlue", "\\kaGreen"
], { ], {
numArgs: 1, numArgs: 1,
allowedInText: true, allowedInText: true,
greediness: 3, greediness: 3
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: "color", type: "color",
color: "katex-" + context.funcName.slice(1), color: "katex-" + context.funcName.slice(1),
value: ordargument(body), value: ordargument(body)
}; };
}); });
@ -379,44 +379,44 @@ defineFunction([
"\\arcsin", "\\arccos", "\\arctan", "\\arg", "\\cos", "\\cosh", "\\arcsin", "\\arccos", "\\arctan", "\\arg", "\\cos", "\\cosh",
"\\cot", "\\coth", "\\csc", "\\deg", "\\dim", "\\exp", "\\hom", "\\cot", "\\coth", "\\csc", "\\deg", "\\dim", "\\exp", "\\hom",
"\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh",
"\\tan", "\\tanh", "\\tan", "\\tanh"
], { ], {
numArgs: 0, numArgs: 0
}, function(context) { }, function(context) {
return { return {
type: "op", type: "op",
limits: false, limits: false,
symbol: false, symbol: false,
body: context.funcName, body: context.funcName
}; };
}); });
// Limits, not symbols // Limits, not symbols
defineFunction([ defineFunction([
"\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max", "\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max",
"\\min", "\\Pr", "\\sup", "\\min", "\\Pr", "\\sup"
], { ], {
numArgs: 0, numArgs: 0
}, function(context) { }, function(context) {
return { return {
type: "op", type: "op",
limits: true, limits: true,
symbol: false, symbol: false,
body: context.funcName, body: context.funcName
}; };
}); });
// No limits, symbols // No limits, symbols
defineFunction([ defineFunction([
"\\int", "\\iint", "\\iiint", "\\oint", "\\int", "\\iint", "\\iiint", "\\oint"
], { ], {
numArgs: 0, numArgs: 0
}, function(context) { }, function(context) {
return { return {
type: "op", type: "op",
limits: false, limits: false,
symbol: true, symbol: true,
body: context.funcName, body: context.funcName
}; };
}); });
@ -424,28 +424,28 @@ defineFunction([
defineFunction([ defineFunction([
"\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap",
"\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes",
"\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint"
], { ], {
numArgs: 0, numArgs: 0
}, function(context) { }, function(context) {
return { return {
type: "op", type: "op",
limits: true, limits: true,
symbol: true, symbol: true,
body: context.funcName, body: context.funcName
}; };
}); });
// \mathop class command // \mathop class command
defineFunction("\\mathop", { defineFunction("\\mathop", {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: "op", type: "op",
limits: false, limits: false,
symbol: false, symbol: false,
value: ordargument(body), value: ordargument(body)
}; };
}); });
@ -453,10 +453,10 @@ defineFunction("\\mathop", {
defineFunction([ defineFunction([
"\\dfrac", "\\frac", "\\tfrac", "\\dfrac", "\\frac", "\\tfrac",
"\\dbinom", "\\binom", "\\tbinom", "\\dbinom", "\\binom", "\\tbinom",
"\\\\atopfrac", // cant be entered directly "\\\\atopfrac" // cant be entered directly
], { ], {
numArgs: 2, numArgs: 2,
greediness: 2, greediness: 2
}, function(context, args) { }, function(context, args) {
var numer = args[0]; var numer = args[0];
var denom = args[1]; var denom = args[1];
@ -503,19 +503,19 @@ defineFunction([
hasBarLine: hasBarLine, hasBarLine: hasBarLine,
leftDelim: leftDelim, leftDelim: leftDelim,
rightDelim: rightDelim, rightDelim: rightDelim,
size: size, size: size
}; };
}); });
// Left and right overlap functions // Left and right overlap functions
defineFunction(["\\llap", "\\rlap"], { defineFunction(["\\llap", "\\rlap"], {
numArgs: 1, numArgs: 1,
allowedInText: true, allowedInText: true
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
return { return {
type: context.funcName.slice(1), type: context.funcName.slice(1),
body: body, body: body
}; };
}); });
@ -534,9 +534,9 @@ defineFunction([
"\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl",
"\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr",
"\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm",
"\\big", "\\Big", "\\bigg", "\\Bigg", "\\big", "\\Big", "\\bigg", "\\Bigg"
], { ], {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var delim = checkDelimiter(args[0], context); var delim = checkDelimiter(args[0], context);
@ -544,14 +544,14 @@ defineFunction([
type: "delimsizing", type: "delimsizing",
size: delimiterSizes[context.funcName].size, size: delimiterSizes[context.funcName].size,
mclass: delimiterSizes[context.funcName].mclass, mclass: delimiterSizes[context.funcName].mclass,
value: delim.value, value: delim.value
}; };
}); });
defineFunction([ defineFunction([
"\\left", "\\right", "\\left", "\\right"
], { ], {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var delim = checkDelimiter(args[0], context); var delim = checkDelimiter(args[0], context);
@ -559,12 +559,12 @@ defineFunction([
// why this data doesn't match what is in buildHTML. // why this data doesn't match what is in buildHTML.
return { return {
type: "leftright", type: "leftright",
value: delim.value, value: delim.value
}; };
}); });
defineFunction("\\middle", { defineFunction("\\middle", {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var delim = checkDelimiter(args[0], context); var delim = checkDelimiter(args[0], context);
if (!context.parser.leftrightDepth) { if (!context.parser.leftrightDepth) {
@ -573,21 +573,21 @@ defineFunction("\\middle", {
return { return {
type: "middle", type: "middle",
value: delim.value, value: delim.value
}; };
}); });
// Sizing functions (handled in Parser.js explicitly, hence no handler) // Sizing functions (handled in Parser.js explicitly, hence no handler)
defineFunction([ defineFunction([
"\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\tiny", "\\scriptsize", "\\footnotesize", "\\small",
"\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"
], 0, null); ], 0, null);
// Style changing functions (handled in Parser.js explicitly, hence no // Style changing functions (handled in Parser.js explicitly, hence no
// handler) // handler)
defineFunction([ defineFunction([
"\\displaystyle", "\\textstyle", "\\scriptstyle", "\\displaystyle", "\\textstyle", "\\scriptstyle",
"\\scriptscriptstyle", "\\scriptscriptstyle"
], 0, null); ], 0, null);
defineFunction([ defineFunction([
@ -599,10 +599,10 @@ defineFunction([
"\\mathtt", "\\mathtt",
// aliases // aliases
"\\Bbb", "\\bold", "\\frak", "\\Bbb", "\\bold", "\\frak"
], { ], {
numArgs: 1, numArgs: 1,
greediness: 2, greediness: 2
}, function(context, args) { }, function(context, args) {
var body = args[0]; var body = args[0];
var func = context.funcName; var func = context.funcName;
@ -612,31 +612,31 @@ defineFunction([
return { return {
type: "font", type: "font",
font: func.slice(1), font: func.slice(1),
body: body, body: body
}; };
}); });
// Accents // Accents
defineFunction([ defineFunction([
"\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve",
"\\check", "\\hat", "\\vec", "\\dot", "\\check", "\\hat", "\\vec", "\\dot"
// We don't support expanding accents yet // We don't support expanding accents yet
// "\\widetilde", "\\widehat" // "\\widetilde", "\\widehat"
], { ], {
numArgs: 1, numArgs: 1
}, function(context, args) { }, function(context, args) {
var base = args[0]; var base = args[0];
return { return {
type: "accent", type: "accent",
accent: context.funcName, accent: context.funcName,
base: base, base: base
}; };
}); });
// Infix generalized fractions // Infix generalized fractions
defineFunction(["\\over", "\\choose", "\\atop"], { defineFunction(["\\over", "\\choose", "\\atop"], {
numArgs: 0, numArgs: 0,
infix: true, infix: true
}, function(context) { }, function(context) {
var replaceWith; var replaceWith;
switch (context.funcName) { switch (context.funcName) {
@ -655,7 +655,7 @@ defineFunction(["\\over", "\\choose", "\\atop"], {
return { return {
type: "infix", type: "infix",
replaceWith: replaceWith, replaceWith: replaceWith,
token: context.token, token: context.token
}; };
}); });
@ -663,19 +663,19 @@ defineFunction(["\\over", "\\choose", "\\atop"], {
defineFunction(["\\\\", "\\cr"], { defineFunction(["\\\\", "\\cr"], {
numArgs: 0, numArgs: 0,
numOptionalArgs: 1, numOptionalArgs: 1,
argTypes: ["size"], argTypes: ["size"]
}, function(context, args) { }, function(context, args) {
var size = args[0]; var size = args[0];
return { return {
type: "cr", type: "cr",
size: size, size: size
}; };
}); });
// Environment delimiters // Environment delimiters
defineFunction(["\\begin", "\\end"], { defineFunction(["\\begin", "\\end"], {
numArgs: 1, numArgs: 1,
argTypes: ["text"], argTypes: ["text"]
}, function(context, args) { }, function(context, args) {
var nameGroup = args[0]; var nameGroup = args[0];
if (nameGroup.type !== "ordgroup") { if (nameGroup.type !== "ordgroup") {
@ -688,6 +688,6 @@ defineFunction(["\\begin", "\\end"], {
return { return {
type: "environment", type: "environment",
name: name, name: name,
nameGroup: nameGroup, nameGroup: nameGroup
}; };
}); });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,13 +19,13 @@ beforeEach(function() {
parseTree(actual, defaultSettings); parseTree(actual, defaultSettings);
return { return {
pass: false, pass: false,
message: "'" + actual + "' parsed without error", message: "'" + actual + "' parsed without error"
}; };
} catch (e) { } catch (e) {
if (expected === undefined) { if (expected === undefined) {
return { return {
pass: true, pass: true,
message: "'" + actual + "' parsed with error", message: "'" + actual + "' parsed with error"
}; };
} }
var msg = e.message; var msg = e.message;
@ -34,27 +34,27 @@ beforeEach(function() {
return { return {
pass: true, pass: true,
message: "'" + actual + "'" + message: "'" + actual + "'" +
" parsed with error '" + expected + "'", " parsed with error '" + expected + "'"
}; };
} else if (msg.slice(0, 19) === prefix) { } else if (msg.slice(0, 19) === prefix) {
return { return {
pass: false, pass: false,
message: "'" + actual + "'" + message: "'" + actual + "'" +
" parsed with error '" + msg.slice(19) + " parsed with error '" + msg.slice(19) +
"' but expected '" + expected + "'", "' but expected '" + expected + "'"
}; };
} else { } else {
return { return {
pass: false, pass: false,
message: "'" + actual + "'" + message: "'" + actual + "'" +
" caused error '" + msg + " caused error '" + msg +
"' but expected '" + exp + "'", "' but expected '" + exp + "'"
}; };
} }
} }
}, }
}; };
}, }
}); });
}); });

View File

@ -17,7 +17,7 @@ var Style = require("../src/Style");
var defaultSettings = new Settings({}); var defaultSettings = new Settings({});
var defaultOptions = new Options({ var defaultOptions = new Options({
style: Style.TEXT, style: Style.TEXT,
size: "size5", size: "size5"
}); });
var _getBuilt = function(expr, settings) { var _getBuilt = function(expr, settings) {
@ -97,11 +97,11 @@ beforeEach(function() {
var result = { var result = {
pass: true, pass: true,
message: "'" + actual + "' succeeded parsing", message: "'" + actual + "' succeeded parsing"
}; };
parseAndSetResult(actual, result, usedSettings); parseAndSetResult(actual, result, usedSettings);
return result; return result;
}, }
}; };
}, },
@ -113,7 +113,7 @@ beforeEach(function() {
var result = { var result = {
pass: false, pass: false,
message: "Expected '" + actual + "' to fail " + message: "Expected '" + actual + "' to fail " +
"parsing, but it succeeded", "parsing, but it succeeded"
}; };
try { try {
@ -130,7 +130,7 @@ beforeEach(function() {
} }
return result; return result;
}, }
}; };
}, },
@ -141,7 +141,7 @@ beforeEach(function() {
var result = { var result = {
pass: true, pass: true,
message: "'" + actual + "' succeeded in building", message: "'" + actual + "' succeeded in building"
}; };
expect(actual).toParse(usedSettings); expect(actual).toParse(usedSettings);
@ -160,7 +160,7 @@ beforeEach(function() {
} }
return result; return result;
}, }
}; };
}, },
@ -170,7 +170,7 @@ beforeEach(function() {
var result = { var result = {
pass: true, pass: true,
message: "Parse trees of '" + actual + message: "Parse trees of '" + actual +
"' and '" + expected + "' are equivalent", "' and '" + expected + "' are equivalent"
}; };
var actualTree = parseAndSetResult(actual, result); var actualTree = parseAndSetResult(actual, result);
@ -189,9 +189,9 @@ beforeEach(function() {
"' and '" + expected + "' are not equivalent"; "' and '" + expected + "' are not equivalent";
} }
return result; return result;
}, }
}; };
}, }
}); });
}); });
@ -1177,7 +1177,7 @@ describe("A TeX-compliant parser", function() {
"\\rule{1em}", "\\rule{1em}",
"\\llap", "\\llap",
"\\bigl", "\\bigl",
"\\text", "\\text"
]; ];
for (var i = 0; i < missingGroups.length; i++) { for (var i = 0; i < missingGroups.length; i++) {
@ -1204,7 +1204,7 @@ describe("A TeX-compliant parser", function() {
// work // work
// "\\llap \\frac x y", // "\\llap \\frac x y",
"\\llap \\llap x", "\\llap \\llap x",
"\\sqrt \\llap x", "\\sqrt \\llap x"
]; ];
for (var i = 0; i < badArguments.length; i++) { for (var i = 0; i < badArguments.length; i++) {
@ -1222,7 +1222,7 @@ describe("A TeX-compliant parser", function() {
"\\frac x {\\llap y}", "\\frac x {\\llap y}",
"\\llap {\\frac x y}", "\\llap {\\frac x y}",
"\\llap {\\llap x}", "\\llap {\\llap x}",
"\\sqrt {\\llap x}", "\\sqrt {\\llap x}"
]; ];
for (var i = 0; i < goodArguments.length; i++) { for (var i = 0; i < goodArguments.length; i++) {
@ -1235,7 +1235,7 @@ describe("A TeX-compliant parser", function() {
"x^\\sqrt x", "x^\\sqrt x",
"x^\\llap x", "x^\\llap x",
"x_\\sqrt x", "x_\\sqrt x",
"x_\\llap x", "x_\\llap x"
]; ];
for (var i = 0; i < badSupSubscripts.length; i++) { for (var i = 0; i < badSupSubscripts.length; i++) {
@ -1248,7 +1248,7 @@ describe("A TeX-compliant parser", function() {
"x^{\\sqrt x}", "x^{\\sqrt x}",
"x^{\\llap x}", "x^{\\llap x}",
"x_{\\sqrt x}", "x_{\\sqrt x}",
"x_{\\llap x}", "x_{\\llap x}"
]; ];
for (var i = 0; i < goodSupSubscripts.length; i++) { for (var i = 0; i < goodSupSubscripts.length; i++) {
@ -1287,7 +1287,7 @@ describe("A TeX-compliant parser", function() {
"\\frac x \\left( y \\right)", "\\frac x \\left( y \\right)",
"\\llap \\left( x \\right)", "\\llap \\left( x \\right)",
"\\sqrt \\left( x \\right)", "\\sqrt \\left( x \\right)",
"x^\\left( x \\right)", "x^\\left( x \\right)"
]; ];
for (var i = 0; i < badLeftArguments.length; i++) { for (var i = 0; i < badLeftArguments.length; i++) {
@ -1301,7 +1301,7 @@ describe("A TeX-compliant parser", function() {
"\\frac x {\\left( y \\right)}", "\\frac x {\\left( y \\right)}",
"\\llap {\\left( x \\right)}", "\\llap {\\left( x \\right)}",
"\\sqrt {\\left( x \\right)}", "\\sqrt {\\left( x \\right)}",
"x^{\\left( x \\right)}", "x^{\\left( x \\right)}"
]; ];
for (var i = 0; i < goodLeftArguments.length; i++) { for (var i = 0; i < goodLeftArguments.length; i++) {
@ -1721,17 +1721,17 @@ describe("A parse tree generator", function() {
"base": { "base": {
"type": "mathord", "type": "mathord",
"value": "\\sigma", "value": "\\sigma",
"mode": "math", "mode": "math"
}, },
"sup": { "sup": {
"type": "textord", "type": "textord",
"value": "2", "value": "2",
"mode": "math", "mode": "math"
}, },
"sub": undefined, "sub": undefined
}, },
"mode": "math", "mode": "math"
}, }
])); ]));
}); });
}); });
@ -1860,7 +1860,7 @@ describe("An array environment", function() {
var parse = getParsed("\\begin{array}r1\\\\20\\end{array}"); var parse = getParsed("\\begin{array}r1\\\\20\\end{array}");
expect(parse[0].type).toBe("array"); expect(parse[0].type).toBe("array");
expect(parse[0].value.cols).toEqual([ expect(parse[0].value.cols).toEqual([
{ type: "align", align: "r" }, { type: "align", align: "r" }
]); ]);
}); });
@ -1873,7 +1873,7 @@ describe("An array environment", function() {
{ type: "separator", separator: "|" }, { type: "separator", separator: "|" },
{ type: "separator", separator: "|" }, { type: "separator", separator: "|" },
{ type: "align", align: "c" }, { type: "align", align: "c" },
{ type: "separator", separator: "|" }, { type: "separator", separator: "|" }
]); ]);
}); });
@ -1948,7 +1948,7 @@ describe("A parser that does not throw on unsupported commands", function() {
var errorColor = "#933"; var errorColor = "#933";
var noThrowSettings = new Settings({ var noThrowSettings = new Settings({
throwOnError: false, throwOnError: false,
errorColor: errorColor, errorColor: errorColor
}); });
it("should still parse on unrecognized control sequences", function() { it("should still parse on unrecognized control sequences", function() {
@ -2009,7 +2009,7 @@ describe("A macro expander", function() {
it("should allow for multiple expansion", function() { it("should allow for multiple expansion", function() {
compareParseTree("1\\foo2", "1aa2", { compareParseTree("1\\foo2", "1aa2", {
"\\foo": "\\bar\\bar", "\\foo": "\\bar\\bar",
"\\bar": "a", "\\bar": "a"
}); });
}); });
}); });

View File

@ -7,7 +7,7 @@ var childProcess = require("child_process");
var opts = require("nomnom") var opts = require("nomnom")
.option("spacing", { .option("spacing", {
flag: true, flag: true,
help: "Print mismatches involving spacing commands", help: "Print mismatches involving spacing commands"
}) })
.parse(); .parse();
@ -16,7 +16,7 @@ var keys = Object.keys(symbols.math);
keys.sort(); keys.sort();
var types = [ var types = [
"mathord", "op", "bin", "rel", "open", "close", "punct", "inner", "mathord", "op", "bin", "rel", "open", "close", "punct", "inner",
"spacing", "accent", "textord", "spacing", "accent", "textord"
]; ];
process.nextTick(writeTexFile); process.nextTick(writeTexFile);

View File

@ -36,11 +36,11 @@ describe("unicode", function() {
var result = { var result = {
pass: true, pass: true,
message: "'" + actual + "' succeeded parsing", message: "'" + actual + "' succeeded parsing"
}; };
parseAndSetResult(actual, result, usedSettings); parseAndSetResult(actual, result, usedSettings);
return result; return result;
}, }
}; };
}, },
@ -52,7 +52,7 @@ describe("unicode", function() {
var result = { var result = {
pass: false, pass: false,
message: "Expected '" + actual + "' to fail " + message: "Expected '" + actual + "' to fail " +
"parsing, but it succeeded", "parsing, but it succeeded"
}; };
try { try {
@ -69,9 +69,9 @@ describe("unicode", function() {
} }
return result; return result;
}, }
}; };
}, }
}); });
}); });