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

Markdown incorrectly processing HTML #134

Open
dkharrat opened this issue Sep 24, 2012 · 4 comments
Open

Markdown incorrectly processing HTML #134

dkharrat opened this issue Sep 24, 2012 · 4 comments

Comments

@dkharrat
Copy link

Not sure if this is another bug that popped up after the fix for issue #96, but looks like I found another bug in processing inline HTML. The following HTML snippet reproduces the bug:

This line is correctly interpreted as regular markdown

<div>
<div>
test
</div>

<h2>Header</h2>
<ol>
   <li>
      <p>First paragraph</p>
   </li>
   <li>
      <p>Second paragaph</p>
   </li>
</ol>
</div>

generates:

<p>This line is correctly interpreted as regular markdown</p>

<div>
<div>
test
</div>

<p><h2>Header</h2>
<ol>
   <li>
      <p>First paragraph</p>
   </li>
   <li>
      <p>Second paragaph</p>
   </li>
</ol>
</div></p>

Notice that an extra <p> tag is generated before the <h2> tag and after the last </div> tag, resulting in an invalid HTML.

@dkharrat
Copy link
Author

Any update on this one?

@mildsunrise
Copy link

For the record: this isn't a bug, it's a consequence of how Sundown looks for the ending tag.

In order to tell Sundown where your tag really ends, you should indent the HTML, or at least the first </div>:

This line is correctly interpreted as regular markdown

<div>
<div>
test
  </div>

<h2>Header</h2>
<ol>
   <li>
      <p>First paragraph</p>
   </li>
   <li>
      <p>Second paragaph</p>
   </li>
</ol>
</div>

@dkharrat
Copy link
Author

dkharrat commented Sep 4, 2014

Good to know about the workaround. But from the perspective of the library user, I'd consider this a bug as valid markdown input is producing invalid html output. Shouldn't Sundown just not process markdown inside HTML tags instead of relying on indentation? According to the Markdown spec:

Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style emphasis inside an HTML block.

@mildsunrise
Copy link

Well, that's actually from the spec. The spec says the ending tag should be on an unindented line, and be followed by empty lines.

So, Sundown searches for the first </div> tag matching these requeriments (which is the wrong tag, but Sundown doesn't actually parse the HTML).

GerHobbelt pushed a commit to GerHobbelt/soldout that referenced this issue Feb 11, 2021
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