Commit 6282202e authored by Rubén Dávila's avatar Rubén Dávila

Remove custom Lexer. #3945 [ci skip]

Inline diff is going to be generated client side now. #3945
parent 21b602c6
......@@ -95,8 +95,7 @@ module Gitlab
end
def lexer
parent = Rouge::Lexer.guess(filename: @file_name, source: @code).new rescue Rouge::Lexers::PlainText.new
Rouge::Lexers::GitlabDiff.new(parent_lexer: parent)
Rouge::Lexer.guess(filename: @file_name, source: @code).new rescue Rouge::Lexers::PlainText.new
end
def unescape_html(content)
......
Rouge::Token::Tokens.token(:InlineDiff, 'idiff')
module Rouge
module Lexers
# This new Lexer is required in order to avoid the inline diff markup
# to be tokenized, it will be rendered as raw HTML code if that happens.
class GitlabDiff < RegexLexer
title "GitLab Diff"
tag 'gitlab_diff'
state :root do
rule %r{<span class='idiff'>(.*?)</span>} do |match|
token InlineDiff, match[1]
end
rule /(?:(?!<span class='idiff').)*/m do
delegate option(:parent_lexer)
end
end
start do
option(:parent_lexer).reset!
end
end
end
end
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