Socket
Socket
Sign inDemoInstall

katex

Package Overview
Dependencies
Maintainers
6
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

katex - npm Package Compare versions

Comparing version 0.10.1 to 0.10.2

src/functions/includegraphics.js

51

CHANGELOG.md
# Changelog
All notable changes to this project will be documented in this file. This CHANGELOG roughly follows the guidelines from [www.keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
## [v0.10.2]
### Added
- Approximate font metrics only when metrics don't exist (#1898)
- Add KaTeX version to stylesheet and troubleshooting guide (#1893)
- Add symbol double square brackets (#1947, #1954)
- Support double-square curly braces (#1953)
### Changed
- Upgrade minimum development Node version to v8 (#1861)
- Disable @babel/env debug (#1874)
- Add issue templates (#1862)
- Added 'katex-element' (#1905)
- Fix Users' logo and url (#1896)
- Load fonts before running screenshotter (#1891)
- Add Browserstack logo (#1879)
- Added Android library (#1943)
- Move custom colors used by Khan into macros.js (#1933)
- Test for duplicate symbols/macros (#1955)
- Include extensions mhchem & copy-tex in home-page (#1932)
### Fixed
- Fix \Rho (#1870)
- Fix nested \dfrac (#1825)
- Improve MathML accents (#1877)
- Improve MathML for \overset, \stackrel, and \underset (#1886)
- Fix \not (U+E020) RBearing (width) (#1878)
- Fix ApplyFunction character (#1890)
- Improve MathML for \limits (#1897)
- Improve MathML for \hphantom and \vphantom (#1883)
- Improve MathML for \coloneqq, \dblcolon, \eqcolon, and \eqqcolon (#1889)
- Improve MathML for \brace (#1884)
- Fix \middle spacing (#1906)
- Get a tall \middle\vert from MathML (#1911)
- Improve more coloneq (#1902)
- Make \smallint small in \displaystyle (#1907)
- Improve MathML for characters in Unicode private use area (#1908)
- Improve MathML for extensible arrows (#1901)
- Improve MathML for \rule (#1912)
- Improve MathML for fractions (#1882)
- Improve MathML for \tag (#1915)
- Improve MathML for \colorbox and \fcolorbox (#1914)
- Improve MathML for environments (#1910)
- Improve MathML for \genfrac barline (#1925)
- Support \textup and \textmd (#1921)
- Improve MathML for \not (#1923)
- Improve MathML for \Bbbk (#1930)
- Prevent inadvertent tall delims (#1948)
### Removed
- Re-added code for \includegraphics but disabled the function until trust settings is merged (#1951)
## [v0.10.1]

@@ -5,0 +56,0 @@ ### Added

6

contrib/copy-tex/README.md

@@ -24,4 +24,4 @@ # Copy-tex extension

```html
<link href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/copy-tex.css" rel="stylesheet" type="text/css">
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/copy-tex.min.js" integrity="sha384-XhWAe6BtVcvEdS3FFKT7Mcft4HJjPqMQvi5V4YhzH9Qxw497jC13TupOEvjoIPy7" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/copy-tex.css" rel="stylesheet" type="text/css">
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/copy-tex.min.js" integrity="sha384-XhWAe6BtVcvEdS3FFKT7Mcft4HJjPqMQvi5V4YhzH9Qxw497jC13TupOEvjoIPy7" crossorigin="anonymous"></script>
```

@@ -42,3 +42,3 @@

```html
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/copy-tex.mjs" integrity="sha384-kS7UtO844uqLwxPmaRwzg1nGbKiHsIteWh+DP2cvT2FtigL0v6w1yPXYKEDzct0C" crossorigin="anonymous"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/copy-tex.mjs" integrity="sha384-kS7UtO844uqLwxPmaRwzg1nGbKiHsIteWh+DP2cvT2FtigL0v6w1yPXYKEDzct0C" crossorigin="anonymous"></script>
```` -->

@@ -45,0 +45,0 @@

@@ -15,3 +15,3 @@ # `math/tex` Custom Script Type Extension

```html
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/mathtex-script-type.min.js" integrity="sha384-LJ2FmexL77rmGm6SIpxq7y+XA6bkLzGZEgCywzKOZG/ws4va9fUVu2neMjvc3zdv"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/mathtex-script-type.min.js" integrity="sha384-LJ2FmexL77rmGm6SIpxq7y+XA6bkLzGZEgCywzKOZG/ws4va9fUVu2neMjvc3zdv"></script>
```

@@ -27,8 +27,8 @@ You can download the script and use it locally, or from a local KaTeX installation instead.

<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
</head>
<body>
<script type="math/tex">x+\sqrt{1-x^2}</script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/mathtex-script-type.min.js" integrity="sha384-LJ2FmexL77rmGm6SIpxq7y+XA6bkLzGZEgCywzKOZG/ws4va9fUVu2neMjvc3zdv"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/mathtex-script-type.min.js" integrity="sha384-LJ2FmexL77rmGm6SIpxq7y+XA6bkLzGZEgCywzKOZG/ws4va9fUVu2neMjvc3zdv"></script>
</body>

@@ -41,3 +41,3 @@ </html>

```html
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/mathtex-script-type.mjs" integrity="sha384-qc7HqE4GHbr2H9R+C8mTSdJmkkZ9E1bkIRyRrxMsoj3dcbGjILzoXJGcBGGns1bk" crossorigin="anonymous"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/mathtex-script-type.mjs" integrity="sha384-qc7HqE4GHbr2H9R+C8mTSdJmkkZ9E1bkIRyRrxMsoj3dcbGjILzoXJGcBGGns1bk" crossorigin="anonymous"></script>
```` -->

@@ -10,3 +10,3 @@ # mhchem extension

```html
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/mhchem.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/mhchem.min.js" integrity="sha384-oa0lfxCGjaU1LdYckhq8LZcP+JTf8cyJXe69O6VE6UrShzWveT6KiCElJrck/stm"></script>
```

@@ -13,0 +13,0 @@

@@ -8,3 +8,3 @@ # [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)

[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex)
![](https://img.badgesize.io/KaTeX/KaTeX/v0.10.1/dist/katex.min.js?compression=gzip)
![](https://img.badgesize.io/KaTeX/KaTeX/v0.10.2/dist/katex.min.js?compression=gzip)

@@ -33,9 +33,9 @@ KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.

<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>

@@ -42,0 +42,0 @@ </head>

{
"name": "katex",
"version": "0.10.1",
"version": "0.10.2",
"description": "Fast math typesetting for the web.",

@@ -5,0 +5,0 @@ "main": "dist/katex.js",

@@ -8,3 +8,3 @@ # [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)

[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex)
![](https://img.badgesize.io/KaTeX/KaTeX/v0.10.1/dist/katex.min.js?compression=gzip)
![](https://img.badgesize.io/KaTeX/KaTeX/v0.10.2/dist/katex.min.js?compression=gzip)

@@ -33,9 +33,9 @@ KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.

<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>

@@ -42,0 +42,0 @@ </head>

@@ -148,2 +148,15 @@ // @flow

}
} else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) {
const lastChild = lastGroup.children[0];
if (lastChild instanceof TextNode && lastChild.text === '\u0338' &&
(group.type === 'mo' || group.type === 'mi' ||
group.type === 'mn')) {
const child = group.children[0];
if (child instanceof TextNode && child.text.length > 0) {
// Overlay with combining character long solidus
child.text = child.text.slice(0, 1) + "\u0338" +
child.text.slice(1);
groups.pop();
}
}
}

@@ -154,5 +167,2 @@ }

}
// TODO(kevinb): combine \\not with mrels and mords
return groups;

@@ -159,0 +169,0 @@ };

@@ -267,2 +267,65 @@ // @flow

/**
* This node represents an image embed (<img>) element.
*/
export class Img implements VirtualNode {
src: string;
alt: string;
classes: string[];
height: number;
depth: number;
maxFontSize: number;
style: CssStyle;
constructor(
src: string,
alt: string,
style: CssStyle,
) {
this.alt = alt;
this.src = src;
this.classes = ["mord"];
this.style = style;
}
hasClass(className: string): boolean {
return utils.contains(this.classes, className);
}
toNode(): Node {
const node = document.createElement("img");
node.src = this.src;
node.alt = this.alt;
node.className = "mord";
// Apply inline styles
for (const style in this.style) {
if (this.style.hasOwnProperty(style)) {
// $FlowFixMe
node.style[style] = this.style[style];
}
}
return node;
}
toMarkup(): string {
let markup = `<img src='${this.src} 'alt='${this.alt}' `;
// Add the styles, after hyphenation
let styles = "";
for (const style in this.style) {
if (this.style.hasOwnProperty(style)) {
styles += `${utils.hyphenate(style)}:${this.style[style]};`;
}
}
if (styles) {
markup += ` style="${utils.escape(styles)}"`;
}
markup += "'/>";
return markup;
}
}
const iCombinations = {

@@ -269,0 +332,0 @@ 'î': '\u0131\u0302',

@@ -28,2 +28,5 @@ // @flow

// Type to indicate column separation in MathML
export type ColSeparationType = "align" | "alignat";
function getHLines(parser: Parser): boolean[] {

@@ -52,3 +55,3 @@ // Return an array. The array length = number of hlines.

parser: Parser,
{hskipBeforeAndAfter, addJot, cols, arraystretch}: {|
{hskipBeforeAndAfter, addJot, cols, arraystretch, colSeparationType}: {|
hskipBeforeAndAfter?: boolean,

@@ -58,2 +61,3 @@ addJot?: boolean,

arraystretch?: number,
colSeparationType?: ColSeparationType,
|},

@@ -144,2 +148,3 @@ style: StyleStr,

hLinesBeforeRow,
colSeparationType,
};

@@ -374,4 +379,10 @@ }

const alignMap = {
c: "center ",
l: "left ",
r: "right ",
};
const mathmlBuilder: MathMLBuilder<"array"> = function(group, options) {
return new mathMLTree.MathNode(
const table = new mathMLTree.MathNode(
"mtable", group.body.map(function(row) {

@@ -384,2 +395,106 @@ return new mathMLTree.MathNode(

}));
// Set column alignment, row spacing, column spacing, and
// array lines by setting attributes on the table element.
// Set the row spacing. In MathML, we specify a gap distance.
// We do not use rowGap[] because MathML automatically increases
// cell height with the height/depth of the element content.
// LaTeX \arraystretch multiplies the row baseline-to-baseline distance.
// We simulate this by adding (arraystretch - 1)em to the gap. This
// does a reasonable job of adjusting arrays containing 1 em tall content.
// The 0.16 and 0.09 values are found emprically. They produce an array
// similar to LaTeX and in which content does not interfere with \hines.
const gap = 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
table.setAttribute("rowspacing", gap + "em");
// MathML table lines go only between cells.
// To place a line on an edge we'll use <menclose>, if necessary.
let menclose = "";
let align = "";
if (group.cols) {
// Find column alignment, column spacing, and vertical lines.
const cols = group.cols;
let columnLines = "";
let prevTypeWasAlign = false;
let iStart = 0;
let iEnd = cols.length;
if (cols[0].type === "separator") {
menclose += "top ";
iStart = 1;
}
if (cols[cols.length - 1].type === "separator") {
menclose += "bottom ";
iEnd -= 1;
}
for (let i = iStart; i < iEnd; i++) {
if (cols[i].type === "align") {
align += alignMap[cols[i].align];
if (prevTypeWasAlign) {
columnLines += "none ";
}
prevTypeWasAlign = true;
} else if (cols[i].type === "separator") {
// MathML accepts only single lines between cells.
// So we read only the first of consecutive separators.
if (prevTypeWasAlign) {
columnLines += cols[i].separator === "|"
? "solid "
: "dashed ";
prevTypeWasAlign = false;
}
}
}
table.setAttribute("columnalign", align.trim());
if (/[sd]/.test(columnLines)) {
table.setAttribute("columnlines", columnLines.trim());
}
}
// Set column spacing.
if (group.colSeparationType === "align") {
const cols = group.cols || [];
let spacing = "";
for (let i = 1; i < cols.length; i++) {
spacing += i % 2 ? "0em " : "1em ";
}
table.setAttribute("columnspacing", spacing.trim());
} else if (group.colSeparationType === "alignat") {
table.setAttribute("columnspacing", "0em");
} else {
table.setAttribute("columnspacing", "1em");
}
// Address \hline and \hdashline
let rowLines = "";
const hlines = group.hLinesBeforeRow;
menclose += hlines[0].length > 0 ? "left " : "";
menclose += hlines[hlines.length - 1].length > 0 ? "right " : "";
for (let i = 1; i < hlines.length - 1; i++) {
rowLines += (hlines[i].length === 0)
? "none "
// MathML accepts only a single line between rows. Read one element.
: hlines[i][0] ? "dashed " : "solid ";
}
if (/[sd]/.test(rowLines)) {
table.setAttribute("rowlines", rowLines.trim());
}
if (menclose === "") {
return table;
} else {
const wrapper = new mathMLTree.MathNode("menclose", [table]);
wrapper.setAttribute("notation", menclose.trim());
return wrapper;
}
};

@@ -457,2 +572,3 @@

}
res.colSeparationType = isAligned ? "align" : "alignat";
return res;

@@ -459,0 +575,0 @@ };

@@ -214,6 +214,7 @@ // @flow

let ch = character.charCodeAt(0);
if (character[0] in extraCharacterMap) {
let metrics = metricMap[font][ch];
if (!metrics && character[0] in extraCharacterMap) {
ch = extraCharacterMap[character[0]].charCodeAt(0);
metrics = metricMap[font][ch];
}
let metrics = metricMap[font][ch];

@@ -220,0 +221,0 @@ if (!metrics && mode === 'text') {

@@ -24,2 +24,4 @@ // @flow

import "./functions/htmlmathml";
// Disabled until https://github.com/KaTeX/KaTeX/pull/1794 is merged.
// import "./functions/includegraphics";
import "./functions/kern";

@@ -26,0 +28,0 @@ import "./functions/lap";

@@ -12,2 +12,10 @@ // @flow

// Helper function
const paddedNode = group => {
const node = new mathMLTree.MathNode("mpadded", group ? [group] : []);
node.setAttribute("width", "+0.6em");
node.setAttribute("lspace", "0.3em");
return node;
};
// Stretchy arrows with an optional argument

@@ -109,8 +117,7 @@ defineFunction({

let node;
let lowerNode;
if (group.body) {
const upperNode = mml.buildGroup(group.body, options);
const upperNode = paddedNode(mml.buildGroup(group.body, options));
if (group.below) {
lowerNode = mml.buildGroup(group.below, options);
const lowerNode = paddedNode(mml.buildGroup(group.below, options));
node = new mathMLTree.MathNode(

@@ -123,6 +130,9 @@ "munderover", [arrowNode, lowerNode, upperNode]

} else if (group.below) {
lowerNode = mml.buildGroup(group.below, options);
const lowerNode = paddedNode(mml.buildGroup(group.below, options));
node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]);
} else {
node = new mathMLTree.MathNode("mover", [arrowNode]);
// This should never happen.
// Parser.js throws an error if there is no argument.
node = paddedNode();
node = new mathMLTree.MathNode("mover", [arrowNode, node]);
}

@@ -129,0 +139,0 @@ return node;

@@ -25,3 +25,4 @@ // @flow

const mathmlBuilder = (group, options) => {
const inner = mml.buildExpression(group.body, options);
const inner = mml.buildExpression(group.body,
options.withColor(group.color));

@@ -58,40 +59,4 @@ const node = new mathMLTree.MathNode("mstyle", inner);

// TODO(kevinb): define these using macros
defineFunction({
type: "color",
names: [
"\\blue", "\\orange", "\\pink", "\\red",
"\\green", "\\gray", "\\purple",
"\\blueA", "\\blueB", "\\blueC", "\\blueD", "\\blueE",
"\\tealA", "\\tealB", "\\tealC", "\\tealD", "\\tealE",
"\\greenA", "\\greenB", "\\greenC", "\\greenD", "\\greenE",
"\\goldA", "\\goldB", "\\goldC", "\\goldD", "\\goldE",
"\\redA", "\\redB", "\\redC", "\\redD", "\\redE",
"\\maroonA", "\\maroonB", "\\maroonC", "\\maroonD", "\\maroonE",
"\\purpleA", "\\purpleB", "\\purpleC", "\\purpleD", "\\purpleE",
"\\mintA", "\\mintB", "\\mintC",
"\\grayA", "\\grayB", "\\grayC", "\\grayD", "\\grayE",
"\\grayF", "\\grayG", "\\grayH", "\\grayI",
"\\kaBlue", "\\kaGreen",
],
props: {
numArgs: 1,
allowedInText: true,
greediness: 3,
},
handler({parser, funcName}, args) {
const body = args[0];
return {
type: "color",
mode: parser.mode,
color: "katex-" + funcName.slice(1),
body: ordargument(body),
};
},
htmlBuilder,
mathmlBuilder,
});
defineFunction({
type: "color",
names: ["\\color"],

@@ -98,0 +63,0 @@ props: {

@@ -321,7 +321,17 @@ // @flow

mathmlBuilder: (group, options) => {
const middleNode = new mathMLTree.MathNode(
"mo", [mml.makeText(group.delim, group.mode)]);
// A Firefox \middle will strech a character vertically only if it
// is in the fence part of the operator dictionary at:
// https://www.w3.org/TR/MathML3/appendixc.html.
// So we need to avoid U+2223 and use plain "|" instead.
const textNode = (group.delim === "\\vert" || group.delim === "|")
? mml.makeText("|", "text")
: mml.makeText(group.delim, group.mode);
const middleNode = new mathMLTree.MathNode("mo", [textNode]);
middleNode.setAttribute("fence", "true");
// MathML gives 5/18em spacing to each <mo> element.
// \middle should get delimiter spacing instead.
middleNode.setAttribute("lspace", "0.05em");
middleNode.setAttribute("rspace", "0.05em");
return middleNode;
},
});

@@ -115,3 +115,5 @@ // @flow

const node = new mathMLTree.MathNode(
"menclose", [mml.buildGroup(group.body, options)]);
(group.label.indexOf("colorbox") > -1) ? "mpadded" : "menclose",
[mml.buildGroup(group.body, options)]
);
switch (group.label) {

@@ -131,4 +133,14 @@ case "\\cancel":

case "\\fcolorbox":
// TODO(ron): I don't know any way to set the border color.
node.setAttribute("notation", "box");
case "\\colorbox":
// <menclose> doesn't have a good notation option. So use <mpadded>
// instead. Set some attributes that come included with <menclose>.
node.setAttribute("width", "+6pt");
node.setAttribute("height", "+6pt");
node.setAttribute("lspace", "3pt"); // LaTeX source2e: \fboxsep = 3pt
node.setAttribute("voffset", "3pt");
if (group.label === "\\fcolorbox") {
const thk = options.fontMetrics().defaultRuleThickness;
node.setAttribute("style", "border: " + thk + "em solid " +
String(group.borderColor));
}
break;

@@ -135,0 +147,0 @@ case "\\xcancel":

@@ -14,19 +14,26 @@ // @flow

const htmlBuilder = (group, options) => {
// Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
const adjustStyle = (size, originalStyle) => {
// Figure out what style this fraction should be in based on the
// function used
let style = options.style;
if (group.size === "display") {
style = Style.DISPLAY;
} else if (group.size === "text" &&
let style = originalStyle;
if (size === "display") {
// Get display style as a default.
// If incoming style is sub/sup, use style.text() to get correct size.
style = style.id >= Style.SCRIPT.id ? style.text() : Style.DISPLAY;
} else if (size === "text" &&
style.size === Style.DISPLAY.size) {
// We're in a \tfrac but incoming style is displaystyle, so:
style = Style.TEXT;
} else if (group.size === "script") {
} else if (size === "script") {
style = Style.SCRIPT;
} else if (group.size === "scriptscript") {
} else if (size === "scriptscript") {
style = Style.SCRIPTSCRIPT;
}
return style;
};
const htmlBuilder = (group, options) => {
// Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
const style = adjustStyle(group.size, options.style);
const nstyle = style.fracNum();

@@ -73,3 +80,3 @@ const dstyle = style.fracDen();

let denomShift;
if (style.size === Style.DISPLAY.size) {
if (style.size === Style.DISPLAY.size || group.size === "display") {
numShift = options.fontMetrics().num1;

@@ -181,3 +188,3 @@ if (ruleWidth > 0) {

const mathmlBuilder = (group, options) => {
const node = new mathMLTree.MathNode(
let node = new mathMLTree.MathNode(
"mfrac",

@@ -196,2 +203,10 @@ [

const style = adjustStyle(group.size, options.style);
if (style.size !== options.style.size) {
node = new mathMLTree.MathNode("mstyle", [node]);
const isDisplay = (style.size === Style.DISPLAY.size) ? "true" : "false";
node.setAttribute("displaystyle", isDisplay);
node.setAttribute("scriptlevel", "0");
}
if (group.leftDelim != null || group.rightDelim != null) {

@@ -202,3 +217,5 @@ const withDelims = [];

const leftOp = new mathMLTree.MathNode(
"mo", [new mathMLTree.TextNode(group.leftDelim)]);
"mo",
[new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]
);

@@ -214,3 +231,5 @@ leftOp.setAttribute("fence", "true");

const rightOp = new mathMLTree.MathNode(
"mo", [new mathMLTree.TextNode(group.rightDelim)]);
"mo",
[new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]
);

@@ -217,0 +236,0 @@ rightOp.setAttribute("fence", "true");

@@ -102,2 +102,3 @@ // @flow

alwaysHandleSupSub: true,
parentIsSupSub: false,
symbol: false,

@@ -104,0 +105,0 @@ suppressBaseShift: funcName !== "\\stackrel",

@@ -17,2 +17,7 @@ // @flow

// Most operators have a large successor symbol, but these don't.
const noSuccessor = [
"\\smallint",
];
// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also

@@ -41,7 +46,2 @@ // "supsub" since some of them (like \int) can affect super/subscripting.

// Most operators have a large successor symbol, but these don't.
const noSuccessor = [
"\\smallint",
];
let large = false;

@@ -242,4 +242,2 @@ if (style.size === Style.DISPLAY.size &&

// TODO(emily): handle big operators using the `largeop` attribute
if (group.symbol) {

@@ -249,2 +247,5 @@ // This is a symbol. Just add the symbol.

"mo", [mml.makeText(group.name, group.mode)]);
if (utils.contains(noSuccessor, group.name)) {
node.setAttribute("largeop", "false");
}
} else if (group.body) {

@@ -261,3 +262,2 @@ // This is an operator with children. Add them.

"mi", [new mathMLTree.TextNode(group.name.slice(1))]);
// Append an <mo>&ApplyFunction;</mo>.

@@ -267,4 +267,7 @@ // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4

[mml.makeText("\u2061", "text")]);
return mathMLTree.newDocumentFragment([node, operator]);
if (group.parentIsSupSub) {
node = new mathMLTree.MathNode("mo", [node, operator]);
} else {
node = mathMLTree.newDocumentFragment([node, operator]);
}
}

@@ -311,2 +314,3 @@

limits: true,
parentIsSupSub: false,
symbol: true,

@@ -334,2 +338,3 @@ name: fName,

limits: false,
parentIsSupSub: false,
symbol: false,

@@ -374,2 +379,3 @@ body: ordargument(body),

limits: false,
parentIsSupSub: false,
symbol: false,

@@ -397,2 +403,3 @@ name: funcName,

limits: true,
parentIsSupSub: false,
symbol: false,

@@ -425,2 +432,3 @@ name: funcName,

limits: false,
parentIsSupSub: false,
symbol: true,

@@ -427,0 +435,0 @@ name: fName,

@@ -79,4 +79,6 @@ // @flow

const inner = mml.buildExpression(ordargument(group.body), options);
const node = new mathMLTree.MathNode("mphantom", inner);
const phantom = new mathMLTree.MathNode("mphantom", inner);
const node = new mathMLTree.MathNode("mpadded", [phantom]);
node.setAttribute("height", "0px");
node.setAttribute("depth", "0px");
return node;

@@ -111,3 +113,4 @@ },

const inner = mml.buildExpression(ordargument(group.body), options);
const node = new mathMLTree.MathNode("mphantom", inner);
const phantom = new mathMLTree.MathNode("mphantom", inner);
const node = new mathMLTree.MathNode("mpadded", [phantom]);
node.setAttribute("width", "0px");

@@ -114,0 +117,0 @@ return node;

@@ -33,9 +33,5 @@ // @flow

// Calculate the shift, width, and height of the rule, and account for units
let shift = 0;
if (group.shift) {
shift = calculateSize(group.shift, options);
}
const width = calculateSize(group.width, options);
const height = calculateSize(group.height, options);
const shift = (group.shift) ? calculateSize(group.shift, options) : 0;

@@ -59,8 +55,23 @@ // Style the rule to the right size

mathmlBuilder(group, options) {
// TODO(emily): Figure out if there's an actual way to draw black boxes
// in MathML.
const node = new mathMLTree.MathNode("mrow");
const width = calculateSize(group.width, options);
const height = calculateSize(group.height, options);
const shift = (group.shift) ? calculateSize(group.shift, options) : 0;
const color = options.color && options.getColor() || "black";
return node;
const rule = new mathMLTree.MathNode("mspace");
rule.setAttribute("mathbackground", color);
rule.setAttribute("width", width + "em");
rule.setAttribute("height", height + "em");
const wrapper = new mathMLTree.MathNode("mpadded", [rule]);
if (shift >= 0) {
wrapper.setAttribute("height", "+" + shift + "em");
} else {
wrapper.setAttribute("height", shift + "em");
wrapper.setAttribute("depth", "+" + (-shift) + "em");
}
wrapper.setAttribute("voffset", shift + "em");
return wrapper;
},
});

@@ -204,2 +204,6 @@ // @flow

if (group.base && group.base.type === "op") {
group.base.parentIsSupSub = true;
}
const children = [mml.buildGroup(group.base, options)];

@@ -221,3 +225,3 @@

if (base && base.type === "op" && base.limits &&
options.style === Style.DISPLAY) {
(options.style === Style.DISPLAY || base.alwaysHandleSupSub)) {
nodeType = "mover";

@@ -230,3 +234,3 @@ } else {

if (base && base.type === "op" && base.limits &&
options.style === Style.DISPLAY) {
(options.style === Style.DISPLAY || base.alwaysHandleSupSub)) {
nodeType = "munder";

@@ -233,0 +237,0 @@ } else {

@@ -26,2 +26,6 @@ // @flow

node.setAttribute("separator", "true");
} else if (group.family === "open" || group.family === "close") {
// Delims built here should not stretch vertically.
// See delimsizing.js for stretchy delims.
node.setAttribute("stretchy", "false");
}

@@ -28,0 +32,0 @@ return node;

@@ -7,2 +7,8 @@ // @flow

const pad = () => {
const padNode = new mathMLTree.MathNode("mtd", []);
padNode.setAttribute("width", "50%");
return padNode;
};
defineFunctionBuilders({

@@ -12,15 +18,25 @@ type: "tag",

const table = new mathMLTree.MathNode("mtable", [
new mathMLTree.MathNode("mlabeledtr", [
new mathMLTree.MathNode("mtr", [
pad(),
new mathMLTree.MathNode("mtd", [
mml.buildExpressionRow(group.tag, options),
mml.buildExpressionRow(group.body, options),
]),
pad(),
new mathMLTree.MathNode("mtd", [
mml.buildExpressionRow(group.body, options),
mml.buildExpressionRow(group.tag, options),
]),
]),
]);
table.setAttribute("side", "right");
table.setAttribute("width", "100%");
return table;
// TODO: Left-aligned tags.
// Currently, the group and options passed here do not contain
// enough info to set tag alignment. `leqno` is in Settings but it is
// not passed to Options. On the HTML side, leqno is
// set by a CSS class applied in buildTree.js. That would have worked
// in MathML if browsers supported <mlabeledtr>. Since they don't, we
// need to rewrite the way this function is called.
},
});

@@ -16,2 +16,3 @@ // @flow

"\\textbf": "textbf",
"\\textmd": "textmd",
};

@@ -21,2 +22,3 @@

"\\textit": "textit",
"\\textup": "textup",
};

@@ -44,5 +46,5 @@

// Font weights
"\\textbf",
"\\textbf", "\\textmd",
// Font Shapes
"\\textit",
"\\textit", "\\textup",
],

@@ -49,0 +51,0 @@ props: {

@@ -337,2 +337,5 @@ // @flow

// Define \Bbbk with a macro that works in both HTML and MathML.
defineMacro("\\Bbbk", "\\Bbb{k}");
// Unicode middle dot

@@ -352,3 +355,4 @@ // The KaTeX fonts do not contain U+00B7. Instead, \cdotp displays

// width but extends to the right. We use \rlap to get that spacing.
defineMacro("\\not", '\\mathrel{\\mathrlap\\@not}');
// For MathML we write U+0338 here. buildMathML.js will then do the overlay.
defineMacro("\\not", '\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}');

@@ -724,36 +728,57 @@ // Negated symbols from base/fontmath.ltx:

// \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon}
defineMacro("\\dblcolon",
"\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}");
defineMacro("\\dblcolon", "\\html@mathml{" +
"\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" +
"{\\mathop{\\char\"2237}}");
// \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=}
defineMacro("\\coloneqq", "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}");
defineMacro("\\coloneqq", "\\html@mathml{" +
"\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" +
"{\\mathop{\\char\"2254}}"); // ≔
// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=}
defineMacro("\\Coloneqq", "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}");
defineMacro("\\Coloneqq", "\\html@mathml{" +
"\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" +
"{\\mathop{\\char\"2237\\char\"3d}}");
// \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
defineMacro("\\coloneq",
"\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}");
defineMacro("\\coloneq", "\\html@mathml{" +
"\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" +
"{\\mathop{\\char\"3a\\char\"2212}}");
// \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
defineMacro("\\Coloneq",
"\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}");
defineMacro("\\Coloneq", "\\html@mathml{" +
"\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" +
"{\\mathop{\\char\"2237\\char\"2212}}");
// \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon}
defineMacro("\\eqqcolon", "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}");
defineMacro("\\eqqcolon", "\\html@mathml{" +
"\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" +
"{\\mathop{\\char\"2255}}"); // ≕
// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon}
defineMacro("\\Eqqcolon", "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}");
defineMacro("\\Eqqcolon", "\\html@mathml{" +
"\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" +
"{\\mathop{\\char\"3d\\char\"2237}}");
// \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon}
defineMacro("\\eqcolon",
"\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}");
defineMacro("\\eqcolon", "\\html@mathml{" +
"\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" +
"{\\mathop{\\char\"2239}}");
// \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon}
defineMacro("\\Eqcolon",
"\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}");
defineMacro("\\Eqcolon", "\\html@mathml{" +
"\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" +
"{\\mathop{\\char\"2212\\char\"2237}}");
// \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx}
defineMacro("\\colonapprox",
"\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}");
defineMacro("\\colonapprox", "\\html@mathml{" +
"\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" +
"{\\mathop{\\char\"3a\\char\"2248}}");
// \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx}
defineMacro("\\Colonapprox",
"\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}");
defineMacro("\\Colonapprox", "\\html@mathml{" +
"\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" +
"{\\mathop{\\char\"2237\\char\"2248}}");
// \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim}
defineMacro("\\colonsim", "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}");
defineMacro("\\colonsim", "\\html@mathml{" +
"\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" +
"{\\mathop{\\char\"3a\\char\"223c}}");
// \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim}
defineMacro("\\Colonsim", "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}");
defineMacro("\\Colonsim", "\\html@mathml{" +
"\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" +
"{\\mathop{\\char\"2237\\char\"223c}}");
// Some Unicode characters are implemented with macros to mathtools functions.
defineMacro("\u2237", "\\dblcolon"); // ::
defineMacro("\u2239", "\\eqcolon"); // -:
defineMacro("\u2254", "\\coloneqq"); // :=

@@ -798,10 +823,44 @@ defineMacro("\u2255", "\\eqqcolon"); // =:

//////////////////////////////////////////////////////////////////////
// semantic
// MathML alternates for KaTeX glyphs in the Unicode private area
defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}");
defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}");
defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}");
defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}");
defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}");
defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}");
defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}");
defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}");
defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}");
defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}");
defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}");
defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}");
defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}");
defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}");
// The semantic package renders the next two items by calling a glyph from the
// bbold package. Those glyphs do not exist in the KaTeX fonts. Hence the macros.
//////////////////////////////////////////////////////////////////////
// stmaryrd and semantic
defineMacro("\u27e6", "\\mathopen{[\\mkern-3.2mu[}"); // blackboard bold [
defineMacro("\u27e7", "\\mathclose{]\\mkern-3.2mu]}"); // blackboard bold ]
// The stmaryrd and semantic packages render the next four items by calling a
// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros.
defineMacro("\\llbracket", "\\html@mathml{" +
"\\mathopen{[\\mkern-3.2mu[}}" +
"{\\mathopen{\\char`\u27e6}}");
defineMacro("\\rrbracket", "\\html@mathml{" +
"\\mathclose{]\\mkern-3.2mu]}}" +
"{\\mathclose{\\char`\u27e7}}");
defineMacro("\u27e6", "\\llbracket"); // blackboard bold [
defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ]
defineMacro("\\lBrace", "\\html@mathml{" +
"\\mathopen{\\{\\mkern-3.2mu[}}" +
"{\\mathopen{\\char`\u2983}}");
defineMacro("\\rBrace", "\\html@mathml{" +
"\\mathclose{]\\mkern-3.2mu\\}}}" +
"{\\mathclose{\\char`\u2984}}");
defineMacro("\u2983", "\\lBrace"); // blackboard bold {
defineMacro("\u2984", "\\rBrace"); // blackboard bold }
// TODO: Create variable sized versions of the last two items. I believe that

@@ -871,3 +930,3 @@ // will require new font glyphs.

defineMacro("\\Reals", "\\mathbb{R}");
defineMacro("\\Rho", "\\mathrm{R}");
defineMacro("\\Rho", "\\mathrm{P}");
defineMacro("\\sdot", "\\cdot");

@@ -891,1 +950,59 @@ defineMacro("\\sect", "\\S");

defineMacro("\\argmax", "\\DOTSB\\mathop{\\operatorname{arg\\,max}}\\limits");
// Custom Khan Academy colors, should be moved to an optional package
defineMacro("\\blue", "\\textcolor{##6495ed}{#1}");
defineMacro("\\orange", "\\textcolor{##ffa500}{#1}");
defineMacro("\\pink", "\\textcolor{##ff00af}{#1}");
defineMacro("\\red", "\\textcolor{##df0030}{#1}");
defineMacro("\\green", "\\textcolor{##28ae7b}{#1}");
defineMacro("\\gray", "\\textcolor{gray}{##1}");
defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}");
defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}");
defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}");
defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}");
defineMacro("\\blueD", "\\textcolor{##11accd}{#1}");
defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}");
defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}");
defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}");
defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}");
defineMacro("\\tealD", "\\textcolor{##01a995}{#1}");
defineMacro("\\tealE", "\\textcolor{##208170}{#1}");
defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}");
defineMacro("\\greenB", "\\textcolor{##8af281}{#1}");
defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}");
defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}");
defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}");
defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}");
defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}");
defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}");
defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}");
defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}");
defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}");
defineMacro("\\redB", "\\textcolor{##ff8482}{#1}");
defineMacro("\\redC", "\\textcolor{##f9685d}{#1}");
defineMacro("\\redD", "\\textcolor{##e84d39}{#1}");
defineMacro("\\redE", "\\textcolor{##bc2612}{#1}");
defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}");
defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}");
defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}");
defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}");
defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}");
defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}");
defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}");
defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}");
defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}");
defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}");
defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}");
defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}");
defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}");
defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}");
defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}");
defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}");
defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}");
defineMacro("\\grayE", "\\textcolor{##babec2}{#1}");
defineMacro("\\grayF", "\\textcolor{##888d93}{#1}");
defineMacro("\\grayG", "\\textcolor{##626569}{#1}");
defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}");
defineMacro("\\grayI", "\\textcolor{##21242c}{#1}");
defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}");
defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}");

@@ -28,3 +28,3 @@ // @flow

"mrow" | "menclose" |
"mstyle" | "mpadded" | "mphantom";
"mstyle" | "mpadded" | "mphantom" | "mglyph";

@@ -31,0 +31,0 @@ export interface MathDomNode extends VirtualNode {

@@ -39,2 +39,6 @@ // @flow

// In these types, "" (empty string) means "no change".
export type FontWeight = "textbf" | "textmd" | "";
export type FontShape = "textit" | "textup" | "";
export type OptionsData = {

@@ -48,4 +52,4 @@ style: StyleInterface;

fontFamily?: string;
fontWeight?: string;
fontShape?: string;
fontWeight?: FontWeight;
fontShape?: FontShape;
sizeMultiplier?: number;

@@ -73,4 +77,4 @@ maxSize: number;

fontFamily: string;
fontWeight: string;
fontShape: string;
fontWeight: FontWeight;
fontShape: FontShape;
sizeMultiplier: number;

@@ -250,3 +254,3 @@ maxSize: number;

*/
withTextFontWeight(fontWeight: string): Options {
withTextFontWeight(fontWeight: FontWeight): Options {
return this.extend({

@@ -261,3 +265,3 @@ fontWeight,

*/
withTextFontShape(fontShape: string): Options {
withTextFontShape(fontShape: FontShape): Options {
return this.extend({

@@ -303,68 +307,5 @@ fontShape,

/**
* A map of color names to CSS colors.
* TODO(emily): Remove this when we have real macros
*/
static colorMap = {
"katex-blue": "#6495ed",
"katex-orange": "#ffa500",
"katex-pink": "#ff00af",
"katex-red": "#df0030",
"katex-green": "#28ae7b",
"katex-gray": "gray",
"katex-purple": "#9d38bd",
"katex-blueA": "#ccfaff",
"katex-blueB": "#80f6ff",
"katex-blueC": "#63d9ea",
"katex-blueD": "#11accd",
"katex-blueE": "#0c7f99",
"katex-tealA": "#94fff5",
"katex-tealB": "#26edd5",
"katex-tealC": "#01d1c1",
"katex-tealD": "#01a995",
"katex-tealE": "#208170",
"katex-greenA": "#b6ffb0",
"katex-greenB": "#8af281",
"katex-greenC": "#74cf70",
"katex-greenD": "#1fab54",
"katex-greenE": "#0d923f",
"katex-goldA": "#ffd0a9",
"katex-goldB": "#ffbb71",
"katex-goldC": "#ff9c39",
"katex-goldD": "#e07d10",
"katex-goldE": "#a75a05",
"katex-redA": "#fca9a9",
"katex-redB": "#ff8482",
"katex-redC": "#f9685d",
"katex-redD": "#e84d39",
"katex-redE": "#bc2612",
"katex-maroonA": "#ffbde0",
"katex-maroonB": "#ff92c6",
"katex-maroonC": "#ed5fa6",
"katex-maroonD": "#ca337c",
"katex-maroonE": "#9e034e",
"katex-purpleA": "#ddd7ff",
"katex-purpleB": "#c6b9fc",
"katex-purpleC": "#aa87ff",
"katex-purpleD": "#7854ab",
"katex-purpleE": "#543b78",
"katex-mintA": "#f5f9e8",
"katex-mintB": "#edf2df",
"katex-mintC": "#e0e5cc",
"katex-grayA": "#f6f7f7",
"katex-grayB": "#f0f1f2",
"katex-grayC": "#e3e5e6",
"katex-grayD": "#d6d8da",
"katex-grayE": "#babec2",
"katex-grayF": "#888d93",
"katex-grayG": "#626569",
"katex-grayH": "#3b3e40",
"katex-grayI": "#21242c",
"katex-kaBlue": "#314453",
"katex-kaGreen": "#71B307",
};
/**
* Gets the CSS color of the current options object, accounting for the
* `colorMap`.
* Gets the CSS color of the current options object
*/

@@ -374,7 +315,2 @@ getColor(): string | void {

return "transparent";
} else if (
this.color != null &&
Options.colorMap.hasOwnProperty(this.color)
) {
return Options.colorMap[this.color];
} else {

@@ -381,0 +317,0 @@ return this.color;

// @flow
import {NON_ATOMS} from "./symbols";
import type SourceLocation from "./SourceLocation";
import type {AlignSpec} from "./environments/array";
import type {AlignSpec, ColSeparationType} from "./environments/array";
import type {Atom} from "./symbols";

@@ -31,2 +31,3 @@ import type {Mode, StyleStr} from "./types";

loc?: ?SourceLocation,
colSeparationType?: ColSeparationType,
hskipBeforeAndAfter?: boolean,

@@ -53,2 +54,8 @@ addJot?: boolean,

|},
"keyVals": {|
type: "keyVals",
mode: Mode,
loc?: ?SourceLocation,
keyVals: string,
|},
// To avoid requiring run-time type assertions, this more carefully captures

@@ -65,2 +72,3 @@ // the requirements on the fields per the op.js htmlBuilder logic:

suppressBaseShift?: boolean,
parentIsSupSub: boolean,
symbol: boolean,

@@ -76,2 +84,3 @@ name: string,

suppressBaseShift?: boolean,
parentIsSupSub: boolean,
symbol: false, // If 'symbol' is true, `body` *must* be set.

@@ -278,2 +287,12 @@ name?: void,

|},
"includegraphics": {|
type: "includegraphics",
mode: Mode,
loc?: ?SourceLocation,
alt: string,
width: Measurement,
height: Measurement,
totalheight: Measurement,
src: string,
|},
"infix": {|

@@ -280,0 +299,0 @@ type: "infix",

@@ -28,4 +28,6 @@ // @flow

xrightarrow: "\u2192",
underbrace: "\u23b5",
underbrace: "\u23df",
overbrace: "\u23de",
overgroup: "\u23e0",
undergroup: "\u23e1",
overleftrightarrow: "\u2194",

@@ -32,0 +34,0 @@ underleftrightarrow: "\u2194",

@@ -205,7 +205,8 @@ // @flow

defineSymbol(math, ams, rel, "\u226e", "\\nless", true);
defineSymbol(math, ams, rel, "\ue010", "\\nleqslant");
defineSymbol(math, ams, rel, "\ue011", "\\nleqq");
// Symbol names preceeded by "@" each have a corresponding macro.
defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant");
defineSymbol(math, ams, rel, "\ue011", "\\@nleqq");
defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true);
defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true);
defineSymbol(math, ams, rel, "\ue00c", "\\lvertneqq");
defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq");
defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true);

@@ -219,3 +220,3 @@ defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true);

defineSymbol(math, ams, rel, "\u2241", "\\nsim", true);
defineSymbol(math, ams, rel, "\ue006", "\\nshortmid");
defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid");
defineSymbol(math, ams, rel, "\u2224", "\\nmid", true);

@@ -227,11 +228,11 @@ defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true);

defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true);
defineSymbol(math, ams, rel, "\ue01a", "\\varsubsetneq");
defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq");
defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true);
defineSymbol(math, ams, rel, "\ue017", "\\varsubsetneqq");
defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq");
defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true);
defineSymbol(math, ams, rel, "\ue00f", "\\ngeqslant");
defineSymbol(math, ams, rel, "\ue00e", "\\ngeqq");
defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant");
defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq");
defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true);
defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true);
defineSymbol(math, ams, rel, "\ue00d", "\\gvertneqq");
defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq");
defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true);

@@ -246,3 +247,3 @@ defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true);

defineSymbol(math, ams, rel, "\u2246", "\\ncong", true);
defineSymbol(math, ams, rel, "\ue007", "\\nshortparallel");
defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel");
defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true);

@@ -252,11 +253,11 @@ defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true);

defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true);
defineSymbol(math, ams, rel, "\ue018", "\\nsupseteqq");
defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq");
defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true);
defineSymbol(math, ams, rel, "\ue01b", "\\varsupsetneq");
defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq");
defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true);
defineSymbol(math, ams, rel, "\ue019", "\\varsupsetneqq");
defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq");
defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true);
defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true);
defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true);
defineSymbol(math, ams, rel, "\ue016", "\\nsubseteqq");
defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq");
defineSymbol(math, ams, bin, "\u22b4", "\\unlhd");

@@ -286,3 +287,2 @@ defineSymbol(math, ams, bin, "\u22b5", "\\unrhd");

defineSymbol(math, ams, textord, "\u2141", "\\Game", true);
defineSymbol(math, ams, textord, "\u006b", "\\Bbbk");
defineSymbol(math, ams, textord, "\u2035", "\\backprime");

@@ -289,0 +289,0 @@ defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle");

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc