gfm_pipeline.rb 1.75 KB
Newer Older
1 2 3
module Banzai
  module Pipeline
    class GfmPipeline < BasePipeline
Douwe Maan's avatar
Douwe Maan committed
4
      # These filters convert GitLab Flavored Markdown (GFM) to HTML.
5
      # The handlers defined in app/assets/javascripts/copy_as_gfm.js
6 7
      # consequently convert that same HTML to GFM to be copied to the clipboard.
      # Every filter that generates HTML from GFM should have a handler in
8
      # app/assets/javascripts/copy_as_gfm.js, in reverse order.
Douwe Maan's avatar
Douwe Maan committed
9
      # The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.
10
      def self.filters
11
        @filters ||= FilterArray[
12
          Filter::PlantumlFilter,
13
          Filter::SanitizationFilter,
14
          Filter::SyntaxHighlightFilter,
15

16
          Filter::MathFilter,
17
          Filter::UploadLinkFilter,
18
          Filter::VideoLinkFilter,
19
          Filter::ImageLazyLoadFilter,
20
          Filter::ImageLinkFilter,
21 22 23 24 25 26 27 28 29 30 31 32 33
          Filter::EmojiFilter,
          Filter::TableOfContentsFilter,
          Filter::AutolinkFilter,
          Filter::ExternalLinkFilter,

          Filter::UserReferenceFilter,
          Filter::IssueReferenceFilter,
          Filter::ExternalIssueReferenceFilter,
          Filter::MergeRequestReferenceFilter,
          Filter::SnippetReferenceFilter,
          Filter::CommitRangeReferenceFilter,
          Filter::CommitReferenceFilter,
          Filter::LabelReferenceFilter,
34
          Filter::MilestoneReferenceFilter,
35

36
          Filter::TaskListFilter,
37 38 39
          Filter::InlineDiffFilter,

          Filter::SetDirectionFilter
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
        ]
      end

      def self.transform_context(context)
        context.merge(
          only_path: true,

          # EmojiFilter
          asset_host: Gitlab::Application.config.asset_host,
          asset_root: Gitlab.config.gitlab.base_url
        )
      end
    end
  end
end