Class: Banzai::Filter::References::ProjectReferenceFilter
- Inherits:
-
ReferenceFilter
- Object
- HTML::Pipeline::Filter
- ReferenceFilter
- Banzai::Filter::References::ProjectReferenceFilter
- Defined in:
- lib/banzai/filter/references/project_reference_filter.rb
Overview
HTML filter that replaces project references with links.
Constant Summary
Constants inherited from ReferenceFilter
ReferenceFilter::REFERENCE_TYPE_ATTRIBUTE, ReferenceFilter::REFERENCE_TYPE_DATA_ATTRIBUTE_NAME
Constants included from Concerns::TextReplacer
Concerns::TextReplacer::REFERENCE_PLACEHOLDER, Concerns::TextReplacer::REFERENCE_PLACEHOLDER_PATTERN
Constants included from Concerns::PipelineTimingCheck
Concerns::PipelineTimingCheck::MAX_PIPELINE_SECONDS
Instance Method Summary collapse
-
#references_in(text, pattern = object_reference_pattern) ⇒ Object
Public: Find
namespace/project>project references in text.
Methods inherited from ReferenceFilter
call, #call, #call_and_update_nodes, #each_node, #group, #initialize, #nodes, #nodes?, #object_class, #project, #requires_unescaping?
Methods included from Concerns::TextReplacer
#replace_references_in_text_with_html
Methods included from Concerns::HtmlWriter
Methods included from Concerns::OutputSafety
Methods included from RequestStoreReferenceCache
#cached_call, #get_or_set_cache
Methods included from Concerns::PipelineTimingCheck
#call, #exceeded_pipeline_max?
Constructor Details
This class inherits a constructor from Banzai::Filter::References::ReferenceFilter
Instance Method Details
#references_in(text, pattern = object_reference_pattern) ⇒ Object
Public: Find namespace/project> project references in text
references_in(text) do |match_text, project|
"<a href=...>#{project}></a>"
end
text - String text to search.
Yields the String text match, and the String project name.
Returns a HTML String with replacements made, or nil if no replacements were made.
See ReferenceFilter#references_in for a detailed discussion.
24 25 26 27 28 29 |
# File 'lib/banzai/filter/references/project_reference_filter.rb', line 24 def references_in(text, pattern = object_reference_pattern) replace_references_in_text_with_html(Gitlab::Utils::Gsub.gsub_with_limit(text, pattern, limit: Banzai::Filter::FILTER_ITEM_LIMIT)) do |match_data| yield match_data[0], "#{match_data[:namespace]}/#{match_data[:project]}" end end |