From b40ecbb54c53aea6acff883f26717ad2b653080c Mon Sep 17 00:00:00 2001 From: "Johannes Schriewer (Dunkelstern)" Date: Mon, 25 Mar 2013 23:19:59 +0100 Subject: [PATCH 1/2] Fix Error 500 if Pygments can not hilight a code block in the Readme of a project when browsing files (falls back to standard '
'
 block on exception)

---
 lib/redcarpet/render/gitlab_html.rb | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb
index 4f2c86e2d41..e79230c0bb2 100644
--- a/lib/redcarpet/render/gitlab_html.rb
+++ b/lib/redcarpet/render/gitlab_html.rb
@@ -11,7 +11,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
 
   def block_code(code, language)
     options = { options: {encoding: 'utf-8'} }
-    options.merge!(lexer: language.downcase) if Pygments::Lexer.find(language)
+    options.merge!(lexer: language.downcase) if Pygments::Lexer.find(language.downcase)
 
     # New lines are placed to fix an rendering issue
     # with code wrapped inside 

tag for next case: @@ -20,11 +20,19 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML # # ruby code here # - <<-HTML + begin + <<-HTML -
#{Pygments.highlight(code, options)}
+
#{Pygments.highlight(code, options)}
- HTML + HTML + rescue + <<-HTML + +
#{code}
+ + HTML + end end def link(link, title, content) -- GitLab From 48226cc8e841898488d32a6e9a68e8493ad3b5b8 Mon Sep 17 00:00:00 2001 From: "Johannes Schriewer (Dunkelstern)" Date: Mon, 25 Mar 2013 23:32:40 +0100 Subject: [PATCH 2/2] downcasing can raise yet another error so removed it --- lib/redcarpet/render/gitlab_html.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index e79230c0bb2..8d4b9380e02 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -11,7 +11,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML def block_code(code, language) options = { options: {encoding: 'utf-8'} } - options.merge!(lexer: language.downcase) if Pygments::Lexer.find(language.downcase) + options.merge!(lexer: language.downcase) if Pygments::Lexer.find(language) # New lines are placed to fix an rendering issue # with code wrapped inside

tag for next case: -- GitLab