summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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