diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /lib/rouge | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'lib/rouge')
-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>) |