Class: Banzai::Filter::ColorFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Defined in:
lib/banzai/filter/color_filter.rb

Overview

HTML filter that renders `color` followed by a color “chip”.

Constant Summary collapse

COLOR_CHIP_CLASS =
'gfm-color_chip'
CSS =
'code'
XPATH =
Gitlab::Utils::Nokogiri.css_to_xpath(CSS).freeze

Instance Method Summary collapse

Instance Method Details

#callObject


13
14
15
16
17
18
19
20
# File 'lib/banzai/filter/color_filter.rb', line 13

def call
  doc.xpath(XPATH).each do |node|
    color = ColorParser.parse(node.content)
    node << color_chip(color) if color
  end

  doc
end