Skip to content

Commit 728ccab

Browse files
committed
mj-single] SVG output: add xlink to href in <image>
Fixes #241
1 parent 3eaeb2a commit 728ccab

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/mj-single.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ function GetSVG(result) {
627627
//
628628
var svgdata = svg.outerHTML.replace(/><([^/])/g,">\n<$1")
629629
.replace(/(<\/[a-z]*>)(?=<\/)/g,"$1\n")
630-
.replace(/(<use [^>]*)(href=)/g,' $1xlink:$2');
630+
.replace(/(<(?:use|image) [^>]*)(href=)/g,' $1xlink:$2');
631631
//
632632
// The file version includes the xml and DOCTYPE comments
633633
//

test/issue241.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var tape = require('tape');
2+
var mjAPI = require("../lib/mj-single.js");
3+
var jsdom = require('jsdom').jsdom;
4+
5+
tape('SVG output: add xlink to href in <image>', function(t) {
6+
t.plan(1);
7+
mjAPI.start();
8+
var mml = '<math><mglyph src="equation.svg" width="319pt" height="14pt"></mglyph></math>';
9+
var expected = /xlink:href/;
10+
11+
mjAPI.typeset({
12+
math: mml,
13+
format: "MathML",
14+
svg: true
15+
}, function(data) {
16+
t.ok(data.svg.match(expected));
17+
});
18+
});

0 commit comments

Comments
 (0)