Skip to content

Commit d81c945

Browse files
committed
Add a new command bin/mml2mml to produce normalized MathML, possibly with a speech string.
1 parent 643aade commit d81c945

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

bin/mml2mml

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

0 commit comments

Comments
 (0)