I've installed this plugin and like it a lot. However, I found out that the Markdown parser is always adding a paragraph for each line.
Problem 1
Lorem Ipsum dolor …
![foobar](foo/bar.jpeg)
… sit amet
will result in this HTML:
<p>Lorem Ipsum dolor …</p>
<p><img src="foo/bar.jpeg" alt="foobar"></p>
<p>… sit amet</p>
This plugin then converts it to a figure with caption. However, a figure (block element) is not allowed within a paragraph (invalid HTML).
Problem 2
Additionally, it will break the content if the image is inline.
Lorem Ipsum dolor ![foobar](foo/bar.jpeg) … sit amet
will result in
<p>Lorem Ipsum dolor <img src="foo/bar.jpeg" alt="foobar"> sit amet</p>
Converting the inline image in this case is wrong, because it would become a block element due to <figure> (apart from problem 1).
Solution
I have changed the plugin to only handle image tags that are inside empty paragraphs, and then also remove the paragraph. I hope my assumption about the markdown parser is correct, but as the plugin is for Gitbook I guess we can assume always the same parser…
I've installed this plugin and like it a lot. However, I found out that the Markdown parser is always adding a paragraph for each line.
Problem 1
will result in this HTML:
This plugin then converts it to a figure with caption. However, a figure (block element) is not allowed within a paragraph (invalid HTML).
Problem 2
Additionally, it will break the content if the image is inline.
will result in
Converting the inline image in this case is wrong, because it would become a block element due to
<figure>
(apart from problem 1).Solution
I have changed the plugin to only handle image tags that are inside empty paragraphs, and then also remove the paragraph. I hope my assumption about the markdown parser is correct, but as the plugin is for Gitbook I guess we can assume always the same parser…