Commit db325ef9 authored by Robert Schilling's avatar Robert Schilling

Fix Pygments 500 error if lexer not found by name. Use first alias instead. fixes #4473, #4451

parent c04e9733
...@@ -12,7 +12,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML ...@@ -12,7 +12,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
def block_code(code, language) def block_code(code, language)
options = { options: {encoding: 'utf-8'} } options = { options: {encoding: 'utf-8'} }
lexer = Pygments::Lexer.find(language) # language can be an alias lexer = Pygments::Lexer.find(language) # language can be an alias
options.merge!(lexer: lexer.name.downcase) if lexer # downcase is required options.merge!(lexer: lexer.aliases[0].downcase) if lexer # downcase is required
# New lines are placed to fix an rendering issue # New lines are placed to fix an rendering issue
# with code wrapped inside <h1> tag for next case: # with code wrapped inside <h1> tag for next case:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment