From ca54d43f9900666ff86fb4c647f9f9441eec781a Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sat, 10 Nov 2012 00:55:56 +0100 Subject: [PATCH] Fix 500s because of "missing" lexer --- lib/redcarpet/render/gitlab_html.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index 30a80714..48b4da9d 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -10,10 +10,12 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML end def block_code(code, language) + options = { options: {encoding: 'utf-8'} } + if Pygments::Lexer.find(language) - Pygments.highlight(code, lexer: language, options: {encoding: 'utf-8'}) + Pygments.highlight(code, options.merge(lexer: language.downcase)) else - Pygments.highlight(code, options: {encoding: 'utf-8'}) + Pygments.highlight(code, options) end end