Skip to content

Commit 06dba23

Browse files
committed
initial commit
1 parent d87e29d commit 06dba23

File tree

16 files changed

+1111
-0
lines changed

16 files changed

+1111
-0
lines changed

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: node_js
2+
node_js:
3+
- '4'
4+
- '5'
5+
- '6'
6+
- stable
7+
sudo: false
8+
script:
9+
- npm install
10+
- npm test
11+
deploy:
12+
provider: npm
13+
14+
api_key:
15+
secure: Fd/yFRRrLDjleB7QnV/Juncg7dJP193IYOWZaJJFohSfPC3TylhJjUb2bD2fcBUbzM9bLPvhz+XJbWS2YXRGzCWABtyjpZTjO9oEkYBmEuNdVnD9b1j+BCWEEyXfBGF0/WBePRtn8XWQLTPbEJXP9Z2HKOUJJlq4cjTLZ7MHZLw=
16+
on:
17+
tags: true

bin/am2html

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#! /usr/bin/env node
2+
3+
/*************************************************************************
4+
*
5+
* am2html
6+
*
7+
* Uses MathJax to convert an AsciiMath string to an HTML string.
8+
*
9+
* ----------------------------------------------------------------------
10+
*
11+
* Copyright (c) 2016 The MathJax Consortium
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*/
25+
26+
var mjAPI = require("mathjax-node");
27+
28+
var argv = require("yargs")
29+
.demand(1).strict()
30+
.usage("Usage: am2html [options] 'math' > file.html",{
31+
speech: {
32+
boolean: true,
33+
default: true,
34+
describe: "include speech text"
35+
},
36+
linebreaks: {
37+
boolean: true,
38+
describe: "perform automatic line-breaking"
39+
},
40+
ex: {
41+
default: 6,
42+
describe: "ex-size in pixels"
43+
},
44+
width: {
45+
default: 100,
46+
describe: "width of container in ex"
47+
},
48+
extensions: {
49+
default: "",
50+
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
51+
},
52+
css: {
53+
boolean: true,
54+
describe: "output the required CSS rather than the HTML itself"
55+
},
56+
fontURL: {
57+
default: "https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS",
58+
describe: "the URL to use for web fonts"
59+
}
60+
})
61+
.argv;
62+
63+
mjAPI.config({extensions: argv.extensions, fontURL: argv.fontURL});
64+
mjAPI.start();
65+
66+
mjAPI.typeset({
67+
math: argv._[0],
68+
format: "AsciiMath",
69+
html:true, css: argv.css,
70+
speakText: argv.speech,
71+
ex: argv.ex, width: argv.width,
72+
linebreaks: argv.linebreaks
73+
}, function (data) {
74+
if (!data.errors) {console.log(argv.css ? data.css : data.html)}
75+
});

bin/am2htmlcss

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#! /usr/bin/env node
2+
3+
/*************************************************************************
4+
*
5+
* am2htmlcss
6+
*
7+
* Uses MathJax to convert an AsciiMath string to an HTML page.
8+
*
9+
* ----------------------------------------------------------------------
10+
*
11+
* Copyright (c) 2016 The MathJax Consortium
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*/
25+
26+
var mjAPI = require("mathjax-node");
27+
28+
var argv = require("yargs")
29+
.demand(1).strict()
30+
.usage("Usage: am2htmlcss [options] 'math' > file.html",{
31+
speech: {
32+
boolean: true,
33+
default: true,
34+
describe: "include speech text"
35+
},
36+
linebreaks: {
37+
boolean: true,
38+
describe: "perform automatic line-breaking"
39+
},
40+
ex: {
41+
default: 6,
42+
describe: "ex-size in pixels"
43+
},
44+
width: {
45+
default: 100,
46+
describe: "width of container in ex"
47+
},
48+
extensions: {
49+
default: "",
50+
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
51+
},
52+
fontURL: {
53+
default: "https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS",
54+
describe: "the URL to use for web fonts"
55+
}
56+
})
57+
.argv;
58+
59+
mjAPI.config({extensions: argv.extensions, fontURL: argv.fontURL});
60+
mjAPI.start();
61+
62+
mjAPI.typeset({
63+
math: argv._[0],
64+
format: "AsciiMath",
65+
html:true, css: true,
66+
speakText: argv.speech,
67+
ex: argv.ex, width: argv.width,
68+
linebreaks: argv.linebreaks
69+
}, function (data) {
70+
if (!data.errors) {
71+
console.log("<!DOCTYPE html>\n<html>\n<head>");
72+
console.log('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />');
73+
console.log("<title></title>\n<style>");
74+
console.log(data.css);
75+
console.log("</style>\n</head>\n<body>");
76+
console.log(data.html);
77+
console.log("</body>\n</html>");
78+
}
79+
});

bin/am2mml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#! /usr/bin/env node
2+
3+
/*************************************************************************
4+
*
5+
* am2mml
6+
*
7+
* Uses MathJax to convert an AsciiMath string to a MathML string.
8+
*
9+
* ----------------------------------------------------------------------
10+
*
11+
* Copyright (c) 2014 The MathJax Consortium
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*/
25+
26+
var mjAPI = require("mathjax-node");
27+
28+
var argv = require("yargs")
29+
.demand(1).strict()
30+
.usage("Usage: am2mml [options] 'math' > file.mml",{
31+
speech: {
32+
boolean: true,
33+
default: true,
34+
describe: "include speech text"
35+
},
36+
semantics: {
37+
boolean: true,
38+
describe: "add AsciiMath code in <semantics> tag"
39+
},
40+
extensions: {
41+
default: "",
42+
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
43+
}
44+
})
45+
.argv;
46+
47+
mjAPI.config({
48+
MathJax: {
49+
menuSettings: {
50+
semantics: argv.semantics
51+
}
52+
},
53+
extensions: argv.extensions
54+
});
55+
mjAPI.start();
56+
57+
mjAPI.typeset({
58+
math: argv._[0],
59+
format: "AsciiMath", mml:true,
60+
speakText: argv.speech
61+
}, function (data) {
62+
if (!data.errors) {console.log(data.mml)}
63+
});

bin/am2svg

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#! /usr/bin/env node
2+
3+
/*************************************************************************
4+
*
5+
* am2svg
6+
*
7+
* Uses MathJax to convert an AsciiMath string to an SVG image
8+
*
9+
* ----------------------------------------------------------------------
10+
*
11+
* Copyright (c) 2014 The MathJax Consortium
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*/
25+
26+
var mjAPI = require("mathjax-node");
27+
28+
var argv = require("yargs")
29+
.demand(1).strict()
30+
.usage("Usage: am2svg [options] 'math' > file.svg",{
31+
linebreaks: {
32+
boolean: true,
33+
default: true,
34+
describe: "perform automatic line-breaking"
35+
},
36+
speech: {
37+
boolean: true,
38+
describe: "include speech text"
39+
},
40+
font: {
41+
default: "TeX",
42+
describe: "web font to use"
43+
},
44+
ex: {
45+
default: 6,
46+
describe: "ex-size in pixels"
47+
},
48+
width: {
49+
default: 100,
50+
describe: "width of container in ex"
51+
},
52+
extensions: {
53+
default: "",
54+
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
55+
}
56+
})
57+
.argv;
58+
59+
if (argv.font === "STIX") argv.font = "STIX-Web";
60+
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
61+
mjAPI.start();
62+
63+
mjAPI.typeset({
64+
math: argv._[0],
65+
format: "AsciiMath",
66+
svg:true,
67+
speakText: argv.speech,
68+
ex: argv.ex, width: argv.width,
69+
linebreaks: argv.linebreaks
70+
}, function (data) {
71+
if (!data.errors) {console.log(data.svg)}
72+
});

bin/mml2html

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#! /usr/bin/env node
2+
3+
/*************************************************************************
4+
*
5+
* mml2html
6+
*
7+
* Uses MathJax to convert a MathML string to an HTML string.
8+
*
9+
* ----------------------------------------------------------------------
10+
*
11+
* Copyright (c) 2016 The MathJax Consortium
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*/
25+
26+
var mjAPI = require("mathjax-node");
27+
28+
var argv = require("yargs")
29+
.demand(1).strict()
30+
.usage("Usage: mml2html [options] 'math' > file.html",{
31+
speech: {
32+
boolean: true,
33+
default: true,
34+
describe: "include speech text"
35+
},
36+
linebreaks: {
37+
boolean: true,
38+
describe: "perform automatic line-breaking"
39+
},
40+
ex: {
41+
default: 6,
42+
describe: "ex-size in pixels"
43+
},
44+
width: {
45+
default: 100,
46+
describe: "width of container in ex"
47+
},
48+
extensions: {
49+
default: "",
50+
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
51+
},
52+
css: {
53+
boolean: true,
54+
describe: "output the required CSS rather than the HTML itself"
55+
},
56+
fontURL: {
57+
default: "https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS",
58+
describe: "the URL to use for web fonts"
59+
}
60+
})
61+
.argv;
62+
63+
mjAPI.config({extensions: argv.extensions});
64+
mjAPI.start();
65+
66+
mjAPI.typeset({
67+
math: argv._[0],
68+
format: "MathML",
69+
html:true, css: argv.css,
70+
speakText: argv.speech,
71+
ex: argv.ex, width: argv.width,
72+
linebreaks: argv.linebreaks
73+
}, function (data) {
74+
if (!data.errors) {console.log(argv.css ? data.css : data.html)}
75+
});

0 commit comments

Comments
 (0)