Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Feature Request: Automatically detect language #87

Open
lukearmstrong opened this Issue · 1 comment

2 participants

@lukearmstrong

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');
    Rainbow.color();
});

Markdown Source:
https://raw.github.com/lukearmstrong/lukearmstrong.github.com/master/_posts/2012-10-18-minify-your-css-and-javascript.markdown

Markdown Preview:
https://github.com/lukearmstrong/lukearmstrong.github.com/blob/master/_posts/2012-10-18-minify-your-css-and-javascript.markdown

Resulting HTML generated by Jekyll:
http://lukearmstrong.co.uk/2012/10/18/minify-your-css-and-javascript/

@natew

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.