Skip to content

Paragraphs and inline image#1

Merged
todvora merged 3 commits intotodvora:masterfrom
aschempp:fix-paragraph
Nov 6, 2015
Merged

Paragraphs and inline image#1
todvora merged 3 commits intotodvora:masterfrom
aschempp:fix-paragraph

Conversation

@aschempp
Copy link
Copy Markdown
Contributor

@aschempp aschempp commented Nov 5, 2015

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…

todvora added a commit that referenced this pull request Nov 6, 2015
@todvora todvora merged commit 2485dbc into todvora:master Nov 6, 2015
@todvora
Copy link
Copy Markdown
Owner

todvora commented Nov 6, 2015

Hi Andreas,
Thank you very much for your changes! They are now merged and the plugin released as 0.2.0.

Best regards,
Tomas

@aschempp
Copy link
Copy Markdown
Contributor Author

aschempp commented Nov 6, 2015

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants