Comparing version 0.4.3 to 0.5.0
{ | ||
"name": "katex", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"description": "Fast math typesetting for the web.", | ||
@@ -17,3 +17,3 @@ "main": "katex.js", | ||
"devDependencies": { | ||
"browserify": "~2.29.1", | ||
"browserify": "^10.2.4", | ||
"clean-css": "~2.2.15", | ||
@@ -24,2 +24,4 @@ "express": "~3.3.3", | ||
"less": "~1.7.5", | ||
"selenium-webdriver": "^2.46.1", | ||
"nomnom": "^1.8.1", | ||
"uglify-js": "~2.4.15" | ||
@@ -26,0 +28,0 @@ }, |
@@ -10,3 +10,3 @@ # [<img src="https://khan.github.io/KaTeX/katex-logo.svg" width="130" alt="KaTeX">](https://khan.github.io/KaTeX/) [![Build Status](https://travis-ci.org/Khan/KaTeX.svg?branch=master)](https://travis-ci.org/Khan/KaTeX) | ||
KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, and IE 8 - IE 11. | ||
KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, and IE 8 - IE 11. A list of supported commands can be on the [wiki](https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX). | ||
@@ -13,0 +13,0 @@ ## Usage |
@@ -35,3 +35,4 @@ /** | ||
// List of types used by getTypeOfGroup | ||
// List of types used by getTypeOfGroup, | ||
// see https://github.com/Khan/KaTeX/wiki/Examining-TeX#group-types | ||
var groupToType = { | ||
@@ -46,4 +47,4 @@ mathord: "mord", | ||
inner: "minner", | ||
genfrac: "minner", | ||
array: "minner", | ||
genfrac: "mord", | ||
array: "mord", | ||
spacing: "mord", | ||
@@ -160,2 +161,10 @@ punct: "mpunct", | ||
var makeNullDelimiter = function(options) { | ||
return makeSpan([ | ||
"sizing", "reset-" + options.size, "size5", | ||
options.style.reset(), Style.TEXT.cls(), | ||
"nulldelimiter" | ||
]); | ||
}; | ||
/** | ||
@@ -475,4 +484,2 @@ * This is a map of group types to the function used to handle that type. | ||
// Rule 15e | ||
var innerChildren = [makeSpan(["mfrac"], [frac])]; | ||
var delimSize; | ||
@@ -485,20 +492,21 @@ if (fstyle.size === Style.DISPLAY.size) { | ||
if (group.value.leftDelim != null) { | ||
innerChildren.unshift( | ||
delimiter.customSizedDelim( | ||
group.value.leftDelim, delimSize, true, | ||
options.withStyle(fstyle), group.mode) | ||
); | ||
var leftDelim, rightDelim; | ||
if (group.value.leftDelim == null) { | ||
leftDelim = makeNullDelimiter(options); | ||
} else { | ||
leftDelim = delimiter.customSizedDelim( | ||
group.value.leftDelim, delimSize, true, | ||
options.withStyle(fstyle), group.mode); | ||
} | ||
if (group.value.rightDelim != null) { | ||
innerChildren.push( | ||
delimiter.customSizedDelim( | ||
group.value.rightDelim, delimSize, true, | ||
options.withStyle(fstyle), group.mode) | ||
); | ||
if (group.value.rightDelim == null) { | ||
rightDelim = makeNullDelimiter(options); | ||
} else { | ||
rightDelim = delimiter.customSizedDelim( | ||
group.value.rightDelim, delimSize, true, | ||
options.withStyle(fstyle), group.mode); | ||
} | ||
return makeSpan( | ||
["minner", options.style.reset(), fstyle.cls()], | ||
innerChildren, | ||
["mord", options.style.reset(), fstyle.cls()], | ||
[leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], | ||
options.getColor()); | ||
@@ -519,3 +527,5 @@ }, | ||
var baselineskip = 12 * pt; // see size10.clo | ||
var arraystretch = 1; // factor, see lttab.dtx | ||
// Default \arraystretch from lttab.dtx | ||
// TODO(gagern): may get redefined once we have user-defined macros | ||
var arraystretch = utils.deflt(group.value.arraystretch, 1); | ||
var arrayskip = arraystretch * baselineskip; | ||
@@ -574,10 +584,15 @@ var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and | ||
var offset = totalHeight / 2 + fontMetrics.metrics.axisHeight; | ||
var colalign = group.value.colalign || []; | ||
var coldescriptions = group.value.cols || []; | ||
var cols = []; | ||
var colsep; | ||
for (c = 0; c < nc; ++c) { | ||
var coldescr = coldescriptions[c] || {}; | ||
var sepwidth; | ||
if (c > 0 || group.value.hskipBeforeAndAfter) { | ||
colsep = makeSpan(["arraycolsep"], []); | ||
colsep.style.width = arraycolsep + "em"; | ||
cols.push(colsep); | ||
sepwidth = utils.deflt(coldescr.pregap, arraycolsep); | ||
if (sepwidth !== 0) { | ||
colsep = makeSpan(["arraycolsep"], []); | ||
colsep.style.width = sepwidth + "em"; | ||
cols.push(colsep); | ||
} | ||
} | ||
@@ -598,13 +613,16 @@ var col = []; | ||
col = makeSpan( | ||
["col-align-" + (colalign[c] || "c")], | ||
["col-align-" + (coldescr.align || "c")], | ||
[col]); | ||
cols.push(col); | ||
if (c < nc - 1 || group.value.hskipBeforeAndAfter) { | ||
colsep = makeSpan(["arraycolsep"], []); | ||
colsep.style.width = arraycolsep + "em"; | ||
cols.push(colsep); | ||
sepwidth = utils.deflt(coldescr.postgap, arraycolsep); | ||
if (sepwidth !== 0) { | ||
colsep = makeSpan(["arraycolsep"], []); | ||
colsep.style.width = sepwidth + "em"; | ||
cols.push(colsep); | ||
} | ||
} | ||
} | ||
body = makeSpan(["mtable"], cols); | ||
return makeSpan(["minner"], [body], options.getColor()); | ||
return makeSpan(["mord"], [body], options.getColor()); | ||
}, | ||
@@ -1036,3 +1054,3 @@ | ||
// Empty delimiters in \left and \right make null delimiter spaces. | ||
leftDelim = makeSpan(["nulldelimiter"]); | ||
leftDelim = makeNullDelimiter(options); | ||
} else { | ||
@@ -1051,3 +1069,3 @@ // Otherwise, use leftRightDelim to generate the correct sized | ||
if (group.value.right === ".") { | ||
rightDelim = makeSpan(["nulldelimiter"]); | ||
rightDelim = makeNullDelimiter(options); | ||
} else { | ||
@@ -1054,0 +1072,0 @@ rightDelim = delimiter.leftRightDelim( |
@@ -0,1 +1,2 @@ | ||
var fontMetrics = require("./fontMetrics"); | ||
var parseData = require("./parseData"); | ||
@@ -69,6 +70,8 @@ var ParseError = require("./ParseError"); | ||
colalign = colalign.value.map ? colalign.value : [colalign]; | ||
colalign = colalign.map(function(node) { | ||
var cols = colalign.map(function(node) { | ||
var ca = node.value; | ||
if ("lcr".indexOf(ca) !== -1) { | ||
return ca; | ||
return { | ||
align: ca | ||
}; | ||
} | ||
@@ -81,3 +84,3 @@ throw new ParseError( | ||
type: "array", | ||
colalign: colalign, | ||
cols: cols, | ||
hskipBeforeAndAfter: true // \@preamble in lttab.dtx | ||
@@ -93,3 +96,10 @@ }; | ||
{ | ||
names: ["matrix", "pmatrix", "bmatrix", "vmatrix", "Vmatrix"], | ||
names: [ | ||
"matrix", | ||
"pmatrix", | ||
"bmatrix", | ||
"Bmatrix", | ||
"vmatrix", | ||
"Vmatrix" | ||
], | ||
handler: function(pos, mode, envName) { | ||
@@ -100,2 +110,3 @@ var delimiters = { | ||
"bmatrix": ["[", "]"], | ||
"Bmatrix": ["\\{", "\\}"], | ||
"vmatrix": ["|", "|"], | ||
@@ -118,4 +129,32 @@ "Vmatrix": ["\\Vert", "\\Vert"] | ||
} | ||
}, | ||
// A cases environment (in amsmath.sty) is almost equivalent to | ||
// \def\arraystretch{1.2}% | ||
// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. | ||
{ | ||
names: ["cases"], | ||
handler: function(pos, mode, envName) { | ||
var res = { | ||
type: "array", | ||
arraystretch: 1.2, | ||
cols: [{ | ||
align: "l", | ||
pregap: 0, | ||
postgap: fontMetrics.metrics.quad | ||
}, { | ||
align: "l", | ||
pregap: 0, | ||
postgap: 0 | ||
}] | ||
}; | ||
res = parseArray(this, pos, mode, res); | ||
res.result = new ParseNode("leftright", { | ||
body: [res.result], | ||
left: "\\{", | ||
right: "." | ||
}, mode); | ||
return res; | ||
} | ||
} | ||
]; | ||
@@ -122,0 +161,0 @@ |
@@ -10,2 +10,3 @@ /** | ||
"textord", "mathord", etc). | ||
See https://github.com/Khan/KaTeX/wiki/Examining-TeX#group-types | ||
* - replace (optional): the character that this symbol or function should be | ||
@@ -775,2 +776,7 @@ * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi | ||
}, | ||
"\\circledR": { | ||
font: "ams", | ||
group: "textord", | ||
replace: "\u00ae" | ||
}, | ||
"\\measuredangle": { | ||
@@ -881,2 +887,7 @@ font: "ams", | ||
}, | ||
"\\checkmark": { | ||
font: "ams", | ||
group: "textord", | ||
replace: "\u2713" | ||
}, | ||
@@ -883,0 +894,0 @@ // AMS Hebrew |
@@ -34,2 +34,9 @@ /** | ||
/** | ||
* Provide a default value if a setting is undefined | ||
*/ | ||
var deflt = function(setting, defaultIfUndefined) { | ||
return setting === undefined ? defaultIfUndefined : setting; | ||
}; | ||
// hyphenate and escape adapted from Facebook's React under Apache 2 license | ||
@@ -93,2 +100,3 @@ | ||
contains: contains, | ||
deflt: deflt, | ||
escape: escape, | ||
@@ -95,0 +103,0 @@ hyphenate: hyphenate, |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
339746
26
8601
9