diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-29 23:52:27 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-29 23:52:27 +0000 |
commit | 52dd3cdae10174cc35af6698b280acd1431cc4f8 (patch) | |
tree | 5dd5616b71029c5c4315961d8663b3a3c80714a5 /lib/rouge/formatters/html_gitlab.rb | |
parent | 38dadcee569adfbbb1c9dc99634bba4e9a9128bc (diff) | |
download | gitlab-ce-52dd3cdae10174cc35af6698b280acd1431cc4f8.tar.gz |
Add latest changes from gitlab-org/security/gitlab@15-9-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>) |