From 879be42862e05761c5b57d31961ed1a978de957d Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 15 Apr 2015 14:21:20 -0400 Subject: [PATCH] Initialize the references result Hash in ReferenceFilter --- lib/gitlab/markdown/reference_filter.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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