diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-29 23:52:20 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-29 23:52:20 +0000 |
commit | ea1912e51181abbbad5f33486ac5f455c19f1d2e (patch) | |
tree | 9429b7d4adafdb3b802ad74fcabead08c92ddae5 /lib/rouge/formatters/html_gitlab.rb | |
parent | 297ad29837559abc899e81626ab9deeab11c1c2c (diff) | |
download | gitlab-ce-ea1912e51181abbbad5f33486ac5f455c19f1d2e.tar.gz |
Add latest changes from gitlab-org/security/gitlab@15-8-stable-ee
Diffstat (limited to 'lib/rouge/formatters/html_gitlab.rb')
-rw-r--r-- | lib/rouge/formatters/html_gitlab.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/rouge/formatters/html_gitlab.rb b/lib/rouge/formatters/html_gitlab.rb index 436739bed12..a7e95a96b8b 100644 --- a/lib/rouge/formatters/html_gitlab.rb +++ b/lib/rouge/formatters/html_gitlab.rb @@ -25,7 +25,10 @@ module Rouge yield %(<span id="LC#{@line_number}" class="line" lang="#{@tag}">) line.each do |token, value| - yield highlight_unicode_control_characters(span(token, value.chomp! || value)) + value = value.chomp! || value + value = replace_space_characters(value) + + yield highlight_unicode_control_characters(span(token, value)) end yield ellipsis if @ellipsis_indexes.include?(@line_number - 1) && @ellipsis_svg.present? @@ -42,6 +45,10 @@ module Rouge %(<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 replace_space_characters(text) + text.gsub(Gitlab::Unicode::SPACE_REGEXP, ' ') + 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>) |