summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-09 14:54:34 +0100
committerDouwe Maan <douwe@gitlab.com>2015-09-09 14:54:34 +0100
commitd3730b071365dd3dbfa0b8ec4433e1f18a93c969 (patch)
treed595bdac1a75ae1e1b9d3fed10d8585e3e70a80a
parente0da2c352325c1cb2ede88a73434ed7afc037481 (diff)
downloadgitlab-ce-d3730b071365dd3dbfa0b8ec4433e1f18a93c969.tar.gz
Fix highlighting of deleted lines in diffs.rouge-patch
-rw-r--r--CHANGELOG1
-rw-r--r--config/initializers/rouge_diff_lexer.rb24
2 files changed, 25 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 247eb1e3643..ddb31fc430f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -40,6 +40,7 @@ v 8.0.0 (unreleased)
- Add ability to get user information by ID of an SSH key via the API
- Fix bug which IE cannot show image at markdown when the image is raw file of gitlab
- Add support for Crowd
+ - Fix highlighting of deleted lines in diffs.
v 7.14.1
- Improve abuse reports management from admin area
diff --git a/config/initializers/rouge_diff_lexer.rb b/config/initializers/rouge_diff_lexer.rb
new file mode 100644
index 00000000000..fdb2d7b748e
--- /dev/null
+++ b/config/initializers/rouge_diff_lexer.rb
@@ -0,0 +1,24 @@
+# Here until https://github.com/jneen/rouge/pull/297 is merged into Rouge and the gem is updated in GitLab.
+module Rouge
+ module Lexers
+ class Diff
+ def self.analyze_text(text)
+ return 1 if text.start_with?('Index: ')
+ return 1 if text.start_with?('diff ')
+ return 0.9 if text.start_with?('--- ')
+ end
+
+ state :root do
+ rule(/^ .*\n/, Text)
+ rule(/^---\n/, Text)
+ rule(/^\+.*\n/, Generic::Inserted)
+ rule(/^-+.*\n/, Generic::Deleted)
+ rule(/^!.*\n/, Generic::Strong)
+ rule(/^@.*\n/, Generic::Subheading)
+ rule(/^([Ii]ndex|diff).*\n/, Generic::Heading)
+ rule(/^=.*\n/, Generic::Heading)
+ rule(/.*\n/, Text)
+ end
+ end
+ end
+end