Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created April 13, 2014 01:23
Show Gist options
  • Save igaiga/10564659 to your computer and use it in GitHub Desktop.
Save igaiga/10564659 to your computer and use it in GitHub Desktop.
jekyll highlight
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