mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-31 01:38:24 -05:00
Custom liquid tag for creating code blocks
This commit is contained in:
15
lib/jekyll/blocks.rb
Normal file
15
lib/jekyll/blocks.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Jekyll
|
||||
class Highlight < Liquid::Block
|
||||
include Liquid::StandardFilters
|
||||
|
||||
def initialize(tag_name, lang, tokens)
|
||||
super
|
||||
@lang = lang.strip
|
||||
end
|
||||
|
||||
def render(context)
|
||||
"<pre class='syntax-highlight:#{@lang}'>#{escape(super)}</pre>"
|
||||
end
|
||||
end
|
||||
end
|
||||
Liquid::Template.register_tag('highlight', Jekyll::Highlight)
|
||||
Reference in New Issue
Block a user