Class: Banzai::Filter::WikiLinkGollumFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
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:

Constant Summary collapse

ALLOWED_IMAGE_EXTENSIONS =

Pattern to match allowed image extensions

/(jpg|png|gif|svg|bmp)\z/i
'a[href][data-wikilink]'
Gitlab::Utils::Nokogiri.css_to_xpath(CSS_WIKILINK_STYLE).freeze
100

Constants included from Concerns::PipelineTimingCheck

Concerns::PipelineTimingCheck::MAX_PIPELINE_SECONDS

Instance Method Summary collapse

Methods included from Concerns::PipelineTimingCheck

#exceeded_pipeline_max?

Instance Method Details

#callObject



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