debian-mirror-gitlab/lib/banzai/filter/ascii_doc_post_processing_filter.rb

25 lines
649 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module Banzai
module Filter
class AsciiDocPostProcessingFilter < HTML::Pipeline::Filter
2021-06-02 17:11:27 +05:30
CSS_MATH = '[data-math-style]'
XPATH_MATH = Gitlab::Utils::Nokogiri.css_to_xpath(CSS_MATH).freeze
CSS_MERM = '[data-mermaid-style]'
XPATH_MERM = Gitlab::Utils::Nokogiri.css_to_xpath(CSS_MERM).freeze
2017-09-10 17:25:29 +05:30
def call
2021-06-02 17:11:27 +05:30
doc.xpath(XPATH_MATH).each do |node|
2017-09-10 17:25:29 +05:30
node.set_attribute('class', 'code math js-render-math')
end
2021-06-02 17:11:27 +05:30
doc.xpath(XPATH_MERM).each do |node|
2020-10-24 23:57:45 +05:30
node.set_attribute('class', 'js-render-mermaid')
end
2021-06-02 17:11:27 +05:30
2017-09-10 17:25:29 +05:30
doc
end
end
end
end