Skip to content
This repository was archived by the owner on May 15, 2019. It is now read-only.

Commit c0f8260

Browse files
author
David Flanagan
authored
Revert "Update the <TeX> component to the latest upstream KaTeX"
1 parent cff780f commit c0f8260

File tree

5 files changed

+13
-44
lines changed

5 files changed

+13
-44
lines changed

docs/js/katex.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/katex-a11y.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ var typeHandlers = {
174174
buildRegion(a11yStrings, function(a11yStrings) {
175175
buildA11yStrings(tree.value.base, a11yStrings);
176176
a11yStrings.push("with");
177-
buildA11yStrings(tree.value.label, a11yStrings);
177+
buildA11yStrings(tree.value.accent, a11yStrings);
178178
a11yStrings.push("on top");
179179
});
180180
},
@@ -227,19 +227,12 @@ var typeHandlers = {
227227
});
228228
},
229229

230-
inner: function(tree, a11yStrings) {
231-
buildA11yStrings(tree.value, a11yStrings);
232-
},
230+
// inner
233231

234232
katex: function(tree, a11yStrings) {
235233
a11yStrings.push("KaTeX");
236234
},
237235

238-
kern: function(tree, a11yStrings) {
239-
// No op: we don't attempt to present kerning information
240-
// to the screen reader.
241-
},
242-
243236
leftright: function(tree, a11yStrings) {
244237
buildRegion(a11yStrings, function(a11yStrings) {
245238
buildString(tree.value.left, "open", a11yStrings);
@@ -248,7 +241,7 @@ var typeHandlers = {
248241
});
249242
},
250243

251-
lap: function(tree, a11yStrings) {
244+
llap: function(tree, a11yStrings) {
252245
buildA11yStrings(tree.value.body, a11yStrings);
253246
},
254247

@@ -284,10 +277,6 @@ var typeHandlers = {
284277
buildString(tree.value, "punct", a11yStrings);
285278
},
286279

287-
raisebox: function(tree, a11yStrings) {
288-
buildA11yStrings(tree.value, a11yStrings);
289-
},
290-
291280
rel: function(tree, a11yStrings) {
292281
buildString(tree.value, "rel", a11yStrings);
293282
},
@@ -463,13 +452,8 @@ var flattenStrings = function(a11yStrings, results) {
463452
};
464453

465454
var parseMath = function(text) {
466-
// NOTE: `katex` is a global. We assume it has been imported somehow.
467-
//
468-
// colorIsTextColor is an option added in KaTeX 0.9.0 for backward
469-
// compatibility. It makes \color parse like \textcolor. We use it
470-
// in the KA webapp, and need it here because the tests are written
471-
// assuming it is set.
472-
return katex.__parse(text, { colorIsTextColor: true });
455+
// NOTE: `katex` is a global, should be included using require
456+
return katex.__parse(text);
473457
};
474458

475459
var render = function(text, a11yNode) {

js/tex.jsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ const srOnly = {
7979
const TeX = React.createClass({
8080
propTypes: {
8181
children: React.PropTypes.node,
82-
katexOptions: React.PropTypes.any,
8382
onClick: React.PropTypes.func,
8483
onRender: React.PropTypes.func,
8584
style: React.PropTypes.any,
@@ -89,15 +88,6 @@ const TeX = React.createClass({
8988

9089
getDefaultProps: function() {
9190
return {
92-
katexOptions: {
93-
// There was a breaking change in the behavior of \color{}
94-
// in KaTeX 0.8.0. KA content relies on the old behavior
95-
// so we set this option to retain that old behavior even
96-
// though it is not purely compatible with LaTeX.
97-
// See https://github.com/Khan/KaTeX/blob/master/README.md
98-
// for details on this option.
99-
colorIsTextColor: true
100-
},
10191
// Called after math is rendered or re-rendered
10292
onRender: function() {},
10393
onClick: null,
@@ -188,8 +178,7 @@ const TeX = React.createClass({
188178
let katexHtml = null;
189179
try {
190180
katexHtml = {
191-
__html: katex.renderToString(this.props.children,
192-
this.props.katexOptions),
181+
__html: katex.renderToString(this.props.children),
193182
};
194183
} catch (e) {
195184
/* jshint -W103 */

test/katex-a11y-tex.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454
{
5555
"input": "\\KaTeX",
56-
"output": "K, A, T, E, X"
56+
"output": "KaTeX"
5757
},
5858
{
5959
"input": "ab\\llap{f}cd\\rlap{g}h",
@@ -151,4 +151,4 @@
151151
"input": "4 \\geq 3",
152152
"output": "4, is greater than or equal to, 3"
153153
}
154-
]
154+
]

test/tex-test.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ describe("TeX", () => {
3232
assert(html.indexOf('q') === -1);
3333
});
3434

35-
it("handles \\color{} in the old mathjax-compatible way", () => {
36-
const html = ReactDOMServer.renderToString(
37-
<TeX>{"\\text{\\color{#f00} xyz}"}</TeX>
38-
);
39-
assert(html.indexOf(
40-
'<span class="mord" style="color:#f00;">x</span>') !== -1);
41-
});
42-
4335
describe("MathJax", () => {
4436
beforeEach(function() {
4537
global.document = jsdom.jsdom();

0 commit comments

Comments
 (0)