Skip to content

Commit b1618f8

Browse files
authored
Merge pull request #361 from mathjax/develop
1.2.1 release
2 parents fa4d045 + 6b3b03e commit b1618f8

File tree

5 files changed

+86
-63
lines changed

5 files changed

+86
-63
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ The `start` method start (and restarts) mathjax-node. This allows reconfiguratio
9696

9797
**Note.** This is done automatically when `typeset` is first called (see below).
9898

99-
### `typeset(options, callback)`
99+
### `typeset(options[, callback])`
100100

101-
The `typeset` method is the main method of mathjax-node. It expects a configuration object `input` and a `callback`.
101+
The `typeset` method is the main method of mathjax-node. It expects a configuration object `options` and optionally a callback.
102+
103+
If no `callback` is passed, it will return a Promise.
102104

103105
Once called, `typeset` can be called repeatedly and will optionally store information across calls (see `state` below).
104106

@@ -132,9 +134,9 @@ The following are the default input options.
132134
}
133135
```
134136

135-
### `callback(result, options)`
137+
### `Promise.resolve(result,options)` / `Promise.reject(errors)` / `callback(result, options)`
136138

137-
mathjax-node returns two objects to the `callback`: a `result` object as well as the original input `options`.
139+
mathjax-node returns two objects to `Promise.resolve` or `callback`: a `result` object and the original input `options`.
138140

139141
The `result` object will contain (at most) the following structure:
140142

@@ -165,4 +167,6 @@ The `result` object will contain (at most) the following structure:
165167
}
166168
```
167169

168-
The `options` contains the configuration object passed to `typeset`; this can be useful for passing other data along or for identifying which `typeset()` call is associated with this `callback` call (in case you use the same `callback` function for more than one `typeset()`).
170+
If the `errors` array is non-empty, the Promise will reject, and be passed the `errors` array.
171+
172+
The `options` contains the configuration object passed to `typeset`; this can be useful for passing other data along or for identifying which `typeset()` call is associated with this (`callback`) call (in case you use the same `callback` function for more than one `typeset()`).

lib/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var displayMessages = false; // don't log Message.Set() calls
3838
var displayErrors = true; // show error messages on the console
3939
var undefinedChar = false; // unknown characters are not saved in the error array
4040
var extensions = ''; // no additional extensions used
41-
var fontURL = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/fonts/HTML-CSS'; // location of web fonts for CHTML
41+
var fontURL = ''; // location of web fonts for CHTML
4242

4343
var defaults = {
4444
ex: 6, // ex-size in pixels
@@ -339,7 +339,10 @@ function ConfigureMathJax() {
339339
delete STYLES[".mjx-chartest .mjx-box"];
340340
delete STYLES[".mjx-test"];
341341
delete STYLES[".mjx-ex-boxtest"];
342-
342+
// fontURL to current MathJax version
343+
if (!fontURL){
344+
fontURL = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' + MathJax.version + '/fonts/HTML-CSS';
345+
}
343346
CHTML.Augment({
344347
webfontDir: fontURL,
345348
//

package-lock.json

Lines changed: 67 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mathjax-node",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "API's for calling MathJax from node.js",
55
"keywords": [
66
"MathJax",

test/base-config-fonturl.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var tape = require('tape');
22
var mjAPI = require("../lib/main.js");
3+
var mjVersion = require('../package-lock.json').dependencies['mathjax'].version
34

45
tape('basic configuration: check fontURL', function (t) {
56
t.plan(2);
@@ -10,12 +11,12 @@ tape('basic configuration: check fontURL', function (t) {
1011
format: "TeX",
1112
css: true
1213
}, function (result, data) {
13-
t.ok(result.css.indexOf('https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/fonts/HTML-CSS') > -1, 'Default fontURL');
14+
t.ok(result.css.indexOf('https://cdnjs.cloudflare.com/ajax/libs/mathjax/' + mjVersion + '/fonts/HTML-CSS') > -1, 'Default fontURL');
1415
});
1516
// reconfigure
1617
mjAPI.typeset({
1718
math: ''
18-
}, function(){
19+
}, function () {
1920
mjAPI.config({
2021
fontURL: 'https://example.com'
2122
});
@@ -28,4 +29,4 @@ tape('basic configuration: check fontURL', function (t) {
2829
}, function (result, data) {
2930
t.ok(result.css.indexOf('https://example.com') > -1, 'Configuring fontURL');
3031
});
31-
});
32+
});

0 commit comments

Comments
 (0)