Class: Banzai::Filter::References::ExternalIssueReferenceFilter
- Inherits:
-
ReferenceFilter
- Object
- HTML::Pipeline::Filter
- ReferenceFilter
- Banzai::Filter::References::ExternalIssueReferenceFilter
- 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.
Constant Summary
Constants inherited from ReferenceFilter
ReferenceFilter::REFERENCE_TYPE_DATA_ATTRIBUTE
Constants included from Concerns::PipelineTimingCheck
Concerns::PipelineTimingCheck::MAX_PIPELINE_SECONDS
Instance Method Summary collapse
- #call ⇒ Object
-
#references_in(text, pattern = object_reference_pattern) ⇒ Object
Public: Find ‘JIRA-123` issue references in text.
Methods inherited from ReferenceFilter
call, #call_and_update_nodes, #each_node, #group, #initialize, #nodes, #nodes?, #object_class, #project, #requires_unescaping?
Methods included from Concerns::OutputSafety
Methods included from RequestStoreReferenceCache
#cached_call, #get_or_set_cache
Methods included from Concerns::PipelineTimingCheck
Constructor Details
This class inherits a constructor from Banzai::Filter::References::ReferenceFilter
Instance Method Details
#call ⇒ Object
39 40 41 42 43 44 |
# File 'lib/banzai/filter/references/external_issue_reference_filter.rb', line 39 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 31 32 33 34 35 36 37 |
# File 'lib/banzai/filter/references/external_issue_reference_filter.rb', line 26 def references_in(text, pattern = object_reference_pattern) case pattern when Regexp Gitlab::Utils::Gsub.gsub_with_limit(text, pattern, limit: Banzai::Filter::FILTER_ITEM_LIMIT) do |match_data| yield match_data[0], match_data[:issue] end when Gitlab::UntrustedRegexp pattern.replace_gsub(text, limit: Banzai::Filter::FILTER_ITEM_LIMIT) do |match| yield match, match[:issue] end end end |