bhollis / maruku

A pure-Ruby Markdown-superset interpreter (Official Repo).
MIT License
500 stars 80 forks source link

Markdown syntax is not processed within span-level tags. #31

Closed jornvandebeek closed 11 years ago

jornvandebeek commented 13 years ago

The markdown spec specifies "Unlike block-level HTML tags, Markdown syntax is processed within span-level tags.", yet maruku does not adhere to this rule. Any markdown within html tags seems to be ignored:

Maruku.new("<span>*hello*</span>").to_html

Generates:

"<span>*hello*</span>"

Edit:Added code tags

pelegri commented 12 years ago

On the other hand, whatever is being used to process GFM in this comment, correctly processes markedown inside spans, see below

This example shows a bullet list:

bhollis commented 11 years ago

Fixed on master.

distler commented 11 years ago

I believe the fix is not (completely) correct.

<span>*hello*</span>

<p><span>*hello*</span></p>

should be parsed as

<p><span><em>hello</em></span></p>
<p><span>*hello*</span></p>

which is not what Maruku trunk does. There's a (partial?) fix on my branch. But I don't think it handles Markdown inside of nested span-level elements as Gruber intends (?).

bhollis commented 11 years ago

@distler you're absolutely right. Testing other engines, it looks like the rule is that if there's a bare HTML element, and it's a block element, then nothing should be parsed within it. If it's HTML within Markdown, or a bare HTML element that's a span element, then it does get Markdown parsed within it.

I'll reopen this, add some tests, and fix the logic.

distler commented 11 years ago

As is frequently the case, the intended behaviour is not entirely clear.

<span>*hello*</span>

<p><span>*hello*</span></p>

<span>**hello** <span>*goodbye*</span></span>

It's pretty unambiguous that the first two should be parsed as

<p><span><em>hello</em></span></p>
<p><span>*hello*</span></p>

It's not entirely clear how the 3rd one is supposed to be parsed, but "most" Markdown interpreters seem to parse it as

<p><span><strong>hello</strong> <span><em>goodbye</em></span></span></p>

whereas my implementation (currently) treats it as

<p><span><strong>hello</strong> <span>*goodbye*</span></span></p>
distler commented 11 years ago

I wrote:

There's a (partial?) fix on my branch. But I don't think it handles Markdown inside of nested span-level elements as Gruber intends (?).

Fixed properly, now.

bhollis commented 11 years ago

Fixed in your branch? Let me know if you need a hand to bring the changes over here in a PR.

distler commented 11 years ago

Fix is now on trunk.