php-markdown icon indicating copy to clipboard operation
php-markdown copied to clipboard

Discrepancy between how Markdown and MarkdownExtra render <footer> in blockquote

Open simensen opened this issue 12 years ago • 4 comments

I have found a discrepancy in the way that Markdown and MarkdownExtra parse a particular chunk of markdown:

$my_text = '

> Hello world, how are you?
>
> <footer>- [Example](http://example.com) *wins* **the** internet</footer>

# Hello Too!
';

$my_html = Michelf\Markdown::defaultTransform($my_text);

print $my_html;

$my_html = Michelf\MarkdownExtra::defaultTransform($my_text);

print $my_html;

The output from Markdown:

<blockquote>
  <p>Hello world, how are you?</p>

  <footer>- [Example](http://example.com) *wins* **the** internet</footer>
</blockquote>

<h1>Hello Too!</h1>

The output from MarkdownExtra:

<blockquote>
  <p>Hello world, how are you?</p>
</blockquote>

<footer>- [Example](http://example.com) *wins* **the** internet</footer>

<h1>Hello Too!</h1>

Notice how the footer is included in the blockquote in the first example (Markdown) but it is outside of the blockquote in the second example (MarkdownExtra).

Which is correct? I'm used to the former (has been working that way for over a year) but it is not clear if that is what the expectation should be. I'm guessing this might relate to whatever introduced the new behavior reported in #67.

simensen avatar Feb 08 '13 19:02 simensen

Definitively a bug.

michelf avatar Feb 08 '13 20:02 michelf

A bug in Extra I mean. There's no reason for that footer tag to be outside the blockquote.

michelf avatar Feb 08 '13 20:02 michelf

Is this something somewhat easy that I can possibly help with or is this something that is going to require a lot of work? I'm still kinda stuck trying to figure out how to format my block quotes correctly. As you noted, the solution you recommended for #67 works great except that by using Markdown Extra the footer ends up in the wrong spot in the markup.

Excited to see 1.3 stable version on Packagist. :) Switched my system to use it and then remembered that I was still having some issues with my existing markdown files. :)

simensen avatar May 02 '13 14:05 simensen

It's quite tricky. The easiest way to fix this would probably to make the HTML block parser recognize blockquotes so it can ignore them (the HTML block parser will be called again for the blockquote's content anyway). The correct/good way to fix this is to overhaul the parsing process so it becomes more like a tokenizing parser and less like a series of filters applied one after another.

michelf avatar May 02 '13 15:05 michelf