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
Kazuhiko Shiozaki
gitlab-ce
Commits
2f5074dc
Commit
2f5074dc
authored
Dec 01, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand inline docs.
parent
c07f0fa7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
lib/gitlab/markdown/abstract_reference_filter.rb
lib/gitlab/markdown/abstract_reference_filter.rb
+4
-2
lib/gitlab/markdown/reference_filter.rb
lib/gitlab/markdown/reference_filter.rb
+24
-0
No files found.
lib/gitlab/markdown/abstract_reference_filter.rb
View file @
2f5074dc
...
...
@@ -3,7 +3,7 @@ require 'gitlab/markdown'
module
Gitlab
module
Markdown
# Issues, Merge Requests, Snippets, Commits and Commit Ranges share
# similar functionality in refernce filtering.
# similar functionality in refer
e
nce filtering.
class
AbstractReferenceFilter
<
ReferenceFilter
include
CrossProjectReference
...
...
@@ -88,6 +88,8 @@ module Gitlab
# to the referenced object's details page.
#
# text - String text to replace references in.
# pattern - Reference pattern to match against.
# link_text - Original content of the link being replaced.
#
# Returns a String with references replaced with links. All links
# have `gfm` and `gfm-OBJECT_NAME` class names attached for styling.
...
...
@@ -98,7 +100,7 @@ module Gitlab
if
project
&&
object
=
find_object
(
project
,
id
)
title
=
escape_once
(
object_link_title
(
object
))
klass
=
reference_class
(
object_sym
)
data
=
data_attribute
(
original:
link_text
||
match
,
project:
project
.
id
,
...
...
lib/gitlab/markdown/reference_filter.rb
View file @
2f5074dc
...
...
@@ -122,6 +122,18 @@ module Gitlab
doc
end
# Iterate through the document's link nodes, yielding the current node's
# content if:
#
# * The `project` context value is present AND
# * The node's content matches `pattern`
#
# pattern - Regex pattern against which to match the node's content
#
# Yields the current node's String contents. The result of the block will
# replace the node and update the current document.
#
# Returns the updated Nokogiri::HTML::DocumentFragment object.
def
replace_link_nodes_with_text
(
pattern
)
return
doc
if
project
.
nil?
...
...
@@ -148,6 +160,18 @@ module Gitlab
doc
end
# Iterate through the document's link nodes, yielding the current node's
# content if:
#
# * The `project` context value is present AND
# * The node's HREF matches `pattern`
#
# pattern - Regex pattern against which to match the node's HREF
#
# Yields the current node's String HREF and String content.
# The result of the block will replace the node and update the current document.
#
# Returns the updated Nokogiri::HTML::DocumentFragment object.
def
replace_link_nodes_with_href
(
pattern
)
return
doc
if
project
.
nil?
...
...
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