Skip to content

Commit 993f531

Browse files
committed
Merge branch 'develop' into chtml
2 parents e6b97c2 + c41a269 commit 993f531

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MathJax-node [![Build Status](https://travis-ci.org/mathjax/MathJax-node.svg?branch=develop)](https://travis-ci.org/mathjax/MathJax-node)
1+
# mathjax-node [![Build Status](https://travis-ci.org/mathjax/MathJax-node.svg?branch=develop)](https://travis-ci.org/mathjax/MathJax-node)
22

33
This repository contains files that provide APIs to call MathJax from
44
node.js programs. There is an API for converting individual math
@@ -14,9 +14,9 @@ of calling the MathJax API.
1414

1515
Use
1616

17-
npm install MathJax-node
17+
npm install mathjax-node
1818

19-
to install MathJax-node and its dependencies.
19+
to install mathjax-node and its dependencies.
2020

2121
These API's can produce PNG images, but that requires the
2222
[Batik](http://xmlgraphics.apache.org/batik/download.html) library. It
@@ -25,7 +25,7 @@ directory for more details.
2525

2626
# Getting started
2727

28-
MahJax-node provides two libraries, `lib/mj-single.js` and `lib/mj-page.js`. Below are two very minimal examples -- be sure to check out the examples in `./bin/` for more advanced configurations.
28+
mathjax-node provides two libraries, `lib/mj-single.js` and `lib/mj-page.js`. Below are two very minimal examples -- be sure to check out the examples in `./bin/` for more advanced configurations.
2929

3030
* `lib/mj-single.js` is optimized for processing single equations.
3131

bin/page2mml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function processHTML(html,callback) {
104104
xmlns:xmlns
105105
}, function (result) {
106106
document.body.innerHTML = result.html;
107-
var HTML = "<!DOCTYPE html>\n"+document.documentElement.outerHTML.replace(/^(\n|\s)*/,"");
107+
var HTML = "<!DOCTYPE html>\n"+document.documentElement.outerHTML.replace(/^(\n|\s)*/,"")+"\n";
108108
callback(HTML);
109109
});
110110
}

lib/mj-page.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var MathJax; // filled in once MathJax is loaded
8787
var serverState = STATE.STOPPED; // nothing loaded yet
8888
var timer; // used to reset MathJax if it runs too long
8989

90-
var tmpfile = os.tmpdir() + "/mj-single-svg"; // file name prefix to use for temp files
90+
var tmpfile = os.tmpdir() + "/mj-single-svg" + process.pid; // file name prefix to use for temp files
9191

9292
var document, window, content, html; // the DOM elements
9393

@@ -213,6 +213,9 @@ function ConfigureMathJax() {
213213
MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
214214
AddError("TeX parse error",message[1]);
215215
});
216+
MathJax.Hub.Register.MessageHook("file load error",function (message) {
217+
AddError("File load error",message[1]);
218+
});
216219

217220
//
218221
// Set the delays to 0 (we don't need to update the screen)
@@ -650,7 +653,7 @@ function ConfigureTypeset() {
650653
// Reset the MathJax counters for things
651654
//
652655
SVG.resetGlyphs(true);
653-
TEX.resetEquationNumbers();
656+
if (TEX.resetEquationNUmbers) TEX.resetEquationNumbers();
654657
MML.SUPER.ID = 0;
655658

656659
//
@@ -790,7 +793,8 @@ function AdjustMML() {
790793
for (var i = nodes.length-1; i >= 0; i--) {
791794
var math = nodes[i].getElementsByTagName("math")[0]
792795
nodes[i].parentNode.replaceChild(math,nodes[i]);
793-
if (data.speakText) math.setAttribute("alttext",speech.processExpression(math.outerHTML));
796+
var alttext = speech.processExpression(math.outerHTML.replace(/&nbsp;/g,"\u00A0"));
797+
if (data.speakText) math.setAttribute("alttext",alttext);
794798
}
795799
}
796800
}

lib/mj-single.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var MathJaxConfig; // configuration for when starting MathJax
8787
var MathJax; // filled in once MathJax is loaded
8888
var serverState = STATE.STOPPED; // nothing loaded yet
8989
var timer; // used to reset MathJax if it runs too long
90-
var tmpfile = os.tmpdir() + "/mj-single-svg"; // file name prefix to use for temp files
90+
var tmpfile = os.tmpdir() + "/mj-single-svg" + process.pid; // file name prefix to use for temp files
9191

9292
var document, window, content, html; // the DOM elements
9393

@@ -215,6 +215,9 @@ function ConfigureMathJax() {
215215
MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
216216
AddError("TeX parse error: "+message[1]);
217217
});
218+
MathJax.Hub.Register.MessageHook("file load error",function (message) {
219+
AddError("File load error: "+message[1]);
220+
});
218221

219222
//
220223
// Set the delays to 0 (we don't need to update the screen)
@@ -535,6 +538,7 @@ function GetSpeech(result) {
535538
var jax = MathJax.Hub.getAllJax()[0];
536539
jax.root.alttext = result.speakText;
537540
if (jax.root.attrNames) {jax.root.attrNames.push("alttext")}
541+
result.mml = jax.root.toMathML('',jax);
538542
} else {
539543
delete result.mml;
540544
}
@@ -734,7 +738,7 @@ function GetState(state) {
734738
state.defs = HTML.Element("defs");
735739
state.n = 0;
736740
}
737-
TEX.resetEquationNumbers();
741+
if (TEX.resetEquationNumbers) TEX.resetEquationNumbers();
738742
MML.SUPER.ID = ID = 0;
739743
}
740744
}

package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "MathJax-node",
3-
"version": "0.3.0",
2+
"name": "mathjax-node",
3+
"version": "0.4.0",
44
"description": "API's for calling MathJax from node.js",
55
"keywords": [
66
"MathJax",
@@ -16,18 +16,15 @@
1616
"bugs": {
1717
"url": "http://github.com/mathjax/MathJax-node/issues"
1818
},
19-
"license": {
20-
"type": "Apache-2.0",
21-
"url": "http://github.com/mathjax/MathJax-node/blob/master/LICENSE"
22-
},
19+
"license": "Apache-2.0",
2320
"repository": {
2421
"type": "git",
2522
"url": "git://github.com/mathjax/MathJax-node.git"
2623
},
2724
"dependencies": {
28-
"jsdom": "*",
25+
"jsdom": "^6.0.0",
2926
"speech-rule-engine": "*",
30-
"yargs": "*",
27+
"yargs": "^3.0.0",
3128
"MathJax": "https://github.com/mathjax/MathJax/tarball/mathjax-node-2.5.1"
3229
},
3330
"scripts": {

0 commit comments

Comments
 (0)