summaryrefslogtreecommitdiff
path: root/lib/banzai
diff options
context:
space:
mode:
authorWillian Balmant <willchb@gmail.com>2019-04-11 16:09:03 +0000
committerWillian Balmant <willchb@gmail.com>2019-04-11 16:09:03 +0000
commitb27b8dc0c2e38689f519198ea127b60437e13983 (patch)
treea0c20cf975ebe748fb7253618c50e79e8bec965d /lib/banzai
parent2075ef7d071286ad156ca13640336572bb20bceb (diff)
downloadgitlab-ce-b27b8dc0c2e38689f519198ea127b60437e13983.tar.gz
Use strip to remove leading/trailing spaces
Change based on comments in MR #27025
Diffstat (limited to 'lib/banzai')
-rw-r--r--lib/banzai/filter/table_of_contents_filter.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/banzai/filter/table_of_contents_filter.rb b/lib/banzai/filter/table_of_contents_filter.rb
index 8d79f5bd58b..ade4d260be1 100644
--- a/lib/banzai/filter/table_of_contents_filter.rb
+++ b/lib/banzai/filter/table_of_contents_filter.rb
@@ -18,7 +18,6 @@ module Banzai
# `li` child elements.
class TableOfContentsFilter < HTML::Pipeline::Filter
PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u.freeze
- LEADING_OR_TRAILING_SPACE_REGEXP = /^\p{Space}+|\p{Space}+$/.freeze
def call
return doc if context[:no_header_anchors]
@@ -32,7 +31,7 @@ module Banzai
if header_content = node.children.first
id = node
.text
- .gsub(LEADING_OR_TRAILING_SPACE_REGEXP, '') # remove leading and trailing spaces
+ .strip
.downcase
.gsub(PUNCTUATION_REGEXP, '') # remove punctuation
.tr(' ', '-') # replace spaces with dash