mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-30 09:18:11 -05:00
Rely on the Redcarpet plugin instead of hard-coding
To avoid code duplication and have to keep tracking of the API change of Rouge, let's rely on the Redcarpet plugin and customize the output on our needs.
This commit is contained in:
@@ -38,16 +38,15 @@ module Jekyll
|
||||
end
|
||||
|
||||
module WithRouge
|
||||
require 'rouge'
|
||||
require 'rouge/plugins/redcarpet'
|
||||
|
||||
include Rouge::Plugins::Redcarpet
|
||||
include CommonMethods
|
||||
|
||||
def block_code(code, lang)
|
||||
require 'rouge'
|
||||
|
||||
lexer = Rouge::Lexer.find_fancy(lang, code) || Rouge::Lexers::PlainText
|
||||
formatter = Rouge::Formatters::HTML.new
|
||||
|
||||
output = "<div class=\"highlight\">"
|
||||
output << add_code_tags(formatter.render(lexer.lex(code)), lang)
|
||||
output << add_code_tags(super, lang)
|
||||
output << "</div>"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user