Skip to content

Commit bab656f

Browse files
committed
Merge pull request #243 from mathjax/issue241
[mj-single] SVG output: add xlink to href in <image>. Resolves #241
2 parents 83eeaf3 + 4cedb16 commit bab656f

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
@@ -622,7 +622,7 @@ function GetSVG(result) {
622622
//
623623
var svgdata = svg.outerHTML.replace(/><([^/])/g,">\n<$1")
624624
.replace(/(<\/[a-z]*>)(?=<\/)/g,"$1\n")
625-
.replace(/(<use [^>]*)(href=)/g,' $1xlink:$2');
625+
.replace(/(<(?:use|image) [^>]*)(href=)/g,' $1xlink:$2');
626626
//
627627
// The file version includes the xml and DOCTYPE comments
628628
//

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)