Skip to content

Commit 73bf96e

Browse files
committed
Merge branch '3.1.3-update'
2 parents 0602206 + 3c3946f commit 73bf96e

21 files changed

+410
-157
lines changed

component/mml2svg

+24-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ var argv = require('yargs')
4747
default: 80 * 16,
4848
describe: 'width of container in pixels'
4949
},
50+
styles: {
51+
boolean: true,
52+
default: true,
53+
describe: 'include css styles for stand-alone image'
54+
},
55+
container: {
56+
boolean: true,
57+
describe: 'include <mjx-container> element'
58+
},
5059
css: {
5160
boolean: true,
5261
describe: 'output the required CSS rather than the HTML itself'
@@ -69,6 +78,19 @@ var argv = require('yargs')
6978
})
7079
.argv;
7180

81+
//
82+
// Minimal CSS needed for stand-alone image
83+
//
84+
const CSS = [
85+
'svg a{fill:blue;stroke:blue}',
86+
'[data-mml-node="merror"]>g{fill:red;stroke:red}',
87+
'[data-mml-node="merror"]>rect[data-background]{fill:yellow;stroke:none}',
88+
'[data-frame],[data-line]{stroke-width:70px;fill:none}',
89+
'.mjx-dashed{stroke-dasharray:140}',
90+
'.mjx-dotted{stroke-linecap:round;stroke-dasharray:0,140}',
91+
'use[data-c]{stroke-width:3px}'
92+
].join('');
93+
7294
//
7395
// Configure MathJax
7496
//
@@ -113,7 +135,8 @@ MathJax.startup.promise.then(() => {
113135
if (argv.css) {
114136
console.log(adaptor.textContent(MathJax.svgStylesheet()));
115137
} else {
116-
console.log(adaptor.outerHTML(node));
138+
let html = (argv.container ? adaptor.outerHTML(node) : adaptor.innerHTML(node));
139+
console.log(argv.styles ? html.replace(/<defs>/, `<defs><style>${CSS}</style>`) : html);
117140
};
118141
});
119142
}).catch(err => console.log(err));

component/tex2svg

+24-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@
2929
//
3030
const PACKAGES = 'base, autoload, require, ams, newcommand';
3131

32+
//
33+
// Minimal CSS needed for stand-alone image
34+
//
35+
const CSS = [
36+
'svg a{fill:blue;stroke:blue}',
37+
'[data-mml-node="merror"]>g{fill:red;stroke:red}',
38+
'[data-mml-node="merror"]>rect[data-background]{fill:yellow;stroke:none}',
39+
'[data-frame],[data-line]{stroke-width:70px;fill:none}',
40+
'.mjx-dashed{stroke-dasharray:140}',
41+
'.mjx-dotted{stroke-linecap:round;stroke-dasharray:0,140}',
42+
'use[data-c]{stroke-width:3px}'
43+
].join('');
44+
3245
//
3346
// Get the command-line arguments
3447
//
@@ -56,6 +69,15 @@ var argv = require('yargs')
5669
default: PACKAGES,
5770
describe: 'the packages to use, e.g. "base, ams"; use "*" to represent the default packages, e.g, "*, bbox"'
5871
},
72+
styles: {
73+
boolean: true,
74+
default: true,
75+
describe: 'include css styles for stand-alone image'
76+
},
77+
container: {
78+
boolean: true,
79+
describe: 'include <mjx-container> element'
80+
},
5981
css: {
6082
boolean: true,
6183
describe: 'output the required CSS rather than the HTML itself'
@@ -125,7 +147,8 @@ MathJax.startup.promise.then(() => {
125147
if (argv.css) {
126148
console.log(adaptor.textContent(MathJax.svgStylesheet()));
127149
} else {
128-
console.log(adaptor.outerHTML(node));
150+
let html = (argv.container ? adaptor.outerHTML(node) : adaptor.innerHTML(node));
151+
console.log(argv.styles ? html.replace(/<defs>/, `<defs><style>${CSS}</style>`) : html);
129152
};
130153
});
131154
}).catch(err => console.log(err));

direct/mml2svg

+55-32
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,57 @@ var argv = require('yargs')
4040
.demand(0).strict()
4141
.usage('$0 [options] "math" > file.html')
4242
.options({
43-
em: {
44-
default: 16,
45-
describe: 'em-size in pixels'
46-
},
47-
ex: {
48-
default: 8,
49-
describe: 'ex-size in pixels'
50-
},
51-
width: {
52-
default: 80 * 16,
53-
describe: 'width of container in pixels'
54-
},
55-
css: {
56-
boolean: true,
57-
describe: 'output the required CSS rather than the SVG itself'
58-
},
59-
fontCache: {
60-
boolean: true,
61-
default: true,
62-
describe: 'whether to use a local font cache or not'
63-
},
64-
assistiveMml: {
65-
boolean: true,
66-
default: false,
67-
describe: 'whether to include assistive MathML output'
68-
}
43+
em: {
44+
default: 16,
45+
describe: 'em-size in pixels'
46+
},
47+
ex: {
48+
default: 8,
49+
describe: 'ex-size in pixels'
50+
},
51+
width: {
52+
default: 80 * 16,
53+
describe: 'width of container in pixels'
54+
},
55+
styles: {
56+
boolean: true,
57+
default: true,
58+
describe: 'include css styles for stand-alone image'
59+
},
60+
container: {
61+
boolean: true,
62+
describe: 'include <mjx-container> element'
63+
},
64+
css: {
65+
boolean: true,
66+
describe: 'output the required CSS rather than the SVG itself'
67+
},
68+
fontCache: {
69+
boolean: true,
70+
default: true,
71+
describe: 'whether to use a local font cache or not'
72+
},
73+
assistiveMml: {
74+
boolean: true,
75+
default: false,
76+
describe: 'whether to include assistive MathML output'
77+
}
6978
})
7079
.argv;
7180

81+
//
82+
// Minimal CSS needed for stand-alone image
83+
//
84+
const CSS = [
85+
'svg a{fill:blue;stroke:blue}',
86+
'[data-mml-node="merror"]>g{fill:red;stroke:red}',
87+
'[data-mml-node="merror"]>rect[data-background]{fill:yellow;stroke:none}',
88+
'[data-frame],[data-line]{stroke-width:70px;fill:none}',
89+
'.mjx-dashed{stroke-dasharray:140}',
90+
'.mjx-dotted{stroke-linecap:round;stroke-dasharray:0,140}',
91+
'use[data-c]{stroke-width:3px}'
92+
].join('');
93+
7294
//
7395
// Create DOM adaptor and register it for HTML documents
7496
//
@@ -87,18 +109,19 @@ const html = mathjax.document('', {InputJax: mml, OutputJax: svg});
87109
// Typeset the math from the command line
88110
//
89111
const node = html.convert(argv._[0] || '', {
90-
display: !argv.inline,
91-
em: argv.em,
92-
ex: argv.ex,
93-
containerWidth: argv.width
112+
display: !argv.inline,
113+
em: argv.em,
114+
ex: argv.ex,
115+
containerWidth: argv.width
94116
});
95117

96118
//
97119
// If the --css option was specified, output the CSS,
98120
// Otherwise, typeset the math and output the HTML
99121
//
100122
if (argv.css) {
101-
console.log(adaptor.textContent(svg.styleSheet(html)));
123+
console.log(adaptor.textContent(svg.styleSheet(html)));
102124
} else {
103-
console.log(adaptor.outerHTML(node));
125+
let html = (argv.container ? adaptor.outerHTML(node) : adaptor.innerHTML(node));
126+
console.log(argv.styles ? html.replace(/<defs>/, `<defs><style>${CSS}</style>`) : html);
104127
}

direct/tex2svg

+63-40
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,69 @@ const {AssistiveMmlHandler} = require('mathjax-full/js/a11y/assistive-mml.js');
3535

3636
const {AllPackages} = require('mathjax-full/js/input/tex/AllPackages.js');
3737

38+
//
39+
// Minimal CSS needed for stand-alone image
40+
//
41+
const CSS = [
42+
'svg a{fill:blue;stroke:blue}',
43+
'[data-mml-node="merror"]>g{fill:red;stroke:red}',
44+
'[data-mml-node="merror"]>rect[data-background]{fill:yellow;stroke:none}',
45+
'[data-frame],[data-line]{stroke-width:70px;fill:none}',
46+
'.mjx-dashed{stroke-dasharray:140}',
47+
'.mjx-dotted{stroke-linecap:round;stroke-dasharray:0,140}',
48+
'use[data-c]{stroke-width:3px}'
49+
].join('');
50+
3851
//
3952
// Get the command-line arguments
4053
//
4154
var argv = require('yargs')
4255
.demand(0).strict()
4356
.usage('$0 [options] "math" > file.svg')
4457
.options({
45-
inline: {
46-
boolean: true,
47-
describe: "process as inline math"
48-
},
49-
em: {
50-
default: 16,
51-
describe: 'em-size in pixels'
52-
},
53-
ex: {
54-
default: 8,
55-
describe: 'ex-size in pixels'
56-
},
57-
width: {
58-
default: 80 * 16,
59-
describe: 'width of container in pixels'
60-
},
61-
packages: {
62-
default: AllPackages.sort().join(', '),
63-
describe: 'the packages to use, e.g. "base, ams"'
64-
},
65-
css: {
66-
boolean: true,
67-
describe: 'output the required CSS rather than the SVG itself'
68-
},
69-
fontCache: {
70-
boolean: true,
71-
default: true,
72-
describe: 'whether to use a local font cache or not'
73-
},
74-
assistiveMml: {
75-
boolean: true,
76-
default: false,
77-
describe: 'whether to include assistive MathML output'
78-
}
58+
inline: {
59+
boolean: true,
60+
describe: "process as inline math"
61+
},
62+
em: {
63+
default: 16,
64+
describe: 'em-size in pixels'
65+
},
66+
ex: {
67+
default: 8,
68+
describe: 'ex-size in pixels'
69+
},
70+
width: {
71+
default: 80 * 16,
72+
describe: 'width of container in pixels'
73+
},
74+
packages: {
75+
default: AllPackages.sort().join(', '),
76+
describe: 'the packages to use, e.g. "base, ams"'
77+
},
78+
styles: {
79+
boolean: true,
80+
default: true,
81+
describe: 'include css styles for stand-alone image'
82+
},
83+
container: {
84+
boolean: true,
85+
describe: 'include <mjx-container> element'
86+
},
87+
css: {
88+
boolean: true,
89+
describe: 'output the required CSS rather than the SVG itself'
90+
},
91+
fontCache: {
92+
boolean: true,
93+
default: true,
94+
describe: 'whether to use a local font cache or not'
95+
},
96+
assistiveMml: {
97+
boolean: true,
98+
default: false,
99+
describe: 'whether to include assistive MathML output'
100+
}
79101
})
80102
.argv;
81103

@@ -97,18 +119,19 @@ const html = mathjax.document('', {InputJax: tex, OutputJax: svg});
97119
// Typeset the math from the command line
98120
//
99121
const node = html.convert(argv._[0] || '', {
100-
display: !argv.inline,
101-
em: argv.em,
102-
ex: argv.ex,
103-
containerWidth: argv.width
122+
display: !argv.inline,
123+
em: argv.em,
124+
ex: argv.ex,
125+
containerWidth: argv.width
104126
});
105127

106128
//
107129
// If the --css option was specified, output the CSS,
108130
// Otherwise, typeset the math and output the HTML
109131
//
110132
if (argv.css) {
111-
console.log(adaptor.textContent(svg.styleSheet(html)));
133+
console.log(adaptor.textContent(svg.styleSheet(html)));
112134
} else {
113-
console.log(adaptor.outerHTML(node));
135+
let html = (argv.container ? adaptor.outerHTML(node) : adaptor.innerHTML(node));
136+
console.log(argv.styles ? html.replace(/<defs>/, `<defs><style>${CSS}</style>`) : html);
114137
}

jsdom/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ npm install --production
6060

6161
(If you wish to rebuild the jsdom adaptor component, then leave off the `--production` so that the developer dependencies will be isntalled.)
6262

63-
The exampk files should be executables that you can run. On non-unix systems, you may need to call
63+
The example files should be executables that you can run. On non-unix systems, you may need to call
6464

6565
``` bash
6666
node -r esm <example-name>

0 commit comments

Comments
 (0)