Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
51f6e866
Commit
51f6e866
authored
Aug 18, 2020
by
Vasilii Iakliushin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove product suffix from anchors
parent
2ac47a71
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
lib/gitlab/utils/markdown.rb
lib/gitlab/utils/markdown.rb
+2
-0
spec/lib/banzai/filter/table_of_contents_filter_spec.rb
spec/lib/banzai/filter/table_of_contents_filter_spec.rb
+5
-0
spec/lib/gitlab/utils/markdown_spec.rb
spec/lib/gitlab/utils/markdown_spec.rb
+8
-0
No files found.
lib/gitlab/utils/markdown.rb
View file @
51f6e866
...
...
@@ -4,9 +4,11 @@ module Gitlab
module
Utils
module
Markdown
PUNCTUATION_REGEXP
=
/[^\p{Word}\- ]/u
.
freeze
PRODUCT_SUFFIX
=
/\((CORE|STARTER|PREMIUM|ULTIMATE)(\s+ONLY)?\)/
.
freeze
def
string_to_anchor
(
string
)
string
.
gsub
(
PRODUCT_SUFFIX
,
''
)
.
strip
.
downcase
.
gsub
(
PUNCTUATION_REGEXP
,
''
)
# remove punctuation
...
...
spec/lib/banzai/filter/table_of_contents_filter_spec.rb
View file @
51f6e866
...
...
@@ -65,6 +65,11 @@ RSpec.describe Banzai::Filter::TableOfContentsFilter do
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'href'
)).
to
eq
'#title-with-spaces'
end
it
'removes a product suffix'
do
doc
=
filter
(
header
(
1
,
"Title with spaces (ULTIMATE)"
))
expect
(
doc
.
css
(
'h1 a'
).
first
.
attr
(
'href'
)).
to
eq
'#title-with-spaces'
end
it
'appends a unique number to duplicates'
do
doc
=
filter
(
header
(
1
,
'One'
)
+
header
(
2
,
'One'
))
...
...
spec/lib/gitlab/utils/markdown_spec.rb
View file @
51f6e866
...
...
@@ -52,6 +52,14 @@ RSpec.describe Gitlab::Utils::Markdown do
end
end
context
'when string has a product suffix'
do
let
(
:string
)
{
'My Header (ULTIMATE)'
}
it
'ignores a product suffix'
do
is_expected
.
to
eq
'my-header'
end
end
context
'when string is empty'
do
let
(
:string
)
{
''
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment