From 53e416e2962cfdb3f0dbb54dcc2b6e156b6339c4 Mon Sep 17 00:00:00 2001 From: Martin von Gagern Date: Wed, 11 Jan 2017 13:26:00 +0100 Subject: [PATCH] Revert "Remove trailing commas for IE 9 compatibility" This reverts commit 4d2e46e7f6b57a5ea99ae7802809e88065876f9c. 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. --- .eslintrc | 4 +- contrib/auto-render/auto-render-spec.js | 36 +++--- contrib/auto-render/auto-render.js | 8 +- contrib/auto-render/splitAtDelimiters.js | 8 +- dockers/Screenshotter/screenshotter.js | 30 ++--- dockers/texcmp/texcmp.js | 10 +- katex.js | 2 +- server.js | 2 +- src/Options.js | 14 +- src/Parser.js | 22 ++-- src/Style.js | 8 +- src/buildCommon.js | 44 +++---- src/buildHTML.js | 32 ++--- src/buildMathML.js | 12 +- src/buildTree.js | 4 +- src/delimiter.js | 14 +- src/domTree.js | 4 +- src/environments.js | 30 ++--- src/fontMetrics.js | 10 +- src/fontMetricsData.js | 34 ++--- src/functions.js | 158 +++++++++++------------ src/mathMLTree.js | 2 +- src/parseData.js | 2 +- src/symbols.js | 4 +- src/unicodeRegexes.js | 2 +- src/utils.js | 4 +- test/errors-spec.js | 14 +- test/katex-spec.js | 52 ++++---- test/symgroups.js | 4 +- test/unicode-spec.js | 10 +- 30 files changed, 289 insertions(+), 291 deletions(-) diff --git a/.eslintrc b/.eslintrc index 1719fd16..d0042426 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,9 +4,7 @@ "brace-style": [2, "1tbs", { "allowSingleLine": true }], // We'd possibly like to remove the 'properties': 'never' one day. "camelcase": [2, { "properties": "never" }], - // 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-dangle": [2, "always-multiline"], "comma-spacing": [2, { "before": false, "after": true }], "constructor-super": 2, "curly": 2, diff --git a/contrib/auto-render/auto-render-spec.js b/contrib/auto-render/auto-render-spec.js index 6cdd4e44..6b526a46 100644 --- a/contrib/auto-render/auto-render-spec.js +++ b/contrib/auto-render/auto-render-spec.js @@ -13,7 +13,7 @@ beforeEach(function() { compare: function(actual, left, right, result) { var message = { pass: true, - message: "'" + actual + "' split correctly" + message: "'" + actual + "' split correctly", }; var startData = [{type: "text", data: actual}]; @@ -59,9 +59,9 @@ beforeEach(function() { } return message; - } + }, }; - } + }, }); }); @@ -75,7 +75,7 @@ describe("A delimiter splitter", function() { "(", ")", [ {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( "(", ")", [ - {type: "text", data: "hello ) world"} + {type: "text", data: "hello ) world"}, ]); }); @@ -94,7 +94,7 @@ describe("A delimiter splitter", function() { {type: "text", data: "hello "}, {type: "math", data: " world ", 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: "math", data: " world ", 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: "math", data: " more ", 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 ", rawData: "( world )", display: false}, {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: "math", data: " world { ) } ", rawData: "( world { ) } )", display: false}, - {type: "text", data: " boo"} + {type: "text", data: " boo"}, ]); expect("hello ( world { { } ) } ) boo").toSplitInto( @@ -151,7 +151,7 @@ describe("A delimiter splitter", function() { {type: "text", data: "hello "}, {type: "math", data: " world { { } ) } ", 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: "math", data: " world \\) ", rawData: "( world \\) )", display: false}, - {type: "text", data: " boo"} + {type: "text", data: " boo"}, ]); /* TODO(emily): make this work maybe? @@ -184,7 +184,7 @@ describe("A delimiter splitter", function() { {type: "text", data: "hello "}, {type: "math", data: " world ", 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: "math", data: " world ", rawData: "( world )", display: true}, - {type: "text", data: " boo"} + {type: "text", data: " boo"}, ]); }); @@ -204,7 +204,7 @@ describe("A delimiter splitter", function() { var startData = [ {type: "text", data: "hello ( world ) boo"}, {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( @@ -217,7 +217,7 @@ describe("A delimiter splitter", function() { {type: "text", data: "hello "}, {type: "math", data: " world ", rawData: "( world )", display: false}, - {type: "text", data: " boo"} + {type: "text", data: " boo"}, ]); }); @@ -225,7 +225,7 @@ describe("A delimiter splitter", function() { var startData = [ {type: "text", 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( @@ -235,7 +235,7 @@ describe("A delimiter splitter", function() { rawData: "( world )", display: false}, {type: "text", data: " boo"}, {type: "math", data: "hello ( world ) boo", - rawData: "(hello ( world ) boo)", display: true} + rawData: "(hello ( world ) boo)", display: true}, ]); }); }); diff --git a/contrib/auto-render/auto-render.js b/contrib/auto-render/auto-render.js index 9a236529..62449ed8 100644 --- a/contrib/auto-render/auto-render.js +++ b/contrib/auto-render/auto-render.js @@ -27,7 +27,7 @@ var renderMathInText = function(text, delimiters) { var math = data[i].data; try { katex.render(math, span, { - displayMode: data[i].display + displayMode: data[i].display, }); } catch (e) { if (!(e instanceof katex.ParseError)) { @@ -73,14 +73,14 @@ var defaultOptions = { delimiters: [ {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: // {left: "$", right: "$", display: false}, ], ignoredTags: [ - "script", "noscript", "style", "textarea", "pre", "code" - ] + "script", "noscript", "style", "textarea", "pre", "code", + ], }; var extend = function(obj) { diff --git a/contrib/auto-render/splitAtDelimiters.js b/contrib/auto-render/splitAtDelimiters.js index 46bac078..13b3af7a 100644 --- a/contrib/auto-render/splitAtDelimiters.js +++ b/contrib/auto-render/splitAtDelimiters.js @@ -43,7 +43,7 @@ var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) { currIndex = nextIndex; finalData.push({ type: "text", - data: text.slice(0, currIndex) + data: text.slice(0, currIndex), }); lookingForLeft = false; } @@ -57,7 +57,7 @@ var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) { finalData.push({ type: "text", - data: text.slice(currIndex, nextIndex) + data: text.slice(currIndex, nextIndex), }); currIndex = nextIndex; @@ -78,7 +78,7 @@ var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) { rawData: text.slice( currIndex, nextIndex + rightDelim.length), - display: display + display: display, }); currIndex = nextIndex + rightDelim.length; @@ -89,7 +89,7 @@ var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) { finalData.push({ type: "text", - data: text.slice(currIndex) + data: text.slice(currIndex), }); } else { finalData.push(startData[i]); diff --git a/dockers/Screenshotter/screenshotter.js b/dockers/Screenshotter/screenshotter.js index dd3c6352..dc31cb52 100644 --- a/dockers/Screenshotter/screenshotter.js +++ b/dockers/Screenshotter/screenshotter.js @@ -25,52 +25,52 @@ var opts = require("nomnom") .option("browser", { abbr: "b", "default": "firefox", - help: "Name of the browser to use" + help: "Name of the browser to use", }) .option("container", { abbr: "c", 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", { full: "selenium-url", - help: "Full URL of the Selenium web driver" + help: "Full URL of the Selenium web driver", }) .option("seleniumIP", { full: "selenium-ip", - help: "IP address of the Selenium web driver" + help: "IP address of the Selenium web driver", }) .option("seleniumPort", { full: "selenium-port", "default": 4444, - help: "Port number of the Selenium web driver" + help: "Port number of the Selenium web driver", }) .option("katexURL", { full: "katex-url", - help: "Full URL of the KaTeX development server" + help: "Full URL of the KaTeX development server", }) .option("katexIP", { full: "katex-ip", - help: "Full URL of the KaTeX development server" + help: "Full URL of the KaTeX development server", }) .option("katexPort", { full: "katex-port", - help: "Port number of the KaTeX development server" + help: "Port number of the KaTeX development server", }) .option("include", { abbr: "i", - help: "Comma-separated list of test cases to process" + help: "Comma-separated list of test cases to process", }) .option("exclude", { abbr: "x", - help: "Comma-separated list of test cases to exclude" + help: "Comma-separated list of test cases to exclude", }) .option("verify", { flag: true, - help: "Check whether screenshot matches current file content" + help: "Check whether screenshot matches current file content", }) .option("wait", { - help: "Wait this many seconds between page load and screenshot" + help: "Wait this many seconds between page load and screenshot", }) .parse(); @@ -208,7 +208,7 @@ function tryConnect() { } var sock = net.connect({ host: seleniumIP, - port: +seleniumPort + port: +seleniumPort, }); sock.on("connect", function() { sock.end(); @@ -278,7 +278,7 @@ function imageDimensions(img) { return { buf: buf, width: buf.readUInt32BE(16), - height: buf.readUInt32BE(20) + height: buf.readUInt32BE(20), }; } @@ -399,7 +399,7 @@ function takeScreenshot(key) { } } var opt = new jspngopt.Optimizer({ - pako: pako + pako: pako, }); var buf = opt.bufferSync(img.buf); if (loadExpected) { diff --git a/dockers/texcmp/texcmp.js b/dockers/texcmp/texcmp.js index 517a4b44..95d12520 100644 --- a/dockers/texcmp/texcmp.js +++ b/dockers/texcmp/texcmp.js @@ -49,7 +49,7 @@ Q.all([ readFile(path.join(ssDir, "test.tex"), "utf-8"), ensureDir(tmpDir), ensureDir(teximgDir), - ensureDir(diffDir) + ensureDir(diffDir), ]).spread(function(data) { template = data; // dirs have been created, template has been read, now rasterize. @@ -80,14 +80,14 @@ function processTestCase(key) { var fftLatex = writeFile(texFile, tex).then(function() { // Step 2: call "pdflatex key" to create key.pdf return execFile("pdflatex", [ - "-interaction", "nonstopmode", key + "-interaction", "nonstopmode", key, ], {cwd: tmpDir}); }).then(function() { console.log("Typeset " + key); // Step 3: call "convert ... key.pdf key.png" to create key.png return execFile("convert", [ "-density", dpi, "-units", "PixelsPerInch", "-flatten", - "-depth", "8", pdfFile, pngFile + "-depth", "8", pdfFile, pngFile, ]); }).then(function() { console.log("Rasterized " + key); @@ -168,7 +168,7 @@ function processTestCase(key) { // First image is red, second green, third blue channel of result "-channel", "RGB", "-combine", "-trim", // remove everything with the same color as the corners - diffFile // output file name + diffFile, // output file name ]); }).then(function() { console.log("Compared " + key); @@ -245,7 +245,7 @@ function fftImage(image) { real: real, imag: imag, width: image.width, - height: image.height + height: image.height, }; } diff --git a/katex.js b/katex.js index 5844f363..4d64606b 100644 --- a/katex.js +++ b/katex.js @@ -70,5 +70,5 @@ module.exports = { * to change. Use at your own risk. */ __parse: generateParseTree, - ParseError: ParseError + ParseError: ParseError, }; diff --git a/server.js b/server.js index f9036937..979561f9 100644 --- a/server.js +++ b/server.js @@ -64,7 +64,7 @@ app.get("/katex.css", function(req, res, next) { less.render(data, { paths: [path.join(__dirname, "static")], - filename: "katex.less" + filename: "katex.less", }, function(err, output) { if (err) { console.error(String(err)); diff --git a/src/Options.js b/src/Options.js index 7f3e126f..e5de594e 100644 --- a/src/Options.js +++ b/src/Options.js @@ -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", }; /** diff --git a/src/Parser.js b/src/Parser.js index 915f3daf..ebd066ec 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -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); diff --git a/src/Style.js b/src/Style.js index f690c3e1..5cf2e6f5 100644 --- a/src/Style.js +++ b/src/Style.js @@ -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], }; diff --git a/src/buildCommon.js b/src/buildCommon.js index 223e12e7..bbd174d3 100644 --- a/src/buildCommon.js +++ b/src/buildCommon.js @@ -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, }; diff --git a/src/buildHTML.js b/src/buildHTML.js index 0f3bc0fb..8255b017 100644 --- a/src/buildHTML.js +++ b/src/buildHTML.js @@ -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 diff --git a/src/buildMathML.js b/src/buildMathML.js index f56e7e0a..6c17d418 100644 --- a/src/buildMathML.js +++ b/src/buildMathML.js @@ -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; diff --git a/src/buildTree.js b/src/buildTree.js index 03ade9eb..4a8c2aed 100644 --- a/src/buildTree.js +++ b/src/buildTree.js @@ -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) { diff --git a/src/delimiter.js b/src/delimiter.js index d27bbec0..0dbc8c5f 100644 --- a/src/delimiter.js +++ b/src/delimiter.js @@ -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, }; diff --git a/src/domTree.js b/src/domTree.js index 7e2cbff4..f09ff4e2 100644 --- a/src/domTree.js +++ b/src/domTree.js @@ -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, }; diff --git a/src/environments.js b/src/environments.js index 02c9fdf0..9f899758 100644 --- a/src/environments.js +++ b/src/environments.js @@ -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; diff --git a/src/fontMetrics.js b/src/fontMetrics.js index cdf9cd2e..7e78f2a4 100644 --- a/src/fontMetrics.js +++ b/src/fontMetrics.js @@ -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, }; diff --git a/src/fontMetricsData.js b/src/fontMetricsData.js index b010284c..957f55b8 100644 --- a/src/fontMetricsData.js +++ b/src/fontMetricsData.js @@ -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], + }, }; diff --git a/src/functions.js b/src/functions.js index f2f06b72..20e7134e 100644 --- a/src/functions.js +++ b/src/functions.js @@ -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" // can’t be entered directly + "\\\\atopfrac", // can’t 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, }; }); diff --git a/src/mathMLTree.js b/src/mathMLTree.js index 0c7d441c..86e63562 100644 --- a/src/mathMLTree.js +++ b/src/mathMLTree.js @@ -98,5 +98,5 @@ TextNode.prototype.toMarkup = function() { module.exports = { MathNode: MathNode, - TextNode: TextNode + TextNode: TextNode, }; diff --git a/src/parseData.js b/src/parseData.js index 3912445d..61ebd069 100644 --- a/src/parseData.js +++ b/src/parseData.js @@ -27,6 +27,6 @@ function ParseNode(type, value, mode, firstToken, lastToken) { } module.exports = { - ParseNode: ParseNode + ParseNode: ParseNode, }; diff --git a/src/symbols.js b/src/symbols.js index 6ac6548d..a4250c79 100644 --- a/src/symbols.js +++ b/src/symbols.js @@ -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, }; } diff --git a/src/unicodeRegexes.js b/src/unicodeRegexes.js index 183f8dbc..a05d7cd5 100644 --- a/src/unicodeRegexes.js +++ b/src/unicodeRegexes.js @@ -11,5 +11,5 @@ var cjkRegex = module.exports = { cjkRegex: cjkRegex, - hangulRegex: hangulRegex + hangulRegex: hangulRegex, }; diff --git a/src/utils.js b/src/utils.js index 67f121d5..f9e57cc6 100644 --- a/src/utils.js +++ b/src/utils.js @@ -51,7 +51,7 @@ var ESCAPE_LOOKUP = { ">": ">", "<": "<", "\"": """, - "'": "'" + "'": "'", }; var ESCAPE_REGEX = /[&><"']/g; @@ -102,5 +102,5 @@ module.exports = { hyphenate: hyphenate, indexOf: indexOf, setTextContent: setTextContent, - clearNode: clearNode + clearNode: clearNode, }; diff --git a/test/errors-spec.js b/test/errors-spec.js index b0da8fc7..02f6b241 100644 --- a/test/errors-spec.js +++ b/test/errors-spec.js @@ -19,13 +19,13 @@ beforeEach(function() { parseTree(actual, defaultSettings); return { pass: false, - message: "'" + actual + "' parsed without error" + message: "'" + actual + "' parsed without error", }; } catch (e) { if (expected === undefined) { return { pass: true, - message: "'" + actual + "' parsed with error" + message: "'" + actual + "' parsed with error", }; } var msg = e.message; @@ -34,27 +34,27 @@ beforeEach(function() { return { pass: true, message: "'" + actual + "'" + - " parsed with error '" + expected + "'" + " parsed with error '" + expected + "'", }; } else if (msg.slice(0, 19) === prefix) { return { pass: false, message: "'" + actual + "'" + " parsed with error '" + msg.slice(19) + - "' but expected '" + expected + "'" + "' but expected '" + expected + "'", }; } else { return { pass: false, message: "'" + actual + "'" + " caused error '" + msg + - "' but expected '" + exp + "'" + "' but expected '" + exp + "'", }; } } - } + }, }; - } + }, }); }); diff --git a/test/katex-spec.js b/test/katex-spec.js index 88d5ca7f..9f2242c4 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -17,7 +17,7 @@ var Style = require("../src/Style"); var defaultSettings = new Settings({}); var defaultOptions = new Options({ style: Style.TEXT, - size: "size5" + size: "size5", }); var _getBuilt = function(expr, settings) { @@ -97,11 +97,11 @@ beforeEach(function() { var result = { pass: true, - message: "'" + actual + "' succeeded parsing" + message: "'" + actual + "' succeeded parsing", }; parseAndSetResult(actual, result, usedSettings); return result; - } + }, }; }, @@ -113,7 +113,7 @@ beforeEach(function() { var result = { pass: false, message: "Expected '" + actual + "' to fail " + - "parsing, but it succeeded" + "parsing, but it succeeded", }; try { @@ -130,7 +130,7 @@ beforeEach(function() { } return result; - } + }, }; }, @@ -141,7 +141,7 @@ beforeEach(function() { var result = { pass: true, - message: "'" + actual + "' succeeded in building" + message: "'" + actual + "' succeeded in building", }; expect(actual).toParse(usedSettings); @@ -160,7 +160,7 @@ beforeEach(function() { } return result; - } + }, }; }, @@ -170,7 +170,7 @@ beforeEach(function() { var result = { pass: true, message: "Parse trees of '" + actual + - "' and '" + expected + "' are equivalent" + "' and '" + expected + "' are equivalent", }; var actualTree = parseAndSetResult(actual, result); @@ -189,9 +189,9 @@ beforeEach(function() { "' and '" + expected + "' are not equivalent"; } return result; - } + }, }; - } + }, }); }); @@ -1177,7 +1177,7 @@ describe("A TeX-compliant parser", function() { "\\rule{1em}", "\\llap", "\\bigl", - "\\text" + "\\text", ]; for (var i = 0; i < missingGroups.length; i++) { @@ -1204,7 +1204,7 @@ describe("A TeX-compliant parser", function() { // work // "\\llap \\frac x y", "\\llap \\llap x", - "\\sqrt \\llap x" + "\\sqrt \\llap x", ]; for (var i = 0; i < badArguments.length; i++) { @@ -1222,7 +1222,7 @@ describe("A TeX-compliant parser", function() { "\\frac x {\\llap y}", "\\llap {\\frac x y}", "\\llap {\\llap x}", - "\\sqrt {\\llap x}" + "\\sqrt {\\llap x}", ]; for (var i = 0; i < goodArguments.length; i++) { @@ -1235,7 +1235,7 @@ describe("A TeX-compliant parser", function() { "x^\\sqrt x", "x^\\llap x", "x_\\sqrt x", - "x_\\llap x" + "x_\\llap x", ]; for (var i = 0; i < badSupSubscripts.length; i++) { @@ -1248,7 +1248,7 @@ describe("A TeX-compliant parser", function() { "x^{\\sqrt x}", "x^{\\llap x}", "x_{\\sqrt x}", - "x_{\\llap x}" + "x_{\\llap x}", ]; for (var i = 0; i < goodSupSubscripts.length; i++) { @@ -1287,7 +1287,7 @@ describe("A TeX-compliant parser", function() { "\\frac x \\left( y \\right)", "\\llap \\left( x \\right)", "\\sqrt \\left( x \\right)", - "x^\\left( x \\right)" + "x^\\left( x \\right)", ]; for (var i = 0; i < badLeftArguments.length; i++) { @@ -1301,7 +1301,7 @@ describe("A TeX-compliant parser", function() { "\\frac x {\\left( y \\right)}", "\\llap {\\left( x \\right)}", "\\sqrt {\\left( x \\right)}", - "x^{\\left( x \\right)}" + "x^{\\left( x \\right)}", ]; for (var i = 0; i < goodLeftArguments.length; i++) { @@ -1721,17 +1721,17 @@ describe("A parse tree generator", function() { "base": { "type": "mathord", "value": "\\sigma", - "mode": "math" + "mode": "math", }, "sup": { "type": "textord", "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}"); expect(parse[0].type).toBe("array"); 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: "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 noThrowSettings = new Settings({ throwOnError: false, - errorColor: errorColor + errorColor: errorColor, }); 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() { compareParseTree("1\\foo2", "1aa2", { "\\foo": "\\bar\\bar", - "\\bar": "a" + "\\bar": "a", }); }); }); diff --git a/test/symgroups.js b/test/symgroups.js index 33f4bcd4..20a160ff 100644 --- a/test/symgroups.js +++ b/test/symgroups.js @@ -7,7 +7,7 @@ var childProcess = require("child_process"); var opts = require("nomnom") .option("spacing", { flag: true, - help: "Print mismatches involving spacing commands" + help: "Print mismatches involving spacing commands", }) .parse(); @@ -16,7 +16,7 @@ var keys = Object.keys(symbols.math); keys.sort(); var types = [ "mathord", "op", "bin", "rel", "open", "close", "punct", "inner", - "spacing", "accent", "textord" + "spacing", "accent", "textord", ]; process.nextTick(writeTexFile); diff --git a/test/unicode-spec.js b/test/unicode-spec.js index 8174dfbb..a78a83aa 100644 --- a/test/unicode-spec.js +++ b/test/unicode-spec.js @@ -36,11 +36,11 @@ describe("unicode", function() { var result = { pass: true, - message: "'" + actual + "' succeeded parsing" + message: "'" + actual + "' succeeded parsing", }; parseAndSetResult(actual, result, usedSettings); return result; - } + }, }; }, @@ -52,7 +52,7 @@ describe("unicode", function() { var result = { pass: false, message: "Expected '" + actual + "' to fail " + - "parsing, but it succeeded" + "parsing, but it succeeded", }; try { @@ -69,9 +69,9 @@ describe("unicode", function() { } return result; - } + }, }; - } + }, }); });