From 557e93e505a6bfe86eea9cb0059473cb88b1a8ec Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 17 Apr 2013 09:02:33 -0400 Subject: [PATCH 1/3] 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. From 486cd40424abbb97e1a942b3fc2ae9c4e99dc64c Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 17 Apr 2013 09:05:24 -0400 Subject: [PATCH 2/3] Make href class specific to SVG (in case we need to have one for other output jax) --- unpacked/jax/output/SVG/jax.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 51b34a772..01f5dc9df 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -60,7 +60,7 @@ width: "100%" }, - ".mjx-href": { + ".mjx-svg-href": { fill: "blue", stroke: "blue" }, @@ -1027,10 +1027,10 @@ // for svg element, put inside the main element var g = svg.element.firstChild; while (g.firstChild) {a.appendChild(g.firstChild)} - g.appendChild(a); this.SVGaddClass(g,"mjx-href"); + g.appendChild(a); this.SVGaddClass(g,"mjx-svg-href"); g.removeAttribute("fill"); g.removeAttribute("stroke"); } else { - this.SVGaddClass(svg.element,"mjx-href"); + this.SVGaddClass(svg.element,"mjx-svg-href"); a.appendChild(svg.element); svg.element = a; } svg.removeable = false; From 9e65b9ce749f5d37ca73fefddbe4515e6cedbdbf Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Fri, 19 Apr 2013 08:08:59 -0400 Subject: [PATCH 3/3] Move mjx-svg-href class to rather than its child. Resolves issue #427. --- unpacked/jax/output/SVG/jax.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 01f5dc9df..1e8cf94f7 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -1018,7 +1018,7 @@ // FIXME: if an element has an id, its zoomed copy will have the same ID if (this.id) {svg.removeable = false; SVG.Element(svg.element,{"id":this.id})} if (this.href) { - var a = SVG.Element("a"); + var a = SVG.Element("a",{"class":"mjx-svg-href"}); a.setAttributeNS(XLINKNS,"href",this.href); a.onclick = this.SVGlink; SVG.addElement(a,"rect",{width:svg.w, height:svg.h+svg.d, y:-svg.d, @@ -1027,10 +1027,8 @@ // for svg element, put inside the main element var g = svg.element.firstChild; while (g.firstChild) {a.appendChild(g.firstChild)} - g.appendChild(a); this.SVGaddClass(g,"mjx-svg-href"); - g.removeAttribute("fill"); g.removeAttribute("stroke"); + g.appendChild(a); } else { - this.SVGaddClass(svg.element,"mjx-svg-href"); a.appendChild(svg.element); svg.element = a; } svg.removeable = false;