summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-04-15 14:21:20 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-04-25 14:39:44 -0400
commit879be42862e05761c5b57d31961ed1a978de957d (patch)
tree1cb9cae9fa38a9b00417ad90c5563f6fb8ba40a3 /lib
parent439b9f50af3168d33169a4cd25b59e45ea46dc62 (diff)
downloadgitlab-ce-879be42862e05761c5b57d31961ed1a978de957d.tar.gz
Initialize the references result Hash in ReferenceFilter
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown/reference_filter.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/markdown/reference_filter.rb b/lib/gitlab/markdown/reference_filter.rb
index ef4aa408a7e..efd7ea16fcc 100644
--- a/lib/gitlab/markdown/reference_filter.rb
+++ b/lib/gitlab/markdown/reference_filter.rb
@@ -12,7 +12,15 @@ module Gitlab
# :reference_class - Custom CSS class added to reference links.
# :only_path - Generate path-only links.
#
+ # Results:
+ # :references - A Hash of references that were found and replaced.
class ReferenceFilter < HTML::Pipeline::Filter
+ def initialize(*args)
+ super
+
+ result[:references] = Hash.new { |hash, type| hash[type] = [] }
+ end
+
def escape_once(html)
ERB::Util.html_escape_once(html)
end
@@ -29,6 +37,14 @@ module Gitlab
context[:project]
end
+ # Add a reference to the pipeline's result Hash
+ #
+ # type - Singular Symbol reference type (e.g., :issue, :user, etc.)
+ # value - Object to add
+ def push_result(type, value)
+ result[:references][type].push(value)
+ end
+
def reference_class(type)
"gfm gfm-#{type} #{context[:reference_class]}".strip
end