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
Invalid HTML produced when using <pre> tag in html mode #951
Comments
I would like to work on this. |
I looked into this issue, and I found that although this behavior does not match the GitHub implementation, this is actually expected behavior according to commonmark specs. However, if you wish for the code to not follow the commonmark specs behavior, I have a proposed fix: Add Please let me know what behavior is desired. |
Thank you for the commonmark reference. What a strange spec! I assume there must be a reason for this decision. In my case, I have worked around the problem by pre-treating the markdown input as follows: html = html.replace(/<pre/g, "\n<pre"); By inserting a blank before the pre tag, it terminates any initial HTML block preceding it. Thus allowing the <pre block to be terminated by its own end tag instead of the blank line inside. I shall also now add script, style and textarea to this, for completeness. |
As written above - works as spec says. Details about spec desitions can be seen on commonmark forum. |
When
<pre>
is used in the input in a certain way, and html mode is on, then markdown-it can produce invalid HTML output:Demo
Input:
Output:
(Note that the
<p>
tag is erroneously inserted around second line of text and then</pre>
is inserted before closing</p>
tag, violating nesting rule.)I checked and I noted that GitHub's markdown implementation handles the same input OK .
The text was updated successfully, but these errors were encountered: