Feature Request: Automatically detect language #87

lukearmstrong opened this Issue Nov 17, 2012 · 1 comment

3 participants


I use Jekyll to host my blog using Github Pages. The markdown syntax to wrap a block of code is to indent with 4 spaces, this wraps using <pre><code></code></pre>.

So I am not able to apply the appropriate value to a data-language attribute, as the <pre><code></code></pre> isn't actually in my markdown file, it is generated.

Well, I could wrap the code blocks with the HTML manually, but I want to keep my articles written purely in markdown, so the Github preview works.

So I'm wondering how difficult it would be to detect the language of the code inside the <pre><code></code></pre> block, and then apply the appropriate styling to it. It doesn't have to be 100% accurate, just better than what I am doing at the moment:

$(function() {
    $("pre > code").attr('data-language', 'generic');

Markdown Source:

Markdown Preview:

Resulting HTML generated by Jekyll:



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment