Class: Banzai::Filter::References::ExternalIssueReferenceFilter

Inherits:
ReferenceFilter
  • Object
show all
Defined in:
lib/banzai/filter/references/external_issue_reference_filter.rb

Overview

HTML filter that replaces external issue tracker references with links. References are ignored if the project doesn't use an external issue tracker.

This filter does not support cross-project references.

Instance Method Summary collapse

Methods inherited from ReferenceFilter

call, #call_and_update_nodes, #each_node, #group, #initialize, #nodes, #object_class, #project, #requires_unescaping?

Methods included from OutputSafety

#escape_once

Methods included from RequestStoreReferenceCache

#cached_call, #get_or_set_cache

Constructor Details

This class inherits a constructor from Banzai::Filter::References::ReferenceFilter

Instance Method Details

#callObject


32
33
34
35
36
37
# File 'lib/banzai/filter/references/external_issue_reference_filter.rb', line 32

def call
  # Early return if the project isn't using an external tracker
  return doc if project.nil? || default_issues_tracker?

  super
end

#references_in(text, pattern = object_reference_pattern) ⇒ Object

Public: Find `JIRA-123` issue references in text

references_in(text, pattern) do |match, issue|
  "<a href=...>##{issue}</a>"
end

text - String text to search.

Yields the String match and the String issue reference.

Returns a String replaced with the return of the block.


26
27
28
29
30
# File 'lib/banzai/filter/references/external_issue_reference_filter.rb', line 26

def references_in(text, pattern = object_reference_pattern)
  text.gsub(pattern) do |match|
    yield match, $~[:issue]
  end
end