Skip to content

Commit 34e87f2

Browse files
committed
PseudoCode.js not bundled with KaTeX
1 parent 2445efd commit 34e87f2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ setup:
66
npm install
77
mkdir -p build
88

9-
# watch the changes to js source code and update the target js code
9+
# Watch the changes to js source code and update the target js code
1010
watch-js: pseudocode.js $(wildcard src/*.js)
11-
./node_modules/.bin/watchify $< --standalone pseudocode -o build/pseudocode.js
11+
./node_modules/.bin/watchify $< --exclude katex --standalone pseudocode -o build/pseudocode.js
1212

1313
clean:
1414
rm -rf build/*
@@ -18,8 +18,11 @@ zip: build/pseudocode-js.tar.gz build/pseudocode-js.zip
1818
lint: pseudocode.js $(wildcard src/*.js)
1919
./node_modules/.bin/jshint $^
2020

21+
# although pseudocode.js depends on katex, pseudocode.js will not be
22+
# bundled with katex, as users are likely to have katex.js loade in a separate
23+
# file by browser
2124
build/pseudocode.js: pseudocode.js $(wildcard src/*.js)
22-
./node_modules/.bin/browserify $< --standalone pseudocode -o $@
25+
./node_modules/.bin/browserify $< --exclude katex --standalone pseudocode -o $@
2326

2427
build/pseudocode.min.js: build/pseudocode.js
2528
./node_modules/.bin/uglifyjs --mangle --beautify beautify=false < $< > $@

src/Renderer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/*
22
* TODO: rename commentSymbol to commentDelimiters
33
* */
4-
var katex = require('katex');
4+
/* katex package may either be defined in a separate js file loaded by browser
5+
* or imported by node.js.
6+
* */
57
var utils = require('./utils');
68

79
/*
@@ -155,6 +157,7 @@ TextEnvironment.prototype.renderToHTML = function() {
155157
this._html.putText(text);
156158
break;
157159
case 'math':
160+
if (!katex) katex = require('katex');
158161
var mathHTML = katex.renderToString(text);
159162
this._html.putSpan(mathHTML);
160163
break;

0 commit comments

Comments
 (0)