[kramdown-users] kramdown table-making has gone completely insane

Thomas Leitner t_leitner at gmx.at
Tue Oct 12 03:34:22 EDT 2010

On 2010-10-12 05:41 +1100 Shawn Van Ittersum wrote:
> Sorry for the confusion about code spans and code blocks.  But if
> kramdown does not process the contents of code spans, then how do the
> pipe characters in Matt's example get interpreted as table cell
> delimiters?  They're inside a code span:
> require 'kramdown'
> s = <<END
> The operator `||` is called logical-or.
> puts Kramdown::Document.new(s).to_html

This is easily explained: The kramdown parser has basically two stages.
The first stage parses the document line by line and builds the tree of
all *block level elements*. After that the text in the block level
elements is parsed using the span level parser which returns text and,
possibly, span level elements.

So your assumption that the above document line contains a code span is
only correct *if* the line is parsed as paragraph. However, the table
parser is invoked before the paragraph parser (because everything that
is not any valid other kramdown block level element is a paragraph),
finds the pipes, concludes that it is a table line, splits the line
into cells using the pipes as separators and boom: no more code span!

-- Thomas

More information about the kramdown-users mailing list