Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mermaid_filter.rb « filter « banzai « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aaaf851ccf078440937c0ca3ba7d0f227971568c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

# Generated HTML is transformed back to GFM by app/assets/javascripts/behaviors/markdown/nodes/code_block.js
module Banzai
  module Filter
    class MermaidFilter < HTML::Pipeline::Filter
      CSS   = 'pre[lang="mermaid"] > code'
      XPATH = Gitlab::Utils::Nokogiri.css_to_xpath(CSS).freeze

      def call
        doc.xpath(XPATH).add_class('js-render-mermaid')

        doc
      end
    end
  end
end