Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<details> block-level element is wrapped in <p> but shouldn't #787

Closed
henrahmagix opened this issue Apr 13, 2020 · 0 comments · Fixed by #788
Closed

<details> block-level element is wrapped in <p> but shouldn't #787

henrahmagix opened this issue Apr 13, 2020 · 0 comments · Fixed by #788

Comments

@henrahmagix
Copy link
Contributor

Thanks for your great library btw! I really love using it to make my own admin interface for a Jekyll site =) Anyway onto the issue:

It's mentioned in #588 (comment) that

Showdown differentiates between block and inline HTML elements. Block elements are encoded as soon as possible while inline elements are "left alone".

<details> is a block-level element (at least in latest Safari and Chrome), so it's not allowed inside <p>, but Showdown still wraps it in <p>.

The following example shows how the browsers "fix" the structure of the HTML emitted by Showdown:

const s = new showdown.Converter();
const html = s.makeHtml('<details></details>');
// <p><details></details></p>
const div = document.createElement('div');
div.innerHTML = html;
const browserHTML = div.innerHTML;
// <p></p><details></details><p></p>
// can't use browserHTML :'(
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 a pull request may close this issue.

1 participant