debian-mirror-gitlab/lib/gitlab/diff/inline_diff_marker.rb

28 lines
687 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2016-01-29 22:53:50 +05:30
module Gitlab
module Diff
2017-09-10 17:25:29 +05:30
class InlineDiffMarker < Gitlab::StringRangeMarker
2018-04-05 14:03:07 +05:30
def initialize(line, rich_line = nil)
super(line, rich_line || line)
end
2021-04-17 20:07:23 +05:30
def mark(line_inline_diffs)
super(line_inline_diffs) do |text, left:, right:, mode:|
2020-01-01 13:55:28 +05:30
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}.html_safe
2016-01-29 22:53:50 +05:30
end
end
private
2017-09-10 17:25:29 +05:30
def html_class_names(left, right, mode)
2016-06-02 11:05:42 +05:30
class_names = ["idiff"]
2017-09-10 17:25:29 +05:30
class_names << "left" if left
class_names << "right" if right
2016-06-02 11:05:42 +05:30
class_names << mode if mode
class_names.join(" ")
end
2016-01-29 22:53:50 +05:30
end
end
end