-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New: Flag to control xlink prefix on href #2080
Conversation
After some extensive testing it seems that some browsers, in some cases, will not display SVG if the `href` attribute is prefixed with `xlink`, a change that was introduced with SVG 2.0. This is not yet a recognized specification, but the changes in browsers are being enacted nevertheless. On the other hand, some strict SVG 1.1 clients will not render the SVG correctly if it *doesn't* include the `xlink:` prefix. In my testing this included Inkscape. Given that the most likely target for Verovio output is browsers, but still wishing to retain backwards compatibility, this PR changes the default behaviour from producing `xlink:href` to simply `href`. Clients that need the full attribute name can set `--svg-include-xlink` which will insert the xlink prefix on the href attributes. References previous discussions on this topic: #1158, #332
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested with the PDFKit js toolkit used in MEI Viewer?
I've tested it and it seems to work as expected; including or removing Easiest way to test it is to You can control the xlink behaviour by commenting / uncommenting the appropriate option in the test.html source. (It should be obvious). |
Does it has to be independent from option |
Laurent and I had a quick discussion about this, and decided that, since 1) SVG2 isn't official yet, but 2) browsers have started to implement it in piecemeal, that it's better to address the specific problem directly, rather than try to do a full SVG2 update. (Not to mention that there's not really a SVG 2 validator out there yet...) |
For reference, the full issue report is here: elm/svg#31 The issue is that browsers only support |
To retain support for SVG 1.1 by default, the xlink flag is now used to control whether the namespace prefix is removed, rather than added.
OK, after talking it over a bit more with @lpugin we decided to flip the behaviour of the flag; the old behaviour is now the default, and the new behaviour is enabled with a flag. |
std::string hrefAttrib = "href"; | ||
if (m_includeXlink) { | ||
if (!m_removeXlink) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I did it this way to avoid needing to strip characters off the string, and instead prepending to the string by default. This avoids needing to make a new copy of the string, or doing any index-based counting to remove the prefix.
After some extensive testing it seems that some browsers, in some cases, will not display SVG if the
href
attribute is prefixed withxlink
, a change that was introduced with SVG 2.0. This is not yet a recognized specification, but the changes in browsers are being enacted nevertheless.On the other hand, some strict SVG 1.1 clients will not render the SVG correctly if it doesn't include the
xlink:
prefix. In my testing this included Inkscape.Given that the most likely target for Verovio output is browsers, but still wishing to retain backwards compatibility, this PR changes the default behaviour from producing
xlink:href
to simplyhref
. Clients that need the full attribute name can set--svg-include-xlink
which will insert the xlink prefix on the href attributes.References previous discussions on this topic: #1158, #332