Skip to content

Commit 2ce5fa9

Browse files
authored
Merge pull request #356 from mathjax/355
Fix fontURL issues
2 parents d4fe53a + 0ec6e2c commit 2ce5fa9

File tree

3 files changed

+76
-57
lines changed

3 files changed

+76
-57
lines changed

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.

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)