MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

Clickable SVG directive/bypass

Open karl-mohring opened this issue 4 years ago • 5 comments

I'm trying to find a nice way of embedding links into SVG objects in place of a text TOC/hyperlinks between pages. The problem is that the links are stripped out during parsing when included as an image, yet the links remain when viewing the image file in the _build folder. I could just use a target argument, but that makes the entire image a link, rather than the individual elements in the image.

Describe the solution you'd like Ideally, I'd just use an svg-specific directive or modifier on the image directive that bypasses whatever process that strips the links. Something like:

'''{image} svg/path.svg
:clickable: true
'''

Describe alternatives you've considered My current workaround is to include the image normally on the page with 0 height, so the image is copied on build, then use html to tag the file as an object.

'''{image} /images/test.svg
:height: 0px
'''
<object data="../_images/test.svg" type="image/svg+xml"></object>

I mean, it works, but it feels dirty and I lose any size controls that I usually have with the image directive. The Jupyter-Book documentation also mentions that use of raw HTML is "highly discouraged", so is there an official solution that doesn't use this method?

Additional context Relevant stackoverflow

karl-mohring avatar Jun 26 '20 01:06 karl-mohring