Class: Banzai::Filter::WikiLinkGollumFilter
- Inherits:
-
HTML::Pipeline::Filter
- Object
- HTML::Pipeline::Filter
- Banzai::Filter::WikiLinkGollumFilter
- Includes:
- Concerns::PipelineTimingCheck
- Defined in:
- lib/banzai/filter/wiki_link_gollum_filter.rb
Overview
HTML Filter for handling Gollum style wiki links. Links have already been recognized and tagged with ‘data-wikilink=“true”` by the markdown parser. This filter adds our classes and checks if they are valid links, and converts to image tags if they link to images.
Currently supported syntax:
-
Link to internal pages:
- [Bug Reports]
- [How to Contribute|Contributing]
-
Link to external resources:
-
Link internal images, gollum special attributes not supported
- [images/logo.png]
-
Link external images, gollum special attributes not supported
- [
]
- [
Constant Summary collapse
- ALLOWED_IMAGE_EXTENSIONS =
Pattern to match allowed image extensions
/(jpg|png|gif|svg|bmp)\z/i- CSS_WIKILINK_STYLE =
'a[href][data-wikilink]'- XPATH_WIKILINK_STYLE =
Gitlab::Utils::Nokogiri.css_to_xpath(CSS_WIKILINK_STYLE).freeze
- IMAGE_LINK_LIMIT =
100
Constants included from Concerns::PipelineTimingCheck
Concerns::PipelineTimingCheck::MAX_PIPELINE_SECONDS
Instance Method Summary collapse
Methods included from Concerns::PipelineTimingCheck
Instance Method Details
#call ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/banzai/filter/wiki_link_gollum_filter.rb', line 40 def call @image_link_count = 0 doc.xpath(XPATH_WIKILINK_STYLE).each_with_index do |node, index| break if Banzai::Filter.filter_item_limit_exceeded?(index) process_image_link(node) || process_page_link(node) end doc end |