commit
9ad50178f1
86
.eslintrc
Normal file
86
.eslintrc
Normal file
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
"rules": {
|
||||
"arrow-spacing": 2,
|
||||
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
|
||||
// We'd possibly like to remove the 'properties': 'never' one day.
|
||||
"camelcase": [2, { "properties": "never" }],
|
||||
"comma-dangle": [2, "always-multiline"],
|
||||
"comma-spacing": [2, { "before": false, "after": true }],
|
||||
"constructor-super": 2,
|
||||
"curly": 2,
|
||||
"eol-last": 2,
|
||||
"eqeqeq": [2, "allow-null"],
|
||||
"guard-for-in": 2,
|
||||
"indent": [2, 4, {"SwitchCase": 1}],
|
||||
"linebreak-style": [2, "unix"],
|
||||
"max-len": [2, 80, 4, { "ignoreUrls": true, "ignorePattern": "\\brequire\\([\"']|eslint-disable" }],
|
||||
"no-alert": 2,
|
||||
"no-array-constructor": 2,
|
||||
"no-console": 2,
|
||||
"no-const-assign": 2,
|
||||
"no-debugger": 2,
|
||||
"no-dupe-class-members": 2,
|
||||
"no-dupe-keys": 2,
|
||||
"no-extra-bind": 2,
|
||||
"no-new": 2,
|
||||
"no-new-func": 2,
|
||||
"no-new-object": 2,
|
||||
"no-spaced-func": 2,
|
||||
"no-this-before-super": 2,
|
||||
"no-throw-literal": 2,
|
||||
"no-trailing-spaces": 2,
|
||||
"no-undef": 2,
|
||||
"no-unexpected-multiline": 2,
|
||||
"no-unreachable": 2,
|
||||
"no-unused-vars": [2, {"args": "none", "varsIgnorePattern": "^_*$"}],
|
||||
"no-useless-call": 2,
|
||||
"no-with": 2,
|
||||
"one-var": [2, "never"],
|
||||
"prefer-const": 2,
|
||||
"prefer-spread": 2,
|
||||
"semi": [2, "always"],
|
||||
"space-after-keywords": 2,
|
||||
"space-before-blocks": 2,
|
||||
"space-before-function-paren": [2, "never"],
|
||||
"space-before-keywords": 2,
|
||||
"space-infix-ops": 2,
|
||||
"space-return-throw-case": 2,
|
||||
"space-unary-ops": 2,
|
||||
// ---------------------------------------
|
||||
// Stuff we explicitly disable.
|
||||
// We turned this off because it complains when you have a
|
||||
// multi-line string, which I think is going too far.
|
||||
"prefer-template": 0,
|
||||
// We've decided explicitly not to care about this.
|
||||
"arrow-parens": 0,
|
||||
// ---------------------------------------
|
||||
// Stuff that's disabled for now, but maybe shouldn't be.
|
||||
// disabled because KaTeX doesn't use ES6
|
||||
"no-var": 0,
|
||||
// TODO(csilvers): enable these if/when community agrees on it.
|
||||
"prefer-arrow-callback": 0,
|
||||
"object-curly-spacing": [0, "always"],
|
||||
// Might be nice to turn this on one day, but since we don't
|
||||
// use jsdoc anywhere it seems silly to require it yet.
|
||||
"valid-jsdoc": 0,
|
||||
"require-jsdoc": 0
|
||||
},
|
||||
"ecmaFeatures": {
|
||||
"arrowFunctions": true,
|
||||
"blockBindings": true,
|
||||
"classes": true,
|
||||
"destructuring": true,
|
||||
"experimentalObjectRestSpread": true,
|
||||
"forOf": true,
|
||||
"jsx": true,
|
||||
"restParams": true,
|
||||
"spread": true,
|
||||
"templateStrings": true
|
||||
},
|
||||
"env": {
|
||||
// "es6": true,
|
||||
"node": true,
|
||||
"browser": true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
68
.jshintrc
68
.jshintrc
|
@ -1,68 +0,0 @@
|
|||
{
|
||||
"bitwise" : true,
|
||||
"camelcase" : true,
|
||||
"curly" : true,
|
||||
"eqeqeq" : false,
|
||||
"es3" : true,
|
||||
"forin" : false,
|
||||
"immed" : true,
|
||||
"indent" : 4,
|
||||
"latedef" : false,
|
||||
"newcap" : true,
|
||||
"noarg" : true,
|
||||
"noempty" : true,
|
||||
"nonbsp" : true,
|
||||
"nonew" : true,
|
||||
"plusplus" : false,
|
||||
"quotmark" : "double",
|
||||
"undef" : true,
|
||||
"unused" : "vars",
|
||||
"strict" : false,
|
||||
"trailing" : true,
|
||||
"maxparams" : 7,
|
||||
"maxdepth" : 6,
|
||||
|
||||
"asi" : false,
|
||||
"boss" : false,
|
||||
"debug" : false,
|
||||
"eqnull" : true,
|
||||
"esnext" : false,
|
||||
"evil" : false,
|
||||
"expr" : true,
|
||||
"funcscope" : false,
|
||||
"globalstrict" : false,
|
||||
"iterator" : false,
|
||||
"lastsemic" : false,
|
||||
"laxbreak" : true,
|
||||
"laxcomma" : false,
|
||||
"loopfunc" : false,
|
||||
"maxerr" : 50,
|
||||
"multistr" : false,
|
||||
"notypeof" : false,
|
||||
"proto" : true,
|
||||
"scripturl" : false,
|
||||
"smarttabs" : false,
|
||||
"shadow" : false,
|
||||
"sub" : false,
|
||||
"supernew" : false,
|
||||
"validthis" : false,
|
||||
"noyield" : false,
|
||||
|
||||
"browser" : true,
|
||||
"couch" : false,
|
||||
"devel" : false,
|
||||
"dojo" : false,
|
||||
"jquery" : false,
|
||||
"mootools" : false,
|
||||
"node" : true,
|
||||
"nonstandard" : false,
|
||||
"prototypejs" : false,
|
||||
"rhino" : false,
|
||||
"worker" : false,
|
||||
"wsh" : false,
|
||||
"yui" : false,
|
||||
"globals": {
|
||||
"JSON": false,
|
||||
"console": true
|
||||
}
|
||||
}
|
2
Makefile
2
Makefile
|
@ -17,7 +17,7 @@ setup:
|
|||
npm install
|
||||
|
||||
lint: katex.js server.js cli.js $(wildcard src/*.js) $(wildcard test/*.js) $(wildcard contrib/*/*.js) $(wildcard dockers/*/*.js)
|
||||
./node_modules/.bin/jshint $^
|
||||
./node_modules/.bin/eslint --fix $^
|
||||
|
||||
build/katex.js: katex.js $(wildcard src/*.js)
|
||||
$(BROWSERIFY) $< --standalone katex > $@
|
||||
|
|
5
cli.js
5
cli.js
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
// Simple CLI for KaTeX.
|
||||
// Reads TeX from stdin, outputs HTML to stdout.
|
||||
/* eslint no-console:0 */
|
||||
|
||||
var katex = require("./");
|
||||
var input = "";
|
||||
|
@ -8,7 +9,7 @@ var input = "";
|
|||
// Skip the first two args, which are just "node" and "cli.js"
|
||||
var args = process.argv.slice(2);
|
||||
|
||||
if (args.indexOf("--help") != -1) {
|
||||
if (args.indexOf("--help") !== -1) {
|
||||
console.log(process.argv[0] + " " + process.argv[1] +
|
||||
" [ --help ]" +
|
||||
" [ --display-mode ]");
|
||||
|
@ -25,7 +26,7 @@ process.stdin.on("data", function(chunk) {
|
|||
});
|
||||
|
||||
process.stdin.on("end", function() {
|
||||
var options = { displayMode: args.indexOf("--display-mode") != -1 };
|
||||
var options = { displayMode: args.indexOf("--display-mode") !== -1 };
|
||||
var output = katex.renderToString(input, options);
|
||||
console.log(output);
|
||||
});
|
||||
|
|
|
@ -13,12 +13,13 @@ 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}];
|
||||
|
||||
var split = splitAtDelimiters(startData, left, right, false);
|
||||
var split =
|
||||
splitAtDelimiters(startData, left, right, false);
|
||||
|
||||
if (split.length !== result.length) {
|
||||
message.pass = false;
|
||||
|
@ -58,9 +59,9 @@ beforeEach(function() {
|
|||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -69,12 +70,12 @@ describe("A delimiter splitter", function() {
|
|||
expect("hello").toSplitInto("(", ")", [{type: "text", data: "hello"}]);
|
||||
});
|
||||
|
||||
it("doesn't create a math node when there's only a left delimiter", function() {
|
||||
it("doesn't create a math node with only one left delimiter", function() {
|
||||
expect("hello ( world").toSplitInto(
|
||||
"(", ")",
|
||||
[
|
||||
{type: "text", data: "hello "},
|
||||
{type: "text", data: "( world"}
|
||||
{type: "text", data: "( world"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -82,7 +83,7 @@ describe("A delimiter splitter", function() {
|
|||
expect("hello ) world").toSplitInto(
|
||||
"(", ")",
|
||||
[
|
||||
{type: "text", data: "hello ) world"}
|
||||
{type: "text", data: "hello ) world"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -93,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"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -104,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"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -118,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"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -130,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"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -141,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(
|
||||
|
@ -150,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"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -161,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?
|
||||
|
@ -171,7 +172,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"},
|
||||
]);
|
||||
*/
|
||||
});
|
||||
|
@ -183,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"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -195,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"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -203,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(
|
||||
|
@ -216,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"},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -224,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(
|
||||
|
@ -234,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},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-console:0 */
|
||||
/* global katex */
|
||||
|
||||
var splitAtDelimiters = require("./splitAtDelimiters");
|
||||
|
@ -26,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)) {
|
||||
|
@ -72,19 +73,20 @@ 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}
|
||||
// {left: "$", right: "$", display: false},
|
||||
],
|
||||
|
||||
ignoredTags: [
|
||||
"script", "noscript", "style", "textarea", "pre", "code"
|
||||
]
|
||||
"script", "noscript", "style", "textarea", "pre", "code",
|
||||
],
|
||||
};
|
||||
|
||||
var extend = function(obj) {
|
||||
// Adapted from underscore.js' `_.extend`. See LICENSE.txt for license.
|
||||
var source, prop;
|
||||
var source;
|
||||
var prop;
|
||||
for (var i = 1, length = arguments.length; i < length; i++) {
|
||||
source = arguments[i];
|
||||
for (prop in source) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-constant-condition:0 */
|
||||
var findEndOfMath = function(delimiter, text, startIndex) {
|
||||
// Adapted from
|
||||
// https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx
|
||||
|
@ -42,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;
|
||||
}
|
||||
|
@ -56,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;
|
||||
|
@ -77,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;
|
||||
|
@ -88,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]);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-console:0, prefer-spread:0 */
|
||||
"use strict";
|
||||
|
||||
var childProcess = require("child_process");
|
||||
|
@ -23,50 +24,50 @@ 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",
|
||||
"default": "localhost",
|
||||
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",
|
||||
})
|
||||
.parse();
|
||||
|
||||
|
@ -185,7 +186,7 @@ function tryConnect() {
|
|||
}
|
||||
var sock = net.connect({
|
||||
host: seleniumIP,
|
||||
port: +seleniumPort
|
||||
port: +seleniumPort,
|
||||
});
|
||||
sock.on("connect", function() {
|
||||
sock.end();
|
||||
|
@ -223,7 +224,8 @@ function buildDriver() {
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
// Set the screen size
|
||||
|
||||
var targetW = 1024, targetH = 768;
|
||||
var targetW = 1024;
|
||||
var targetH = 768;
|
||||
function setSize(reqW, reqH) {
|
||||
return driver.manage().window().setSize(reqW, reqH).then(function() {
|
||||
return driver.takeScreenshot();
|
||||
|
@ -247,7 +249,7 @@ function imageDimensions(img) {
|
|||
return {
|
||||
buf: buf,
|
||||
width: buf.readUInt32BE(16),
|
||||
height: buf.readUInt32BE(20)
|
||||
height: buf.readUInt32BE(20),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -310,7 +312,7 @@ function takeScreenshot(key) {
|
|||
}
|
||||
}
|
||||
var opt = new jspngopt.Optimizer({
|
||||
pako: pako
|
||||
pako: pako,
|
||||
});
|
||||
var buf = opt.bufferSync(img.buf);
|
||||
if (loadExpected) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-console:0 */
|
||||
"use strict";
|
||||
|
||||
var childProcess = require("child_process");
|
||||
|
@ -47,7 +48,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.
|
||||
|
@ -78,14 +79,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",
|
||||
pdfFile, pngFile
|
||||
pdfFile, pngFile,
|
||||
]);
|
||||
}).then(function() {
|
||||
console.log("Rasterized " + key);
|
||||
|
@ -99,7 +100,8 @@ function processTestCase(key) {
|
|||
// Now we have the FFT result from both
|
||||
// Step 6: find alignment which maximizes overlap.
|
||||
// This uses a FFT-based correlation computation.
|
||||
var x, y;
|
||||
var x;
|
||||
var y;
|
||||
var real = createMatrix();
|
||||
var imag = createMatrix();
|
||||
|
||||
|
@ -164,8 +166,8 @@ function processTestCase(key) {
|
|||
"(", "-clone", "0-1", "-compose", "darken", "-composite", ")",
|
||||
// First image is red, second green, third blue channel of result
|
||||
"-channel", "RGB", "-combine",
|
||||
"-trim", // remove everything that has the same color as the corners
|
||||
diffFile // output file name
|
||||
"-trim", // remove everything with the same color as the corners
|
||||
diffFile, // output file name
|
||||
]);
|
||||
}).then(function() {
|
||||
console.log("Compared " + key);
|
||||
|
@ -241,7 +243,7 @@ function fftImage(image) {
|
|||
real: real,
|
||||
imag: imag,
|
||||
width: image.width,
|
||||
height: image.height
|
||||
height: image.height,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
3
katex.js
3
katex.js
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-console:0 */
|
||||
/**
|
||||
* This is the main entry point for KaTeX. Here, we expose functions for
|
||||
* rendering expressions either to DOM nodes or to markup strings.
|
||||
|
@ -69,5 +70,5 @@ module.exports = {
|
|||
* to change. Use at your own risk.
|
||||
*/
|
||||
__parse: generateParseTree,
|
||||
ParseError: ParseError
|
||||
ParseError: ParseError,
|
||||
};
|
||||
|
|
|
@ -22,5 +22,5 @@ for font in sorted(data):
|
|||
|
||||
sys.stdout.write(json.dumps(values))
|
||||
sep = ",\n "
|
||||
sep = "\n},\n"
|
||||
sys.stdout.write("\n}};\n")
|
||||
sep = ",\n },\n "
|
||||
sys.stdout.write(",\n },\n};\n")
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
"devDependencies": {
|
||||
"browserify": "^10.2.4",
|
||||
"clean-css": "~2.2.15",
|
||||
"eslint": "^1.10.2",
|
||||
"express": "~3.3.3",
|
||||
"glob": "^5.0.15",
|
||||
"jasmine": "^2.3.2",
|
||||
"jasmine-core": "^2.3.4",
|
||||
"js-yaml": "^3.3.1",
|
||||
"jshint": "^2.5.6",
|
||||
"jspngopt": "^0.1.0",
|
||||
"less": "~1.7.5",
|
||||
"nomnom": "^1.8.1",
|
||||
|
|
11
server.js
11
server.js
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-console:0 */
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
|
@ -41,7 +42,13 @@ var serveBrowserified = function(file, standaloneName) {
|
|||
};
|
||||
|
||||
app.get("/katex.js", serveBrowserified("./katex", "katex"));
|
||||
app.use("/test/jasmine", express["static"](path.dirname(require.resolve("jasmine-core/lib/jasmine-core/jasmine.js"))));
|
||||
app.use("/test/jasmine",
|
||||
express["static"](
|
||||
path.dirname(
|
||||
require.resolve("jasmine-core/lib/jasmine-core/jasmine.js")
|
||||
)
|
||||
)
|
||||
);
|
||||
app.get("/test/katex-spec.js", serveBrowserified("./test/*[Ss]pec.js"));
|
||||
app.get("/contrib/auto-render/auto-render.js",
|
||||
serveBrowserified("./contrib/auto-render/auto-render",
|
||||
|
@ -56,7 +63,7 @@ app.get("/katex.css", function(req, res, next) {
|
|||
|
||||
var parser = new less.Parser({
|
||||
paths: ["./static"],
|
||||
filename: "katex.less"
|
||||
filename: "katex.less",
|
||||
});
|
||||
|
||||
parser.parse(data, function(err, tree) {
|
||||
|
|
|
@ -60,7 +60,7 @@ var whitespaceRegex = /\s*/;
|
|||
*/
|
||||
Lexer.prototype._innerLex = function(pos, ignoreWhitespace) {
|
||||
var input = this._input;
|
||||
if (pos == input.length) {
|
||||
if (pos === input.length) {
|
||||
return new Token("EOF", null, pos);
|
||||
}
|
||||
var match = matchAt(tokenRegex, input, pos);
|
||||
|
@ -122,7 +122,7 @@ Lexer.prototype._innerLexSize = function(pos) {
|
|||
}
|
||||
return new Token(match[0], {
|
||||
number: +(match[1] + match[2]),
|
||||
unit: unit
|
||||
unit: unit,
|
||||
}, pos + match[0].length);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
font: font,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -171,7 +171,7 @@ var colorMap = {
|
|||
"katex-grayH": "#555555",
|
||||
"katex-grayI": "#333333",
|
||||
"katex-kaBlue": "#314453",
|
||||
"katex-kaGreen": "#639b24"
|
||||
"katex-kaGreen": "#639b24",
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-constant-condition:0 */
|
||||
var functions = require("./functions");
|
||||
var environments = require("./environments");
|
||||
var Lexer = require("./Lexer");
|
||||
|
@ -177,7 +178,6 @@ Parser.prototype.parseExpression = function(breakOnInfix, breakOnToken) {
|
|||
*/
|
||||
Parser.prototype.handleInfixNodes = function(body) {
|
||||
var overIndex = -1;
|
||||
var func;
|
||||
var funcName;
|
||||
|
||||
for (var i = 0; i < body.length; i++) {
|
||||
|
@ -189,12 +189,12 @@ Parser.prototype.handleInfixNodes = function (body) {
|
|||
}
|
||||
overIndex = i;
|
||||
funcName = node.value.replaceWith;
|
||||
func = functions[funcName];
|
||||
}
|
||||
}
|
||||
|
||||
if (overIndex !== -1) {
|
||||
var numerNode, denomNode;
|
||||
var numerNode;
|
||||
var denomNode;
|
||||
|
||||
var numerBody = body.slice(0, overIndex);
|
||||
var denomBody = body.slice(overIndex + 1);
|
||||
|
@ -236,7 +236,10 @@ Parser.prototype.handleSupSubscript = function(name) {
|
|||
return this.handleUnsupportedCmd();
|
||||
} else {
|
||||
throw new ParseError(
|
||||
"Expected group after '" + symbol + "'", this.lexer, symPos + 1);
|
||||
"Expected group after '" + symbol + "'",
|
||||
this.lexer,
|
||||
symPos + 1
|
||||
);
|
||||
}
|
||||
} else if (group.isFunction) {
|
||||
// ^ and _ have a greediness, so handle interactions with functions'
|
||||
|
@ -271,7 +274,7 @@ Parser.prototype.handleSupSubscript = function(name) {
|
|||
"text",
|
||||
{
|
||||
body: textordArray,
|
||||
type: "text"
|
||||
type: "text",
|
||||
},
|
||||
this.mode);
|
||||
|
||||
|
@ -280,7 +283,7 @@ Parser.prototype.handleSupSubscript = function(name) {
|
|||
{
|
||||
color: this.settings.errorColor,
|
||||
value: [textNode],
|
||||
type: "color"
|
||||
type: "color",
|
||||
},
|
||||
this.mode);
|
||||
|
||||
|
@ -314,10 +317,10 @@ Parser.prototype.parseAtom = function() {
|
|||
if (lex.text === "\\limits" || lex.text === "\\nolimits") {
|
||||
// We got a limit control
|
||||
if (!base || base.type !== "op") {
|
||||
throw new ParseError("Limit controls must follow a math operator",
|
||||
throw new ParseError(
|
||||
"Limit controls must follow a math operator",
|
||||
this.lexer, this.pos);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var limits = lex.text === "\\limits";
|
||||
base.value.limits = limits;
|
||||
base.value.alwaysHandleSupSub = true;
|
||||
|
@ -363,7 +366,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
|
||||
|
@ -374,12 +377,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",
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -416,7 +419,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
|
||||
|
@ -436,7 +439,7 @@ Parser.prototype.parseImplicitGroup = function() {
|
|||
envName: envName,
|
||||
parser: this,
|
||||
lexer: this.lexer,
|
||||
positions: args.pop()
|
||||
positions: args.pop(),
|
||||
};
|
||||
var result = env.handler(context, args);
|
||||
this.expect("\\end", false);
|
||||
|
@ -457,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
|
||||
|
@ -466,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
|
||||
|
@ -516,7 +519,7 @@ Parser.prototype.callFunction = function(name, args, positions) {
|
|||
funcName: name,
|
||||
parser: this,
|
||||
lexer: this.lexer,
|
||||
positions: positions
|
||||
positions: positions,
|
||||
};
|
||||
return functions[name].handler(context, args);
|
||||
};
|
||||
|
|
|
@ -86,7 +86,7 @@ var sizeNames = [
|
|||
"displaystyle textstyle",
|
||||
"textstyle",
|
||||
"scriptstyle",
|
||||
"scriptscriptstyle"
|
||||
"scriptscriptstyle",
|
||||
];
|
||||
|
||||
// Reset names for the different sizes
|
||||
|
@ -94,7 +94,7 @@ var resetNames = [
|
|||
"reset-textstyle",
|
||||
"reset-textstyle",
|
||||
"reset-scriptstyle",
|
||||
"reset-scriptscriptstyle"
|
||||
"reset-scriptscriptstyle",
|
||||
];
|
||||
|
||||
// Instances of the different styles
|
||||
|
@ -106,7 +106,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
|
||||
|
@ -122,5 +122,5 @@ module.exports = {
|
|||
DISPLAY: styles[D],
|
||||
TEXT: styles[T],
|
||||
SCRIPT: styles[S],
|
||||
SCRIPTSCRIPT: styles[SS]
|
||||
SCRIPTSCRIPT: styles[SS],
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-console:0 */
|
||||
/**
|
||||
* This module contains general functions that can be used for building
|
||||
* different kinds of domTree nodes in a consistent manner.
|
||||
|
@ -19,12 +20,12 @@ var greekCapitals = [
|
|||
"\\Upsilon",
|
||||
"\\Phi",
|
||||
"\\Psi",
|
||||
"\\Omega"
|
||||
"\\Omega",
|
||||
];
|
||||
|
||||
var dotlessLetters = [
|
||||
"\u0131", // dotless i, \imath
|
||||
"\u0237" // dotless j, \jmath
|
||||
"\u0237", // dotless j, \jmath
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -130,7 +131,8 @@ var makeOrd = function(group, options, type) {
|
|||
} else {
|
||||
var fontName = fontMap[font].fontName;
|
||||
if (fontMetrics.getCharacterMetrics(value, fontName)) {
|
||||
return makeSymbol(value, fontName, mode, color, classes.concat([font]));
|
||||
return makeSymbol(
|
||||
value, fontName, mode, color, classes.concat([font]));
|
||||
} else {
|
||||
return mathDefault(value, mode, color, classes, type);
|
||||
}
|
||||
|
@ -201,7 +203,8 @@ var makeFragment = function(children) {
|
|||
*/
|
||||
var makeFontSizer = function(options, fontSize) {
|
||||
var fontSizeInner = makeSpan([], [new domTree.symbolNode("\u200b")]);
|
||||
fontSizeInner.style.fontSize = (fontSize / options.style.sizeMultiplier) + "em";
|
||||
fontSizeInner.style.fontSize =
|
||||
(fontSize / options.style.sizeMultiplier) + "em";
|
||||
|
||||
var fontSizer = makeSpan(
|
||||
["fontsize-ensurer", "reset-" + options.size, "size5"],
|
||||
|
@ -350,7 +353,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
|
||||
|
@ -358,32 +361,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",
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -396,11 +399,11 @@ var fontMap = {
|
|||
// styles
|
||||
"mathbf": {
|
||||
variant: "bold",
|
||||
fontName: "Main-Bold"
|
||||
fontName: "Main-Bold",
|
||||
},
|
||||
"mathrm": {
|
||||
variant: "normal",
|
||||
fontName: "Main-Regular"
|
||||
fontName: "Main-Regular",
|
||||
},
|
||||
|
||||
// "mathit" is missing because it requires the use of two fonts: Main-Italic
|
||||
|
@ -410,28 +413,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 = {
|
||||
|
@ -443,5 +446,5 @@ module.exports = {
|
|||
makeVList: makeVList,
|
||||
makeOrd: makeOrd,
|
||||
sizingMultiplier: sizingMultiplier,
|
||||
spacingFunctions: spacingFunctions
|
||||
spacingFunctions: spacingFunctions,
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-console:0 */
|
||||
/**
|
||||
* This file does the main work of building a domTree structure from a parse
|
||||
* tree. The entry point is the `buildHTML` function, which takes a parse tree.
|
||||
|
@ -53,7 +54,7 @@ var groupToType = {
|
|||
rule: "mord",
|
||||
leftright: "minner",
|
||||
sqrt: "mord",
|
||||
accent: "mord"
|
||||
accent: "mord",
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -104,7 +105,8 @@ var shouldHandleSupSub = function(group, options) {
|
|||
// Operators handle supsubs differently when they have limits
|
||||
// (e.g. `\displaystyle\sum_2^3`)
|
||||
return group.value.limits &&
|
||||
(options.style.size === Style.DISPLAY.size || group.value.alwaysHandleSupSub);
|
||||
(options.style.size === Style.DISPLAY.size ||
|
||||
group.value.alwaysHandleSupSub);
|
||||
} else if (group.type === "accent") {
|
||||
return isCharacterBox(group.value.base);
|
||||
} else {
|
||||
|
@ -160,7 +162,7 @@ var makeNullDelimiter = function(options) {
|
|||
return makeSpan([
|
||||
"sizing", "reset-" + options.size, "size5",
|
||||
options.style.reset(), Style.TEXT.cls(),
|
||||
"nulldelimiter"
|
||||
"nulldelimiter",
|
||||
]);
|
||||
};
|
||||
|
||||
|
@ -263,7 +265,10 @@ groupTypes.supsub = function(group, options, prev) {
|
|||
}
|
||||
|
||||
var base = buildGroup(group.value.base, options.reset());
|
||||
var supmid, submid, sup, sub;
|
||||
var supmid;
|
||||
var submid;
|
||||
var sup;
|
||||
var sub;
|
||||
|
||||
if (group.value.sup) {
|
||||
sup = buildGroup(group.value.sup,
|
||||
|
@ -280,7 +285,8 @@ groupTypes.supsub = function(group, options, prev) {
|
|||
}
|
||||
|
||||
// Rule 18a
|
||||
var supShift, subShift;
|
||||
var supShift;
|
||||
var subShift;
|
||||
if (isCharacterBox(group.value.base)) {
|
||||
supShift = 0;
|
||||
subShift = 0;
|
||||
|
@ -314,7 +320,7 @@ groupTypes.supsub = function(group, options, prev) {
|
|||
sub.height - 0.8 * fontMetrics.metrics.xHeight);
|
||||
|
||||
supsub = buildCommon.makeVList([
|
||||
{type: "elem", elem: submid}
|
||||
{type: "elem", elem: submid},
|
||||
], "shift", subShift, options);
|
||||
|
||||
supsub.children[0].style.marginRight = scriptspace;
|
||||
|
@ -331,7 +337,7 @@ groupTypes.supsub = function(group, options, prev) {
|
|||
sup.depth + 0.25 * fontMetrics.metrics.xHeight);
|
||||
|
||||
supsub = buildCommon.makeVList([
|
||||
{type: "elem", elem: supmid}
|
||||
{type: "elem", elem: supmid},
|
||||
], "shift", -supShift, options);
|
||||
|
||||
supsub.children[0].style.marginRight = scriptspace;
|
||||
|
@ -357,7 +363,7 @@ groupTypes.supsub = function(group, options, prev) {
|
|||
|
||||
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
|
||||
|
@ -436,7 +442,7 @@ groupTypes.genfrac = function(group, options, prev) {
|
|||
|
||||
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
|
||||
|
@ -467,7 +473,7 @@ groupTypes.genfrac = function(group, options, prev) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -484,7 +490,8 @@ groupTypes.genfrac = function(group, options, prev) {
|
|||
delimSize = fontMetrics.metrics.getDelim2(fstyle);
|
||||
}
|
||||
|
||||
var leftDelim, rightDelim;
|
||||
var leftDelim;
|
||||
var rightDelim;
|
||||
if (group.value.leftDelim == null) {
|
||||
leftDelim = makeNullDelimiter(options);
|
||||
} else {
|
||||
|
@ -507,7 +514,8 @@ groupTypes.genfrac = function(group, options, prev) {
|
|||
};
|
||||
|
||||
groupTypes.array = function(group, options, prev) {
|
||||
var r, c;
|
||||
var r;
|
||||
var c;
|
||||
var nr = group.value.body.length;
|
||||
var nc = 0;
|
||||
var body = new Array(nr);
|
||||
|
@ -719,7 +727,7 @@ groupTypes.op = function(group, options, prev) {
|
|||
|
||||
// Most operators have a large successor symbol, but these don't.
|
||||
var noSuccessor = [
|
||||
"\\smallint"
|
||||
"\\smallint",
|
||||
];
|
||||
|
||||
var large = false;
|
||||
|
@ -769,7 +777,10 @@ groupTypes.op = function(group, options, prev) {
|
|||
// in a new span so it is an inline, and works.
|
||||
base = makeSpan([], [base]);
|
||||
|
||||
var supmid, supKern, submid, subKern;
|
||||
var supmid;
|
||||
var supKern;
|
||||
var submid;
|
||||
var subKern;
|
||||
// We manually have to handle the superscripts and subscripts. This,
|
||||
// aside from the kern calculations, is copied from supsub.
|
||||
if (supGroup) {
|
||||
|
@ -797,7 +808,9 @@ groupTypes.op = function(group, options, prev) {
|
|||
|
||||
// Build the final group as a vlist of the possible subscript, base,
|
||||
// and possible superscript.
|
||||
var finalGroup, top, bottom;
|
||||
var finalGroup;
|
||||
var top;
|
||||
var bottom;
|
||||
if (!supGroup) {
|
||||
top = base.height - baseShift;
|
||||
|
||||
|
@ -805,7 +818,7 @@ groupTypes.op = function(group, options, prev) {
|
|||
{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
|
||||
|
@ -820,7 +833,7 @@ groupTypes.op = function(group, options, prev) {
|
|||
{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
|
||||
|
@ -843,7 +856,7 @@ groupTypes.op = function(group, options, prev) {
|
|||
{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
|
||||
|
@ -909,7 +922,7 @@ groupTypes.overline = function(group, options, prev) {
|
|||
{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(["overline", "mord"], [vlist], options.getColor());
|
||||
|
@ -977,7 +990,7 @@ groupTypes.sqrt = function(group, options, prev) {
|
|||
{type: "elem", elem: inner},
|
||||
{type: "kern", size: lineClearance},
|
||||
{type: "elem", elem: line},
|
||||
{type: "kern", size: ruleWidth}
|
||||
{type: "kern", size: ruleWidth},
|
||||
], "firstBaseline", null, options);
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1054,7 @@ groupTypes.styling = function(group, options, prev) {
|
|||
"display": Style.DISPLAY,
|
||||
"text": Style.TEXT,
|
||||
"script": Style.SCRIPT,
|
||||
"scriptscript": Style.SCRIPTSCRIPT
|
||||
"scriptscript": Style.SCRIPTSCRIPT,
|
||||
};
|
||||
|
||||
var newStyle = style[group.value.style];
|
||||
|
@ -1243,7 +1256,7 @@ groupTypes.accent = function(group, options, prev) {
|
|||
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
|
||||
|
|
|
@ -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(
|
||||
|
@ -381,7 +381,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];
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -144,7 +144,10 @@ var makeInner = function(symbol, font, mode) {
|
|||
var makeStackedDelim = function(delim, heightTotal, center, options, mode) {
|
||||
// There are four parts, the top, an optional middle, a repeated part, and a
|
||||
// bottom.
|
||||
var top, middle, repeat, bottom;
|
||||
var top;
|
||||
var middle;
|
||||
var repeat;
|
||||
var bottom;
|
||||
top = repeat = bottom = delim;
|
||||
middle = null;
|
||||
// Also keep track of what font the delimiters are in
|
||||
|
@ -325,7 +328,7 @@ var stackLargeDelimiters = [
|
|||
"(", ")", "[", "\\lbrack", "]", "\\rbrack",
|
||||
"\\{", "\\lbrace", "\\}", "\\rbrace",
|
||||
"\\lfloor", "\\rfloor", "\\lceil", "\\rceil",
|
||||
"\\surd"
|
||||
"\\surd",
|
||||
];
|
||||
|
||||
// delimiters that always stack
|
||||
|
@ -334,12 +337,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
|
||||
|
@ -390,7 +393,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
|
||||
|
@ -398,7 +401,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
|
||||
|
@ -411,7 +414,7 @@ var stackLargeDelimiterSequence = [
|
|||
{type: "large", size: 2},
|
||||
{type: "large", size: 3},
|
||||
{type: "large", size: 4},
|
||||
{type: "stack"}
|
||||
{type: "stack"},
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -535,5 +538,5 @@ var makeLeftRightDelim = function(delim, height, depth, options, mode) {
|
|||
module.exports = {
|
||||
sizedDelim: makeSizedDelim,
|
||||
customSizedDelim: makeCustomSizedDelim,
|
||||
leftRightDelim: makeLeftRightDelim
|
||||
leftRightDelim: makeLeftRightDelim,
|
||||
};
|
||||
|
|
|
@ -265,5 +265,5 @@ symbolNode.prototype.toMarkup = function() {
|
|||
module.exports = {
|
||||
span: span,
|
||||
documentFragment: documentFragment,
|
||||
symbolNode: symbolNode
|
||||
symbolNode: symbolNode,
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-constant-condition:0 */
|
||||
var fontMetrics = require("./fontMetrics");
|
||||
var parseData = require("./parseData");
|
||||
var ParseError = require("./ParseError");
|
||||
|
@ -10,7 +11,9 @@ var ParseNode = parseData.ParseNode;
|
|||
* with one group per cell.
|
||||
*/
|
||||
function parseArray(parser, result) {
|
||||
var row = [], body = [row], rowGaps = [];
|
||||
var row = [];
|
||||
var body = [row];
|
||||
var rowGaps = [];
|
||||
while (true) {
|
||||
var cell = parser.parseExpression(false, null);
|
||||
row.push(new ParseNode("ordgroup", cell, parser.mode));
|
||||
|
@ -74,7 +77,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;
|
||||
|
@ -84,7 +87,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];
|
||||
|
@ -93,12 +96,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(
|
||||
|
@ -108,7 +111,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;
|
||||
|
@ -122,7 +125,7 @@ defineEnvironment([
|
|||
"bmatrix",
|
||||
"Bmatrix",
|
||||
"vmatrix",
|
||||
"Vmatrix"
|
||||
"Vmatrix",
|
||||
], {
|
||||
}, function(context) {
|
||||
var delimiters = {
|
||||
|
@ -131,18 +134,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;
|
||||
|
@ -160,19 +163,19 @@ defineEnvironment("cases", {
|
|||
type: "align",
|
||||
align: "l",
|
||||
pregap: 0,
|
||||
postgap: fontMetrics.metrics.quad
|
||||
postgap: fontMetrics.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;
|
||||
});
|
||||
|
@ -185,7 +188,7 @@ defineEnvironment("aligned", {
|
|||
}, function(context) {
|
||||
var res = {
|
||||
type: "array",
|
||||
cols: []
|
||||
cols: [],
|
||||
};
|
||||
res = parseArray(context.parser, res);
|
||||
var emptyGroup = new ParseNode("ordgroup", [], context.mode);
|
||||
|
@ -211,7 +214,7 @@ defineEnvironment("aligned", {
|
|||
type: "align",
|
||||
align: align,
|
||||
pregap: pregap,
|
||||
postgap: 0
|
||||
postgap: 0,
|
||||
};
|
||||
}
|
||||
return res;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* jshint unused:false */
|
||||
/* eslint no-unused-vars:0 */
|
||||
|
||||
var Style = require("./Style");
|
||||
|
||||
|
@ -112,7 +112,7 @@ var metrics = {
|
|||
return sigma21ScriptScript;
|
||||
}
|
||||
throw new Error("Unexpected style size: " + style.size);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// This map contains a mapping from font name and character code to character
|
||||
|
@ -136,12 +136,12 @@ var getCharacterMetrics = function(character, style) {
|
|||
height: metrics[1],
|
||||
italic: metrics[2],
|
||||
skew: metrics[3],
|
||||
width: metrics[4]
|
||||
width: metrics[4],
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
metrics: metrics,
|
||||
getCharacterMetrics: getCharacterMetrics
|
||||
getCharacterMetrics: getCharacterMetrics,
|
||||
};
|
||||
|
|
|
@ -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,5 +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],
|
||||
},
|
||||
};
|
||||
|
|
112
src/functions.js
112
src/functions.js
|
@ -91,7 +91,7 @@ function defineFunction(names, props, handler) {
|
|||
greediness: (props.greediness === undefined) ? 1 : props.greediness,
|
||||
allowedInText: !!props.allowedInText,
|
||||
numOptionalArgs: props.numOptionalArgs || 0,
|
||||
handler: handler
|
||||
handler: handler,
|
||||
};
|
||||
for (var i = 0; i < names.length; ++i) {
|
||||
module.exports[names[i]] = data;
|
||||
|
@ -101,14 +101,14 @@ function defineFunction(names, props, handler) {
|
|||
// 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,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -116,7 +116,7 @@ defineFunction("\\sqrt", {
|
|||
defineFunction("\\text", {
|
||||
numArgs: 1,
|
||||
argTypes: ["text"],
|
||||
greediness: 2
|
||||
greediness: 2,
|
||||
}, function(context, args) {
|
||||
var body = args[0];
|
||||
// Since the corresponding buildHTML/buildMathML function expects a
|
||||
|
@ -131,7 +131,7 @@ defineFunction("\\text", {
|
|||
|
||||
return {
|
||||
type: "text",
|
||||
body: inner
|
||||
body: inner,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -140,7 +140,7 @@ 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];
|
||||
|
@ -155,18 +155,18 @@ defineFunction("\\color", {
|
|||
return {
|
||||
type: "color",
|
||||
color: color.value,
|
||||
value: inner
|
||||
value: inner,
|
||||
};
|
||||
});
|
||||
|
||||
// An overline
|
||||
defineFunction("\\overline", {
|
||||
numArgs: 1
|
||||
numArgs: 1,
|
||||
}, function(context, args) {
|
||||
var body = args[0];
|
||||
return {
|
||||
type: "overline",
|
||||
body: body
|
||||
body: body,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -174,7 +174,7 @@ defineFunction("\\overline", {
|
|||
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];
|
||||
|
@ -183,21 +183,21 @@ defineFunction("\\rule", {
|
|||
type: "rule",
|
||||
shift: shift && shift.value,
|
||||
width: width.value,
|
||||
height: height.value
|
||||
height: height.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];
|
||||
var inner;
|
||||
|
@ -209,7 +209,7 @@ defineFunction("\\phantom", {
|
|||
|
||||
return {
|
||||
type: "phantom",
|
||||
value: inner
|
||||
value: inner,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -230,7 +230,7 @@ var delimiterSizes = {
|
|||
"\\big" : {type: "textord", size: 1},
|
||||
"\\Big" : {type: "textord", size: 2},
|
||||
"\\bigg" : {type: "textord", size: 3},
|
||||
"\\Bigg" : {type: "textord", size: 4}
|
||||
"\\Bigg" : {type: "textord", size: 4},
|
||||
};
|
||||
|
||||
var delimiters = [
|
||||
|
@ -245,13 +245,13 @@ var delimiters = [
|
|||
"\\uparrow", "\\Uparrow",
|
||||
"\\downarrow", "\\Downarrow",
|
||||
"\\updownarrow", "\\Updownarrow",
|
||||
"."
|
||||
".",
|
||||
];
|
||||
|
||||
var fontAliases = {
|
||||
"\\Bbb": "\\mathbb",
|
||||
"\\bold": "\\mathbf",
|
||||
"\\frak": "\\mathfrak"
|
||||
"\\frak": "\\mathfrak",
|
||||
};
|
||||
|
||||
// Single-argument color functions
|
||||
|
@ -268,11 +268,11 @@ 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];
|
||||
var atoms;
|
||||
|
@ -285,7 +285,7 @@ defineFunction([
|
|||
return {
|
||||
type: "color",
|
||||
color: "katex-" + context.funcName.slice(1),
|
||||
value: atoms
|
||||
value: atoms,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -298,44 +298,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,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -343,25 +343,25 @@ 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,
|
||||
};
|
||||
});
|
||||
|
||||
// Fractions
|
||||
defineFunction([
|
||||
"\\dfrac", "\\frac", "\\tfrac",
|
||||
"\\dbinom", "\\binom", "\\tbinom"
|
||||
"\\dbinom", "\\binom", "\\tbinom",
|
||||
], {
|
||||
numArgs: 2,
|
||||
greediness: 2
|
||||
greediness: 2,
|
||||
}, function(context, args) {
|
||||
var numer = args[0];
|
||||
var denom = args[1];
|
||||
|
@ -405,19 +405,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,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -427,9 +427,9 @@ defineFunction([
|
|||
"\\bigr", "\\Bigr", "\\biggr", "\\Biggr",
|
||||
"\\bigm", "\\Bigm", "\\biggm", "\\Biggm",
|
||||
"\\big", "\\Big", "\\bigg", "\\Bigg",
|
||||
"\\left", "\\right"
|
||||
"\\left", "\\right",
|
||||
], {
|
||||
numArgs: 1
|
||||
numArgs: 1,
|
||||
}, function(context, args) {
|
||||
var delim = args[0];
|
||||
if (!utils.contains(delimiters, delim.value)) {
|
||||
|
@ -444,14 +444,14 @@ defineFunction([
|
|||
if (context.funcName === "\\left" || context.funcName === "\\right") {
|
||||
return {
|
||||
type: "leftright",
|
||||
value: delim.value
|
||||
value: delim.value,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
type: "delimsizing",
|
||||
size: delimiterSizes[context.funcName].size,
|
||||
delimType: delimiterSizes[context.funcName].type,
|
||||
value: delim.value
|
||||
value: delim.value,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -459,14 +459,14 @@ defineFunction([
|
|||
// 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([
|
||||
|
@ -478,10 +478,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;
|
||||
|
@ -491,30 +491,30 @@ 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"], {
|
||||
numArgs: 0
|
||||
numArgs: 0,
|
||||
}, function(context) {
|
||||
var replaceWith;
|
||||
switch (context.funcName) {
|
||||
|
@ -529,7 +529,7 @@ defineFunction(["\\over", "\\choose"], {
|
|||
}
|
||||
return {
|
||||
type: "infix",
|
||||
replaceWith: replaceWith
|
||||
replaceWith: replaceWith,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -537,19 +537,19 @@ defineFunction(["\\over", "\\choose"], {
|
|||
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") {
|
||||
|
@ -564,6 +564,6 @@ defineFunction(["\\begin", "\\end"], {
|
|||
return {
|
||||
type: "environment",
|
||||
name: name,
|
||||
namepos: context.positions[1]
|
||||
namepos: context.positions[1],
|
||||
};
|
||||
});
|
||||
|
|
|
@ -98,5 +98,5 @@ TextNode.prototype.toMarkup = function() {
|
|||
|
||||
module.exports = {
|
||||
MathNode: MathNode,
|
||||
TextNode: TextNode
|
||||
TextNode: TextNode,
|
||||
};
|
||||
|
|
|
@ -8,6 +8,6 @@ function ParseNode(type, value, mode) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
ParseNode: ParseNode
|
||||
ParseNode: ParseNode,
|
||||
};
|
||||
|
||||
|
|
|
@ -18,20 +18,17 @@
|
|||
|
||||
module.exports = {
|
||||
math: {},
|
||||
text: {}
|
||||
text: {},
|
||||
};
|
||||
|
||||
function defineSymbol(mode, font, group, replace, name) {
|
||||
module.exports[mode][name] = {
|
||||
font: font,
|
||||
group: group,
|
||||
replace: replace
|
||||
replace: replace,
|
||||
};
|
||||
}
|
||||
|
||||
// (For some reason jshint believes open and close to be global symbols.)
|
||||
/* globals -open, -close */
|
||||
|
||||
// Some abbreviations for commonly used strings.
|
||||
// This helps minify the code, and also spotting typos using jshint.
|
||||
|
||||
|
@ -597,25 +594,27 @@ defineSymbol(text, main, spacing, "\u00a0", " ");
|
|||
defineSymbol(text, main, spacing, "\u00a0", "~");
|
||||
|
||||
// There are lots of symbols which are the same, so we add them in afterwards.
|
||||
var i;
|
||||
var ch;
|
||||
|
||||
// All of these are textords in math mode
|
||||
var mathTextSymbols = "0123456789/@.\"";
|
||||
for (var i = 0; i < mathTextSymbols.length; i++) {
|
||||
var ch = mathTextSymbols.charAt(i);
|
||||
for (i = 0; i < mathTextSymbols.length; i++) {
|
||||
ch = mathTextSymbols.charAt(i);
|
||||
defineSymbol(math, main, textord, ch, ch);
|
||||
}
|
||||
|
||||
// All of these are textords in text mode
|
||||
var textSymbols = "0123456789`!@*()-=+[]'\";:?/.,";
|
||||
for (var i = 0; i < textSymbols.length; i++) {
|
||||
var ch = textSymbols.charAt(i);
|
||||
for (i = 0; i < textSymbols.length; i++) {
|
||||
ch = textSymbols.charAt(i);
|
||||
defineSymbol(text, main, textord, ch, ch);
|
||||
}
|
||||
|
||||
// All of these are textords in text mode, and mathords in math mode
|
||||
var letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
for (var i = 0; i < letters.length; i++) {
|
||||
var ch = letters.charAt(i);
|
||||
for (i = 0; i < letters.length; i++) {
|
||||
ch = letters.charAt(i);
|
||||
defineSymbol(math, main, mathord, ch, ch);
|
||||
defineSymbol(text, main, textord, ch, ch);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ var indexOf = function(list, elem) {
|
|||
if (nativeIndexOf && list.indexOf === nativeIndexOf) {
|
||||
return list.indexOf(elem);
|
||||
}
|
||||
var i = 0, l = list.length;
|
||||
var i = 0;
|
||||
var l = list.length;
|
||||
for (; i < l; i++) {
|
||||
if (list[i] === elem) {
|
||||
return i;
|
||||
|
@ -50,7 +51,7 @@ var ESCAPE_LOOKUP = {
|
|||
">": ">",
|
||||
"<": "<",
|
||||
"\"": """,
|
||||
"'": "'"
|
||||
"'": "'",
|
||||
};
|
||||
|
||||
var ESCAPE_REGEX = /[&><"']/g;
|
||||
|
@ -101,5 +102,5 @@ module.exports = {
|
|||
hyphenate: hyphenate,
|
||||
indexOf: indexOf,
|
||||
setTextContent: setTextContent,
|
||||
clearNode: clearNode
|
||||
clearNode: clearNode,
|
||||
};
|
||||
|
|
|
@ -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 + "'",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint max-len:0 */
|
||||
/* global beforeEach: false */
|
||||
/* global jasmine: false */
|
||||
/* global expect: false */
|
||||
|
@ -16,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) {
|
||||
|
@ -65,7 +66,7 @@ beforeEach(function() {
|
|||
|
||||
var result = {
|
||||
pass: true,
|
||||
message: "'" + actual + "' succeeded parsing"
|
||||
message: "'" + actual + "' succeeded parsing",
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -82,7 +83,7 @@ beforeEach(function() {
|
|||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -94,7 +95,7 @@ beforeEach(function() {
|
|||
var result = {
|
||||
pass: false,
|
||||
message: "Expected '" + actual + "' to fail " +
|
||||
"parsing, but it succeeded"
|
||||
"parsing, but it succeeded",
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -111,7 +112,7 @@ beforeEach(function() {
|
|||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -122,7 +123,7 @@ beforeEach(function() {
|
|||
|
||||
var result = {
|
||||
pass: true,
|
||||
message: "'" + actual + "' succeeded in building"
|
||||
message: "'" + actual + "' succeeded in building",
|
||||
};
|
||||
|
||||
expect(actual).toParse(usedSettings);
|
||||
|
@ -141,9 +142,9 @@ beforeEach(function() {
|
|||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1025,7 +1026,7 @@ describe("A TeX-compliant parser", function() {
|
|||
"\\rule{1em}",
|
||||
"\\llap",
|
||||
"\\bigl",
|
||||
"\\text"
|
||||
"\\text",
|
||||
];
|
||||
|
||||
for (var i = 0; i < missingGroups.length; i++) {
|
||||
|
@ -1052,7 +1053,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++) {
|
||||
|
@ -1070,7 +1071,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++) {
|
||||
|
@ -1083,7 +1084,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++) {
|
||||
|
@ -1096,7 +1097,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++) {
|
||||
|
@ -1135,7 +1136,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++) {
|
||||
|
@ -1149,7 +1150,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++) {
|
||||
|
@ -1504,17 +1505,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"
|
||||
}
|
||||
]));
|
||||
});
|
||||
});
|
||||
|
@ -1643,7 +1644,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" },
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -1656,7 +1657,7 @@ describe("An array environment", function() {
|
|||
{ type: "separator", separator: "|" },
|
||||
{ type: "separator", separator: "|" },
|
||||
{ type: "align", align: "c" },
|
||||
{ type: "separator", separator: "|" }
|
||||
{ type: "separator", separator: "|" },
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -1731,7 +1732,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() {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint no-console:0 */
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs");
|
||||
|
@ -6,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();
|
||||
|
||||
|
@ -15,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);
|
||||
|
@ -94,7 +95,8 @@ function evaluate(err, log) {
|
|||
throw err;
|
||||
}
|
||||
|
||||
var match, nextIndex = 0;
|
||||
var match;
|
||||
var nextIndex = 0;
|
||||
while ((match = reMM.exec(log)) !== null) {
|
||||
var list = match[1];
|
||||
match = reParts.exec(list);
|
||||
|
@ -143,7 +145,8 @@ function evaluate(err, log) {
|
|||
}
|
||||
|
||||
function extractDigits(str) {
|
||||
var match, res = "";
|
||||
var match;
|
||||
var res = "";
|
||||
while ((match = reDigit.exec(str)) !== null) {
|
||||
res += match[1];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user