Skip to content

Instantly share code, notes, and snippets.

@curiouslychase
Last active December 20, 2015 07:29
Show Gist options
  • Save curiouslychase/6093506 to your computer and use it in GitHub Desktop.
Save curiouslychase/6093506 to your computer and use it in GitHub Desktop.
A script to modify Jekyll's highlight class. Updated for Jekyll 1.0.3 from this blog post: http://thanpol.as/jekyll/jekyll-code-highlight-and-line-numbers-problem-solved/
# Working as of Jekyll 1.0.3
module Jekyll
class WrapHighlightBlock < Jekyll::Tags::HighlightBlock
def initialize(tag_name, markup, tokens)
super
end
def render(context)
'<figure class="code"><figcaption></figcaption>' + super + '</figure>'
# I use gist for big code blocks, so I wanted to make my jekyll highlighting
# reflect the same node tree for keeping styles dry
# '<div class="gist-file"><div class="gist-data gist-syntax"><div class="line">' + super + '</div></div></div>'
end
end
end
Liquid::Template.register_tag('highlight', Jekyll::WrapHighlightBlock)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment