BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
466bec7c
Commit
466bec7c
authored
Apr 29, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename SCHEME_PATTERN to LINK_PATTERN
parent
cd3c24a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
autolink_filter.rb
lib/gitlab/markdown/autolink_filter.rb
+5
-5
No files found.
lib/gitlab/markdown/autolink_filter.rb
View file @
466bec7c
...
...
@@ -27,9 +27,9 @@ module Gitlab
# in the generated link.
#
# Rubular: http://rubular.com/r/cxjPyZc7Sb
SCHEME
_PATTERN
=
%r{([a-z][a-z0-9
\+\.
-]+://
\S
+)(?<!,|
\.
)}
LINK
_PATTERN
=
%r{([a-z][a-z0-9
\+\.
-]+://
\S
+)(?<!,|
\.
)}
# Text matching
SCHEME
_PATTERN inside these elements will not be linked
# Text matching
LINK
_PATTERN inside these elements will not be linked
IGNORE_PARENTS
=
%w(a code kbd pre script style)
.
to_set
def
call
...
...
@@ -62,14 +62,14 @@ module Gitlab
@doc
=
parse_html
(
rinku
)
end
# Autolinks any text matching
SCHEME
_PATTERN that Rinku didn't already
# Autolinks any text matching
LINK
_PATTERN that Rinku didn't already
# replace
def
text_parse
search_text_nodes
(
doc
).
each
do
|
node
|
content
=
node
.
to_html
next
if
has_ancestor?
(
node
,
IGNORE_PARENTS
)
next
unless
content
.
match
(
SCHEME
_PATTERN
)
next
unless
content
.
match
(
LINK
_PATTERN
)
# If Rinku didn't link this, there's probably a good reason, so we'll
# skip it too
...
...
@@ -86,7 +86,7 @@ module Gitlab
end
def
autolink_filter
(
text
)
text
.
gsub
(
SCHEME
_PATTERN
)
do
|
match
|
text
.
gsub
(
LINK
_PATTERN
)
do
|
match
|
options
=
link_options
.
merge
(
href:
match
)
content_tag
(
:a
,
match
,
options
)
end
...
...
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