[kramdown-users] Syntax for specifying code highlighting language | Github flavored code blocks style
Thomas Leitner
t_leitner at gmx.at
Wed Sep 12 18:08:49 UTC 2012
Thanks for all the replies!
I will do the following:
* Not implement Github style fenced code blocks for the time being
* Implement support for setting the syntax highlighting language on the
delimiter line of fenced code blocks
* use class 'language-CODELANG' instead of 'lang' attr for highlighting
language (a backwards incompatible change)
-- Thomas
On 2012-08-31 16:17 +0200 Thomas Leitner wrote:
> 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 block.
>
> [1]: https://github.com/gettalong/kramdown/pull/15
>
> I also want to talk 3) about the current way of setting the
> highlighting language.
>
>
> 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 know.
>
> 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
> end
> ~~~~~~~~~~~~
>
> 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 </code></pre>
>
> 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,
> Thomas
More information about the kramdown-users
mailing list