fletcher / MultiMarkdown-4

This project is now deprecated. Please use MultiMarkdown-6 instead!
https://github.com/fletcher/MultiMarkdown-5
Other
306 stars 59 forks source link

Fenced code block with leading # character misinterpreted by {{TOC}} as heading #108

Closed rhempel closed 9 years ago

rhempel commented 9 years ago

A fenced code block like this:

#define INDEX_FOO       0
#define INDEX_BAR       1

and the {{TOC}} feature (thanks!) don't play well together - they produce:

<li>[define INDEX_FOO 0][defineindex_foo0]</li>
<li>[define INDEX_BAR 1][defineindex_bar1]</li>

The actual fenced code block is fine

fletcher commented 9 years ago

I'll look into this.

I increasingly believe I was correct in my initial assertion that fenced code blocks were a bad idea, as they add a huge degree of uncertainty to what was mostly a fairly predictable format (Multi/Markdown) otherwise. But I conceded, and implemented them, and now have to deal with it, or remove them.... Live and learn...

:)

rhempel commented 9 years ago

Having written a few parsers myself, but not a Markdown parser, I am in no position to argue for or against. That being said, I do use fenced code blocks all the time in my docs, so as a user I'd like them to stay. The issue (I think) is that the TOC parser does not understand that it should ignore anything in a fenced code block - but that's just a guess.

fletcher commented 9 years ago

The problem is not that I don't understand where to fix the problem (I have a bit of experience with the code over the last 10 years, as you can imagine).

The problem is that fenced code blocks break many assumptions you can otherwise make about Markdown.