Showdown: Markdown intercepts indented HTML blocks

Created on 13 Mar 2017  路  11Comments  路  Source: showdownjs/showdown

Deeply nested HTML tags are not rendered properly, markdown somehow intercepts.

<div>
  <div>
    <div>
      <div>
        text
      </div>
      <div>
        text
      </div>
    </div>
  </div>
</div>

Renders into

text
text
</div>

See codepen http://codepen.io/anon/pen/wJedgq

bug pending

All 11 comments

remember that indentation affects how the markdown is rendered

http://codepen.io/anon/pen/aJwLBx

It shouldn't be processed at all unless I use markdown attribute.

<div markdown>
  <div>
    <div>
      <div>
        text
      </div>
      <div>
        text
      </div>
    </div>
  </div>
</div>

This is indeed a bug but a hard one to tackle, due to efficiency constraints. I have a fix, but it slows down the parser considerably.

Until I can find a suitable fix, that doesn't slow down the parser too much, the workaround is not indenting html code.

Why do you have this ^ {0,3} constraint on the start tags?
https://github.com/showdownjs/showdown/blob/072973ab8b027b86fb54bc6eb59850dc80f42b3a/src/subParsers/hashHTMLBlocks.js#L52

It can't be to avoid capturing indented code blocks as these are hashed away already, no?

Ah I see that indented code blocks are processed later.

Yes, they have to be processed AFTER HTML is hashed

@tivie - you talk about performance issues with your possible solution. Can you give me a pointer to how to run the performance tests as I would be interested in offering a PR for this issue but not if my solution also suffers from performance degradation.

If you install dev dependencies, you can run the command grunt performance and compare the results with previous implementations

Although performance degradation, in this case, is best seen with documents with "indented HTML".

This should (hopefully) be fixed now, without much performance issues.

Was this page helpful?
0 / 5 - 0 ratings