Skip to content

clip-path misinterpreted by some programs after export #5685

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

Closed
alexcjohnson opened this issue May 26, 2021 · 1 comment · Fixed by #5686
Closed

clip-path misinterpreted by some programs after export #5685

alexcjohnson opened this issue May 26, 2021 · 1 comment · Fixed by #5686
Labels
bug something broken

Comments

@alexcjohnson
Copy link
Collaborator

alexcjohnson commented May 26, 2021

We construct attributes like clip-path="url('#clip4e1647xyplot')" which normally works fine on its own, but for some reason recent versions of MS Word convert this to a broken reference clip-path="url(##clip4e1647xyplot)" (note the double ##). If instead we omit the inner quotes clip-path="url(#clip4e1647xyplot)" Word appears to not mess with it, and it works fine.

We’ll have to do some testing to see if we can uniformly remove those extra quotes, especially in the presence of <base> tags (most commonly added by Angular) which force us to include the full page URL in the reference, not just the hash. But most documentation of the clip-path attribute does not include these quotes so hopefully it will be fine.

The fix is on this line:

return 'url(\'' + baseUrl + '#' + localId + '\')';

Which, if it works with a baseUrl, could just be simplified to:

return 'url(' + baseUrl + '#' + localId)';

But if that has any problems we could remove the quotes only when baseUrl is falsy ('')

@alexcjohnson alexcjohnson added the bug something broken label May 26, 2021
@alexcjohnson
Copy link
Collaborator Author

One potential pitfall: URLs with parens in them, for example: https://en.wikipedia.org/wiki/Textile_(markup_language) - makes me think we should keep the quotes when there is a baseUrl.

For completeness, note that the <base> tag is interrogate here:

var base = d3.select('base');
gd._context._baseUrl = base.size() && base.attr('href') ?
window.location.href.split('#')[0] :
'';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant