diff options
author | Willian Balmant <willchb@gmail.com> | 2019-04-10 20:50:26 +0000 |
---|---|---|
committer | Willian Balmant <willchb@gmail.com> | 2019-04-10 20:50:26 +0000 |
commit | 2075ef7d071286ad156ca13640336572bb20bceb (patch) | |
tree | 6c69724887832bab8d34943f15a05889a7967948 /lib | |
parent | b6ca523cf7b8f7339d13d730c9fa24e7cac3263b (diff) | |
download | gitlab-ce-2075ef7d071286ad156ca13640336572bb20bceb.tar.gz |
No leading/trailing spaces when generating heading ids (Fixes #57528)
Update based on comments in MR #27025
Diffstat (limited to 'lib')
-rw-r--r-- | lib/banzai/filter/table_of_contents_filter.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/banzai/filter/table_of_contents_filter.rb b/lib/banzai/filter/table_of_contents_filter.rb index d4cf08be0ae..8d79f5bd58b 100644 --- a/lib/banzai/filter/table_of_contents_filter.rb +++ b/lib/banzai/filter/table_of_contents_filter.rb @@ -17,8 +17,8 @@ module Banzai # :toc - String containing Table of Contents data as a `ul` element with # `li` child elements. class TableOfContentsFilter < HTML::Pipeline::Filter - PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u - LEADING_OR_TRAILING_SPACE_REGEXP = /^\p{Space}|\p{Space}$/ + 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] |