[kramdown-users] block parsing not recursive?

Matt Neuburg matt at tidbits.com
Mon Aug 27 20:30:29 UTC 2012


Okay, but given that I've got the HTML that I've got, is there any way to have kramdown come sweeping down through it and apply span-level and character-level transformations, like turning _great_ into <em>great</em> and making "stupid" quotes smart? m.

On Aug 27, 2012, at 1:15 PM, Thomas Leitner wrote:

> On 2012-08-12 08:33 -0700 Matt Neuburg wrote:
>> Shouldn't markdown="1" work recursively downward, so that _great_ is
>> parsed into <em>?
> 
> No, the markdown attribute is only applied to the content of the tag
> itself, not to other HTML tags found within.
> 
>> (2)
>> 
>> Okay, so let's try :parse_block_html instead:
>> 
>> s = <<END
>> <div markdown>
>> <p>This is a _great_ text</p>
>> <table>
>> <p>This is a _great_ text</p>
>> </table>
>> </div>
>> END
>> 
>> p Kramdown::Document.new(s, :parse_block_html => true).to_html
>> # => "<div>\n  <p>This is a <em>great</em> text</p>\n
>> <table>\n<p>This is a _great_ text</p>\n</table>\n</div>\n"
>> 
>> So now we do recurse down into the first <p> tag. But what's up with
>> the <table> tag? It seems to block recursion down.
> 
> It works fine if you use <div> instead of <table>. This is because the
> HTML content model for <table> is 'raw' whereas for <div> it is 'block'
> - raw content is not parsed any further but block content is.
> 
> This is done because the <table> element cannot contain kramdown block
> or span elements.
> 
> Best regards,
>  Thomas
> _______________________________________________
> kramdown-users mailing list
> kramdown-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/kramdown-users



More information about the kramdown-users mailing list