diff --git a/lib/gitlab/markdown/label_reference_filter.rb b/lib/gitlab/markdown/label_reference_filter.rb index 9753d0ac0f9..3bb84c50b93 100644 --- a/lib/gitlab/markdown/label_reference_filter.rb +++ b/lib/gitlab/markdown/label_reference_filter.rb @@ -13,25 +13,34 @@ module Gitlab class LabelReferenceFilter < HTML::Pipeline::Filter # Public: Find label references in text # - # LabelReferenceFilter.references_in(text) do |match, label| - # "#{label}" + # LabelReferenceFilter.references_in(text) do |match, id, name| + # "#{Label.find(id)}" # end # # text - String text to search. # - # Yields the String match and the Integer label ID. + # Yields the String match, an optional Integer label ID, and an optional + # String label name. # # Returns a String replaced with the return of the block. def self.references_in(text) text.gsub(LABEL_PATTERN) do |match| - yield match, $~[:label].to_i + yield match, $~[:label_id].to_i, $~[:label_name] end end # Pattern used to extract label references from text # - # This pattern supports cross-project references. - LABEL_PATTERN = /~(?