Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
d73ece022f4d
Commit
d73ece02
authored
Sep 08, 2018
by
Brett Walker
Browse files
Resolve "Process urls with spaces in all markdown processing"
parent
9cfecb85bd05
Changes
5
Hide whitespace changes
Inline
Side-by-side
lib/banzai/filter/spaced_link_filter.rb
View file @
d73ece02
...
...
@@ -10,6 +10,6 @@
#
# CommonMark does not allow spaces in the url portion of a link/url.
# For example, `[example](page slug)` is not valid.
# Neither is ``. However,
# Neither is ``. However,
particularly
# in our wikis, we support (via RedCarpet) this type of link, allowing
# wiki pages to be easily linked by their title. This filter adds that functionality.
...
...
@@ -14,7 +14,8 @@
# in our wikis, we support (via RedCarpet) this type of link, allowing
# wiki pages to be easily linked by their title. This filter adds that functionality.
# The intent is for this to only be used in Wikis - in general, we want
# to adhere to CommonMark's spec.
#
# This is a small extension to the CommonMark spec. If they start allowing
# spaces in urls, we could then remove this filter.
#
class
SpacedLinkFilter
<
HTML
::
Pipeline
::
Filter
include
ActionView
::
Helpers
::
TagHelper
...
...
lib/banzai/pipeline/gfm_pipeline.rb
View file @
d73ece02
...
...
@@ -16,6 +16,7 @@
Filter
::
MathFilter
,
Filter
::
ColorFilter
,
Filter
::
MermaidFilter
,
Filter
::
SpacedLinkFilter
,
Filter
::
VideoLinkFilter
,
Filter
::
ImageLazyLoadFilter
,
Filter
::
ImageLinkFilter
,
...
...
lib/banzai/pipeline/wiki_pipeline.rb
View file @
d73ece02
...
...
@@ -5,7 +5,6 @@
@filters
||=
begin
super
.
insert_after
(
Filter
::
TableOfContentsFilter
,
Filter
::
GollumTagsFilter
)
.
insert_before
(
Filter
::
TaskListFilter
,
Filter
::
WikiLinkFilter
)
.
insert_before
(
Filter
::
VideoLinkFilter
,
Filter
::
SpacedLinkFilter
)
end
end
end
...
...
spec/helpers/issuables_helper_spec.rb
View file @
d73ece02
...
...
@@ -184,7 +184,7 @@
issuableRef:
"#
#{
issue
.
iid
}
"
,
markdownPreviewPath:
"/
#{
@project
.
full_path
}
/preview_markdown"
,
markdownDocsPath:
'/help/user/markdown'
,
markdownVersion:
11
,
markdownVersion:
CacheMarkdownField
::
CACHE_COMMONMARK_VERSION
,
issuableTemplates:
[],
projectPath:
@project
.
path
,
projectNamespace:
@project
.
namespace
.
path
,
...
...
spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
View file @
d73ece02
...
...
@@ -87,4 +87,22 @@
end
end
end
describe
'markdown link or image urls having spaces'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
it
'rewrites links with spaces in url'
do
markdown
=
"[Link to Page](page slug)"
output
=
described_class
.
to_html
(
markdown
,
project:
project
)
expect
(
output
).
to
include
(
"href=
\"
page%20slug
\"
"
)
end
it
'rewrites images with spaces in url'
do
markdown
=
""
output
=
described_class
.
to_html
(
markdown
,
project:
project
)
expect
(
output
).
to
include
(
"src=
\"
test%20image.png
\"
"
)
end
end
end
Write
Preview
Supports
Markdown
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