jeffreytse / jekyll-spaceship

🚀 A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, mermaid, emoji, video, audio, youtube, vimeo, dailymotion, soundcloud, spotify, etc.
MIT License
626 stars 67 forks source link

img tag is converted to invalid xml #69

Open KjellMorgenstern opened 2 years ago

KjellMorgenstern commented 2 years ago

In my document I have image tags like <img src="someimage.png"/>

As soon as I include the spaceship gem, the tags are converted to

<img src="someimage.png">

The "/" at the end is removed. This is not valid xhtml anymore and breaks some parsers.

jeffreytse commented 2 years ago

Hi @KjellMorgenstern

I just tried, and it still keeps converting to an unclosed tag without spaceship, could you have a try in your side?

Thanks and Regards

KjellMorgenstern commented 2 years ago

There are multiple thumbnail gems, maybe that is why it looks different for you. See https://github.com/superterran/jekyll-thumbnail/blob/master/lib/jekyll-thumbnail.rb , line 67. This generates a closed image tag.

jeffreytse commented 2 years ago

Hi @KjellMorgenstern

Thanks for your information, is it that I need to install this gem to reproduce the issue?

Thanks and Regards

KjellMorgenstern commented 2 years ago

Kramdown itself inserts an end slashes for images (and other elements): https://github.com/gettalong/kramdown/blob/master/lib/kramdown/converter/html.rb#L276

However, only when I use the jekyll-thumbnail gem, without the spaceship gem, I get the desired closed img tags:

I tried to add <img src="test.png"/> directly in a post, and it was converted to <img src="test.png"> without the spaceship gem.

So, yes, the thumbnail gem is needed to reproduce this.

jeffreytse commented 2 years ago

@KjellMorgenstern I know what you mean, let me have a check and find a solution. Thank you! : )