From 557e93e505a6bfe86eea9cb0059473cb88b1a8ec Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 17 Apr 2013 09:02:33 -0400 Subject: [PATCH] Allow \color to override link color in SVG output. Resolves issue #427. --- unpacked/jax/output/SVG/config.js | 2 +- unpacked/jax/output/SVG/jax.js | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/unpacked/jax/output/SVG/config.js b/unpacked/jax/output/SVG/config.js index 9c122abfc..3d5bb3272 100644 --- a/unpacked/jax/output/SVG/config.js +++ b/unpacked/jax/output/SVG/config.js @@ -24,7 +24,7 @@ MathJax.OutputJax.SVG = MathJax.OutputJax({ id: "SVG", - version: "2.1.1", + version: "2.1.2", directory: MathJax.OutputJax.directory + "/SVG", extensionDir: MathJax.OutputJax.extensionDir + "/SVG", autoloadDir: MathJax.OutputJax.directory + "/SVG/autoload", diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 3362cfc1d..51b34a772 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -60,7 +60,7 @@ width: "100%" }, - ".MathJax_SVG svg a > g, .MathJax_SVG_Display svg a > g": { + ".mjx-href": { fill: "blue", stroke: "blue" }, @@ -1027,19 +1027,17 @@ // for svg element, put inside the main element var g = svg.element.firstChild; while (g.firstChild) {a.appendChild(g.firstChild)} - g.appendChild(a); + g.appendChild(a); this.SVGaddClass(g,"mjx-href"); + g.removeAttribute("fill"); g.removeAttribute("stroke"); } else { - // if removeable, move contents of to , otherise move element to - if (svg.removeable && svg.element.nodeName === "g") { - while (svg.element.firstChild) {a.appendChild(svg.element.firstChild)} - } else {a.appendChild(svg.element)} - svg.element = a; + this.SVGaddClass(svg.element,"mjx-href"); + a.appendChild(svg.element); svg.element = a; } svg.removeable = false; } if (SVG.config.addMMLclasses) { + this.SVGaddClass(svg.element,"mjx-svg-"+this.type); svg.removeable = false; - svg.element.setAttribute("className","mjx-svg-"+this.type); } var style = this.style; if (style && svg.element) { @@ -1049,6 +1047,10 @@ if (svg.removeable) {svg.removeable = svg.element.style.cssText === ""} } }, + SVGaddClass: function (node,name) { + var classes = node.getAttribute("class"); + node.setAttribute("class",(classes ? classes+" " : "")+name); + }, // // WebKit currently scrolls to the BOTTOM of an svg element if it contains the // target of the link, so implement link by hand, to the containing span element.