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

Embedded HTML tags get wrapped in <p> tags #14

Open
clark800 opened this issue Jul 26, 2023 · 3 comments
Open

Embedded HTML tags get wrapped in <p> tags #14

clark800 opened this issue Jul 26, 2023 · 3 comments

Comments

@clark800
Copy link

clark800 commented Jul 26, 2023

The readme says: "You can include arbitrary HTML code in your documents. The HTML will be
passed through to the resulting document without modification."

But when you embed top-level HTML tags like "div", they get wrapped in "p" tags. I think the ideal behavior would as the readme suggests, which is to not add the "p" tags.

@karlb
Copy link
Owner

karlb commented Jul 28, 2023

What would be the rule? I don't think this should apply for all top level tags. E.g.

Welcome!

<b>Be nice to each other!<b>

Thanks.

should add paragraph tags around each block including the middle one. So would they only be left out for block level tags?

@clark800
Copy link
Author

Yeah, I think changing the behavior for block-level tags only would make sense. Then somehow disable markdown processing until the corresponding closing tag. Maybe keep a counter of non-commented, non-quoted open (+1) and close (-1) tags of the same tag type and it ends when the counter reaches zero? I think it's fair to assume that the HTML is valid and tags/comments/quotes are balanced. If that's too complicated, I think you could also just count the tags that start at the beginning of the line and make it a user requirement that these are not commented or quoted.

@clark800
Copy link
Author

Looks like the official rules say that block-level tags should be treated differently:

The only restrictions are that block-level HTML elements — e.g. <div>, <table>, <pre>, <p>, etc. 
— must be separated from surrounding content by blank lines, and the start and end tags of the 
block should not be indented with tabs or spaces. Markdown is smart enough not to add extra 
(unwanted) <p> tags around HTML block-level tags.

https://daringfireball.net/projects/markdown/syntax#html

Based on the description, it sounds like just counting corresponding open and close tags at the beginning of lines would be sufficient.

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

No branches or pull requests

2 participants