Commit 2f5074dc authored by Douwe Maan's avatar Douwe Maan

Expand inline docs.

parent c07f0fa7
...@@ -3,7 +3,7 @@ require 'gitlab/markdown' ...@@ -3,7 +3,7 @@ require 'gitlab/markdown'
module Gitlab module Gitlab
module Markdown module Markdown
# Issues, Merge Requests, Snippets, Commits and Commit Ranges share # Issues, Merge Requests, Snippets, Commits and Commit Ranges share
# similar functionality in refernce filtering. # similar functionality in reference filtering.
class AbstractReferenceFilter < ReferenceFilter class AbstractReferenceFilter < ReferenceFilter
include CrossProjectReference include CrossProjectReference
...@@ -88,6 +88,8 @@ module Gitlab ...@@ -88,6 +88,8 @@ module Gitlab
# to the referenced object's details page. # to the referenced object's details page.
# #
# text - String text to replace references in. # 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 # Returns a String with references replaced with links. All links
# have `gfm` and `gfm-OBJECT_NAME` class names attached for styling. # have `gfm` and `gfm-OBJECT_NAME` class names attached for styling.
...@@ -98,7 +100,7 @@ module Gitlab ...@@ -98,7 +100,7 @@ module Gitlab
if project && object = find_object(project, id) if project && object = find_object(project, id)
title = escape_once(object_link_title(object)) title = escape_once(object_link_title(object))
klass = reference_class(object_sym) klass = reference_class(object_sym)
data = data_attribute( data = data_attribute(
original: link_text || match, original: link_text || match,
project: project.id, project: project.id,
......
...@@ -122,6 +122,18 @@ module Gitlab ...@@ -122,6 +122,18 @@ module Gitlab
doc doc
end 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) def replace_link_nodes_with_text(pattern)
return doc if project.nil? return doc if project.nil?
...@@ -148,6 +160,18 @@ module Gitlab ...@@ -148,6 +160,18 @@ module Gitlab
doc doc
end 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) def replace_link_nodes_with_href(pattern)
return doc if project.nil? return doc if project.nil?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment