Created
April 13, 2014 01:23
-
-
Save igaiga/10564659 to your computer and use it in GitHub Desktop.
jekyll highlight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
module Tags | |
class HighlightBlock < Liquid::Block | |
def render_codehighlighter(context, code) | |
#The div is required because RDiscount blows ass | |
<<-HTML | |
<div> | |
<pre class='#{@lang}'><code class='#{@lang}'>#{h(code).strip}</code></pre> | |
</div> | |
HTML | |
end | |
def add_code_tags(code, lang) | |
# Add nested <code> tags to code blocks | |
code = code.sub(/<pre>/,'<pre class="' + lang + '"><code class="' + lang + '">') | |
code = code.sub(/<\/pre>/,"</code></pre>") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment