Skip to content

Commit 364dab7

Browse files
committed
Remove KaTeX from repository
1 parent f9f8792 commit 364dab7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+46
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tex/
22
build/
33
node_modules/
4+
static/katex/
45
npm-debug.log

Makefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
build: lint build/pseudocode.min.js build/pseudocode.min.css
44

5-
setup:
5+
setup: setup-katex
66
npm install
77
mkdir -p build
88
ln -s ../static/fonts build/fonts
9+
ln -s ../static/katex build/katex
10+
11+
setup-katex:
12+
@rm -rf static/katex
13+
cd static && wget https://github.com/Khan/KaTeX/releases/download/v0.2.0/katex.zip && unzip katex.zip
14+
@rm -rf static/katex.zip
915

1016
# Watch the changes to js source code and update the target js code
1117
watch-js: pseudocode.js $(wildcard src/*.js)
@@ -21,18 +27,17 @@ lint: pseudocode.js $(wildcard src/*.js)
2127
./node_modules/.bin/jshint $^
2228

2329
build/pseudocode.js: pseudocode.js $(wildcard src/*.js)
24-
./node_modules/.bin/browserify $< --standalone pseudocode -o $@
30+
./node_modules/.bin/browserify --exclude katex $< --standalone pseudocode -o $@
2531

2632
build/pseudocode.min.js: build/pseudocode.js
2733
./node_modules/.bin/uglifyjs --mangle --beautify beautify=false < $< > $@
2834

35+
build/pseudocode.css: static/pseudocode.css
36+
cp static/pseudocode.css build/pseudocode.css
37+
2938
build/pseudocode.min.css: build/pseudocode.css
3039
./node_modules/.bin/cleancss -o $@ $<
3140

32-
build/pseudocode.css: static/pseudocode.css static/katex.min.css
33-
cp static/katex.min.css build/pseudocode.css
34-
cat static/pseudocode.css >> build/pseudocode.css
35-
3641
build/pseudocode: build/pseudocode.min.js build/pseudocode.min.css README.md
3742
mkdir -p build/pseudocode
3843
cp -r $^ build/pseudocode

src/Parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ Parser.prototype._parseAtom = function() {
461461
if (tokenText === null) continue;
462462

463463
var anyWhitespace = this._lexer.get().whitespace;
464-
return new AtomNode(atomType, tokenText.toLowerCase(), anyWhitespace);
464+
if (atomType !== 'ordinary') tokenText = tokenText.toLowerCase();
465+
return new AtomNode(atomType, tokenText, anyWhitespace);
465466
}
466467
return null;
467468
};

src/Renderer.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
22
* */
3-
var katex = require('katex');
43
var utils = require('./utils');
54

65
/*
@@ -52,8 +51,8 @@ TextStyle.prototype._fontCommandTable = {
5251
// font-family
5352
normalfont: { 'font-family': 'KaTeX_Main'},
5453
rmfamily: { 'font-family': 'KaTeX_Main'},
55-
sffamily: { 'font-family': 'KaTeX_SansSerif'},
56-
ttfamily: { 'font-family': 'KaTeX_Typewriter'},
54+
sffamily: { 'font-family': 'KaTeX_SansSerif_Replace'},
55+
ttfamily: { 'font-family': 'KaTeX_Typewriter_Replace'},
5756
// weight
5857
bfseries: { 'font-weight': 'bold'},
5958
mdseries: { 'font-weight': 'medium'},
@@ -67,8 +66,8 @@ TextStyle.prototype._fontCommandTable = {
6766
// font-family
6867
textnormal: { 'font-family': 'KaTeX_Main'},
6968
textrm: { 'font-family': 'KaTeX_Main'},
70-
textsf: { 'font-family': 'KaTeX_SansSerif'},
71-
texttt: { 'font-family': 'KaTeX_Typewriter'},
69+
textsf: { 'font-family': 'KaTeX_SansSerif_Replace'},
70+
texttt: { 'font-family': 'KaTeX_Typewriter_Replace'},
7271
// weight
7372
textbf: { 'font-weight': 'bold'},
7473
textmd: { 'font-weight': 'medium'},
@@ -162,6 +161,10 @@ TextEnvironment.prototype.renderToHTML = function() {
162161
this._html.putText(text);
163162
break;
164163
case 'math':
164+
if (!katex) {
165+
try { katex = require('katex'); }
166+
catch(e) { throw 'katex is required to render math'; }
167+
}
165168
var mathHTML = katex.renderToString(text);
166169
this._html.putSpan(mathHTML);
167170
break;

static/fonts/KaTeX_AMS-Regular.eot

-59.3 KB
Binary file not shown.

static/fonts/KaTeX_AMS-Regular.ttf

-59.1 KB
Binary file not shown.
-34.1 KB
Binary file not shown.
-27.9 KB
Binary file not shown.

static/fonts/KaTeX_Main-Bold.eot

-48 KB
Binary file not shown.

static/fonts/KaTeX_Main-Bold.ttf

-47.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)