diff options
Diffstat (limited to 'lib/rouge/formatters/html_gitlab.rb')
-rw-r--r-- | lib/rouge/formatters/html_gitlab.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/rouge/formatters/html_gitlab.rb b/lib/rouge/formatters/html_gitlab.rb index 9e76225fc54..436739bed12 100644 --- a/lib/rouge/formatters/html_gitlab.rb +++ b/lib/rouge/formatters/html_gitlab.rb @@ -12,6 +12,8 @@ module Rouge def initialize(options = {}) @tag = options[:tag] @line_number = options[:line_number] || 1 + @ellipsis_indexes = options[:ellipsis_indexes] || [] + @ellipsis_svg = options[:ellipsis_svg] end def stream(tokens) @@ -26,6 +28,8 @@ module Rouge yield highlight_unicode_control_characters(span(token, value.chomp! || value)) end + yield ellipsis if @ellipsis_indexes.include?(@line_number - 1) && @ellipsis_svg.present? + yield %(</span>) @line_number += 1 @@ -34,6 +38,10 @@ module Rouge private + def ellipsis + %(<span class="gl-px-2 gl-rounded-base gl-mx-2 gl-bg-gray-100 gl-cursor-help has-tooltip" title="Content has been trimmed">#{@ellipsis_svg}</span>) + end + def highlight_unicode_control_characters(text) text.gsub(Gitlab::Unicode::BIDI_REGEXP) do |char| %(<span class="unicode-bidi has-tooltip" data-toggle="tooltip" title="#{Gitlab::Unicode.bidi_warning}">#{char}</span>) |