[kramdown-users] more on attribute rearrangment

Thomas Leitner t_leitner at gmx.at
Wed Aug 4 02:34:26 EDT 2010


> (2) This is wrong, I think:
> 
>   <div markdown="0">
>   <a href="test" class="ha">hey</a>
>   </div>
> 
> #=>
> 
> <div>
>   <a class="ha" href="test">hey</a>
>   </div>
> 
> The output should be the same. Attribute order should be left alone.
> This is kind of a disaster; RubyFrontier absolutely requires the href
> attribute to be first in the <a> tag in order to do certain
> postprocessing on links. It looks like kramdown must be disassembling
> tags and reassembling them them with attributes in alphabetical
> order. This seems to violate the contract in the docs, which says
> "parsed as raw HTML block and left alone". This is not "left alone"!

As explained in the other mails this is how kramdown currently parses
HTML: it creates an Element object for each HTML tag and stores the
attributes in a hash (without ordering). The converter then outputs
the attributes alphabetically. The parsing of HTML has to be done this
way to ensure certain functionality works correctly and when you look
through the mailing list you can see that a lot of effort has been put
into the current HTML parser to work like it works now. However, as said
before I will see what I can do about the re-ordering of the HTML
attributes.

-- Thomas


More information about the kramdown-users mailing list