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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
1b530f96
Commit
1b530f96
authored
May 18, 2018
by
Alex
Committed by
Robert Speicher
May 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix double brackets being linkified in wiki markdown
parent
076ab2e8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
0 deletions
+37
-0
changelogs/unreleased/18524-fix-double-brackets-in-wiki-markdown.yml
...unreleased/18524-fix-double-brackets-in-wiki-markdown.yml
+5
-0
lib/banzai/filter/gollum_tags_filter.rb
lib/banzai/filter/gollum_tags_filter.rb
+3
-0
spec/features/projects/wiki/markdown_preview_spec.rb
spec/features/projects/wiki/markdown_preview_spec.rb
+23
-0
spec/lib/banzai/filter/gollum_tags_filter_spec.rb
spec/lib/banzai/filter/gollum_tags_filter_spec.rb
+6
-0
No files found.
changelogs/unreleased/18524-fix-double-brackets-in-wiki-markdown.yml
0 → 100644
View file @
1b530f96
---
title
:
Fix double-brackets being linkified in wiki markdown
merge_request
:
18524
author
:
brewingcode
type
:
fixed
lib/banzai/filter/gollum_tags_filter.rb
View file @
1b530f96
...
@@ -58,6 +58,9 @@ module Banzai
...
@@ -58,6 +58,9 @@ module Banzai
def
call
def
call
doc
.
search
(
".//text()"
).
each
do
|
node
|
doc
.
search
(
".//text()"
).
each
do
|
node
|
# Do not perform linking inside <code> blocks
next
unless
node
.
ancestors
(
'code'
).
empty?
# A Gollum ToC tag is `[[_TOC_]]`, but due to MarkdownFilter running
# A Gollum ToC tag is `[[_TOC_]]`, but due to MarkdownFilter running
# before this one, it will be converted into `[[<em>TOC</em>]]`, so it
# before this one, it will be converted into `[[<em>TOC</em>]]`, so it
# needs special-case handling
# needs special-case handling
...
...
spec/features/projects/wiki/markdown_preview_spec.rb
View file @
1b530f96
...
@@ -155,4 +155,27 @@ feature 'Projects > Wiki > User previews markdown changes', :js do
...
@@ -155,4 +155,27 @@ feature 'Projects > Wiki > User previews markdown changes', :js do
end
end
end
end
end
end
it
"does not linkify double brackets inside code blocks as expected"
do
click_link
'New page'
page
.
within
'#modal-new-wiki'
do
fill_in
:new_wiki_path
,
with:
'linkify_test'
click_button
'Create page'
end
page
.
within
'.wiki-form'
do
fill_in
:wiki_content
,
with:
<<-
HEREDOC
`[[do_not_linkify]]`
```
[[also_do_not_linkify]]
```
HEREDOC
click_on
"Preview"
end
expect
(
page
).
to
have_content
(
"do_not_linkify"
)
expect
(
page
.
html
).
to
include
(
'[[do_not_linkify]]'
)
expect
(
page
.
html
).
to
include
(
'[[also_do_not_linkify]]'
)
end
end
end
spec/lib/banzai/filter/gollum_tags_filter_spec.rb
View file @
1b530f96
...
@@ -91,6 +91,12 @@ describe Banzai::Filter::GollumTagsFilter do
...
@@ -91,6 +91,12 @@ describe Banzai::Filter::GollumTagsFilter do
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
'link-text'
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
'link-text'
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
expected_path
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
expected_path
end
end
it
"inside back ticks will be exempt from linkification"
do
doc
=
filter
(
'<code>[[link-in-backticks]]</code>'
,
project_wiki:
project_wiki
)
expect
(
doc
.
at_css
(
'code'
).
text
).
to
eq
'[[link-in-backticks]]'
end
end
end
context
'table of contents'
do
context
'table of contents'
do
...
...
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