Skip to content

Commit 2045a3f

Browse files
authored
Merge pull request #269 from mathjax/issue248
[main] GetSemantic: add string conversion
2 parents 24a5683 + 6e81191 commit 2045a3f

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

lib/main.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,8 @@ function GetSpeech(result) {
549549
function GetSemantic(result) {
550550
if (!data.semantic) return;
551551
result.streeJson = speech.toJson(result.mml);
552-
result.streeXml = data.minSTree ?
553-
speech.toSemantic(result.mml) :
554-
speech.pprintXML(speech.toSemantic(result.mml));
552+
var xml = speech.toSemantic(result.mml).toString();
553+
result.streeXml = data.minSTree ? xml : speech.pprintXML(xml);
555554
}
556555

557556
//

test/sre-semantictree.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var tape = require('tape');
2+
var mjAPI = require("../lib/main.js");
3+
4+
tape('semanticTree: basic test', function(t) {
5+
t.plan(2);
6+
7+
var tex = 'a+b=c';
8+
mjAPI.start();
9+
10+
mjAPI.typeset({
11+
math: tex,
12+
format: "TeX",
13+
mml: true,
14+
speakText: true,
15+
semantic: true
16+
}, function(data) {
17+
t.ok(data.streeJson, 'semantic tree JSON');
18+
t.ok(data.streeXml, 'semantic tree XML');
19+
});
20+
});

0 commit comments

Comments
 (0)