cebe / markdown

A super fast, highly extensible markdown parser for PHP
http://markdown.cebe.cc/
MIT License
999 stars 140 forks source link

Backticks inside inline code blocks #99

Open philsturgeon opened 9 years ago

philsturgeon commented 9 years ago

This is one of those things that would be made easier with CommonMark compliance, but even without that as a goal seems like a bug to me.

Example

Please remove the `\` from ` \``` `

Babelmark

http://johnmacfarlane.net/babelmark2/?text=Please+remove+the+%60%5C%60+from+%60+%5C%60%60%60+%60%0A

Expected Output

<p>Please remove the <code>\</code> from <code>\```</code></p>

Actual Output

p>Please remove the <code>\</code> from <code> \</code><code>` </code></p>

Just a friendly report. I'm not trying to use cebe/markdown for this, just spotted it in the babelfish output while debugging something else. :)

cebe commented 9 years ago

Thanks for reporting, already seen your tweet about it :)

The implementation is correct according to grubers markdown syntax description: https://daringfireball.net/projects/markdown/syntax#code According to that, if you want to include a literal backtick, you have to surround the whole code tag with more than one backtick or in this case the number of sequential backticks + 1:

http://markdown.cebe.cc/try?flavor=default&text=Please+remove+the+%60\%60+from+%60%60%60%60+\%60%60%60+%60%60%60%60

cebe commented 9 years ago

I am considering to add a commonmark compatible class however when I find the time for it.