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

28 lines
681 B
Ruby
Raw Normal View History

2018-12-23 12:14:25 +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
2017-09-10 17:25:29 +05:30
def mark(line_inline_diffs, mode: nil)
2018-04-05 14:03:07 +05:30
super(line_inline_diffs) do |text, left:, right:|
2017-09-10 17:25:29 +05:30
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}
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