sdumetz/jekyll-inline-svg

usage in Markdown in running text breaks, showing `</svg>` and line breaks instead of the SVG content

seansfkelley opened this issue · 0 comments

In Markdown, this plugin works great for SVGs on their own lines, but if you try to do something like

Lorem ipsum ({% svg "/foo/bar/baz.svg" %}) dolor sit amet.

It ends up displayed as

Lorem ipsum

</svg> dolor sit amet.

(Yes, without the image content.)

This is because newlines in the SVG confuse the rendering process (I'm using the default Kramdown renderer, if it matters) and terminate the implied paragraph too early, resulting in something like:

<p>Lorem ipsum <svg></p>
[rest of the SVG content here]
<p></svg> dolor sit amet.</p>

I hacked around this by forking the plugin and replacing xml.root.to_xml by xml.root.to_xml.gsub("\n", ''), which isn't great, but it gets the job done with no apparent ill effect. I can open a PR for this change if you'd like, but it seems kinda gross so if you have a nicer idea I'd be happy to do that instead.