Skip to content

Commit

Permalink
Merge pull request #361 from mathjax/develop
Browse files Browse the repository at this point in the history
1.2.1 release
  • Loading branch information
pkra committed Sep 26, 2017
2 parents fa4d045 + 6b3b03e commit b1618f8
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 63 deletions.
14 changes: 9 additions & 5 deletions README.md
Expand Up @@ -96,9 +96,11 @@ The `start` method start (and restarts) mathjax-node. This allows reconfiguratio

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

### `typeset(options, callback)`
### `typeset(options[, callback])`

The `typeset` method is the main method of mathjax-node. It expects a configuration object `input` and a `callback`.
The `typeset` method is the main method of mathjax-node. It expects a configuration object `options` and optionally a callback.

If no `callback` is passed, it will return a Promise.

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

Expand Down Expand Up @@ -132,9 +134,9 @@ The following are the default input options.
}
```

### `callback(result, options)`
### `Promise.resolve(result,options)` / `Promise.reject(errors)` / `callback(result, options)`

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

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

Expand Down Expand Up @@ -165,4 +167,6 @@ The `result` object will contain (at most) the following structure:
}
```

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()`).
If the `errors` array is non-empty, the Promise will reject, and be passed the `errors` array.

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()`).
7 changes: 5 additions & 2 deletions lib/main.js
Expand Up @@ -38,7 +38,7 @@ var displayMessages = false; // don't log Message.Set() calls
var displayErrors = true; // show error messages on the console
var undefinedChar = false; // unknown characters are not saved in the error array
var extensions = ''; // no additional extensions used
var fontURL = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/fonts/HTML-CSS'; // location of web fonts for CHTML
var fontURL = ''; // location of web fonts for CHTML

var defaults = {
ex: 6, // ex-size in pixels
Expand Down Expand Up @@ -339,7 +339,10 @@ function ConfigureMathJax() {
delete STYLES[".mjx-chartest .mjx-box"];
delete STYLES[".mjx-test"];
delete STYLES[".mjx-ex-boxtest"];

// fontURL to current MathJax version
if (!fontURL){
fontURL = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' + MathJax.version + '/fonts/HTML-CSS';
}
CHTML.Augment({
webfontDir: fontURL,
//
Expand Down
119 changes: 67 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "mathjax-node",
"version": "1.2.0",
"version": "1.2.1",
"description": "API's for calling MathJax from node.js",
"keywords": [
"MathJax",
Expand Down
7 changes: 4 additions & 3 deletions test/base-config-fonturl.js
@@ -1,5 +1,6 @@
var tape = require('tape');
var mjAPI = require("../lib/main.js");
var mjVersion = require('../package-lock.json').dependencies['mathjax'].version

tape('basic configuration: check fontURL', function (t) {
t.plan(2);
Expand All @@ -10,12 +11,12 @@ tape('basic configuration: check fontURL', function (t) {
format: "TeX",
css: true
}, function (result, data) {
t.ok(result.css.indexOf('https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/fonts/HTML-CSS') > -1, 'Default fontURL');
t.ok(result.css.indexOf('https://cdnjs.cloudflare.com/ajax/libs/mathjax/' + mjVersion + '/fonts/HTML-CSS') > -1, 'Default fontURL');
});
// reconfigure
mjAPI.typeset({
math: ''
}, function(){
}, function () {
mjAPI.config({
fontURL: 'https://example.com'
});
Expand All @@ -28,4 +29,4 @@ tape('basic configuration: check fontURL', function (t) {
}, function (result, data) {
t.ok(result.css.indexOf('https://example.com') > -1, 'Configuring fontURL');
});
});
});

0 comments on commit b1618f8

Please sign in to comment.