[kramdown-users] Syntax for specifying code highlighting language | Github flavored code blocks style

Thomas Leitner t_leitner at gmx.at
Fri Aug 31 14:17:53 UTC 2012

Hi everybody,

there is a [pull request][1] on Github which, among other things, wants
to add 1) support for Github flavored code style and 2) support for
setting the highlighting language on the delimiter line of a fenced code

[1]: https://github.com/gettalong/kramdown/pull/15

I also want to talk 3) about the current way of setting the highlighting

ad 1) kramdown already has a fenced code block style:

    some code here

Github flavored code blocks use a backtick instead:

    some code here

I personally don't think that it is necessary or even good in this
case to provide another syntax for fenced code blocks. Using the
backtick currently only works on the Github website itself, as far as I

Also note that the kramdown (and php-markdown-extra and
python-markdown) fenced code blocks *do* work on Github, too!

So, what do you think?

ad 2) Providing the syntax highlighting language on the delimiter line
is a rather nice idea and not only supported by Github but also by
other markdown implementations (like python-markdown). It would look
like this:

    ~~~~~~ ruby
    class MyRuby

I would like to integrate this into kramdown -- does anyone have good
reasons for not using this syntax?

ad 3) The syntax highlighting language can currently be set by using an
IAL to specify the attribute `lang`. However, the `lang` attribute in
HTML elements is generally used for setting the natural language of the
text inside an element...

I'm for removing this collision by following the HTML5 way of
specifying the highlighting language, which is setting the class
`language-CODELANG` on the `<code>` element.

This would mean that this kramdown document:

    some code here
    {: .language-ruby .other attr="key"}

would be transformed to this HTML output (in case coderay was not used):

    <pre attr="key" class="other"><code class="language-ruby">some code here

Note that the `language-ruby` class is set on the `<code>` element and
not on the parent `<pre>` element!

This would be a backwards-incompatible change, what do you think?

Best regards,

More information about the kramdown-users mailing list