gitlab-org--gitlab-foss/lib/gitlab/diff/inline_diff_marker.rb

28 lines
687 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-01-15 10:02:48 -05:00
module Gitlab
module Diff
class InlineDiffMarker < Gitlab::StringRangeMarker
def initialize(line, rich_line = nil)
super(line, rich_line || line)
end
def mark(line_inline_diffs)
super(line_inline_diffs) do |text, left:, right:, mode:|
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}.html_safe
2016-01-15 10:02:48 -05:00
end
end
2016-01-15 10:29:26 -05:00
private
def html_class_names(left, right, mode)
class_names = ["idiff"]
class_names << "left" if left
class_names << "right" if right
class_names << mode if mode
class_names.join(" ")
end
2016-01-15 10:02:48 -05:00
end
end
end