svgtex icon indicating copy to clipboard operation
svgtex copied to clipboard

repeated xlink:href on 'use' elements

Open tiarno opened this issue 10 years ago • 7 comments

The SVG result contains 'use' elements that have duplicate xlink:href elements. That is, using two terminal windows (this is win7)

  1. phantomjs.exe main.js
  2. wget http://localhost:16000/?q=x+e -O test.svg

The resulting SVG has 'use' elements like this:

<use xlink:href="#MJMATHI-78" x="0" y="0" xlink:href="#MJMATHI-78">

What I did to fix it was to replace line 73 in engine.js, which inserts the attribute, with this conditional block:

  if (uses[k]["href"] === undefined) {
      uses[k].setAttribute("xlink:href", id);
  }

tiarno avatar Feb 10 '15 16:02 tiarno

Hello tiarno, thanks for the heads up. Would you mind sending me a pull request for this change, so I can just approve it?

agrbin avatar Feb 14 '15 17:02 agrbin

hi agrbin, I will send a pull request soon; my fork has some issues right now but I'll be back in touch soon, and it will have just the one fix. thx.

tiarno avatar Feb 16 '15 16:02 tiarno

This "fix" has caused a major regression and rendered svgtex completely useless on GNU/Linux (Xubuntu LTS 14.04). On all my browsers (Firefox, Chrome, etc.), I now only see one or more horizontal lines instead of any formula. Reverting https://github.com/agrbin/svgtex/commit/baacbe9c990fd8d73f357e849acae92c4ed8b23e fixes the problem.

stroobandt avatar May 15 '15 22:05 stroobandt

Sorry for the trouble and glad you could revert. I will follow up after some research. I was validating the elements according to http://www.w3.org/TR/SVG11/struct.html#UseElementHrefAttribute which worked on my windows box. It doesn't make sense to me for an xlink to have multiple hrefs; once I have a fix that works for linux as well I'll repost for consideration.

tiarno avatar May 15 '15 23:05 tiarno

As far as I can tell, it is an error to have multiple hrefs. http://www.w3.org/TR/xlink11/ With @serge-stroobandt's results, my guess is that the code I submitted creates another error while fixing the multiple href problem.

tiarno avatar May 15 '15 23:05 tiarno

@tiarno You are welcome. I have no problem at all with sticking to standards, but it has to work. Unfortunately, I am not an expert at all on SVG nor xlink. So, I am afraid I cannot really tell you what is going wrong, apart from not seeing any formulas at all in my browsers, only a few horizontal lines despite a succesful svgtex run. Do you have capability for testing on Linux?

stroobandt avatar May 16 '15 09:05 stroobandt

@serge-stroobandt : no argument here--working is the first thing the code has to do regardless of validation. I cannot test on Linux, but I can on Mac and Windows. I will play around with it and make sure it will work on all platforms before another pull request. Sorry for the trouble.

tiarno avatar May 16 '15 12:05 tiarno