summaryrefslogtreecommitdiff
path: root/lib/banzai/pipeline/gfm_pipeline.rb
blob: b25d6f18d599a0d5ae9feaac6c9f69102a53fcc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module Banzai
  module Pipeline
    class GfmPipeline < BasePipeline
      # These filters convert GitLab Flavored Markdown (GFM) to HTML.
      # The handlers defined in app/assets/javascripts/copy_as_gfm.js.es6
      # 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
      # app/assets/javascripts/copy_as_gfm.js.es6, in reverse order.
      # The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.
      def self.filters
        @filters ||= FilterArray[
          Filter::SyntaxHighlightFilter,
          Filter::PlantumlFilter,
          Filter::SanitizationFilter,

          Filter::MathFilter,
          Filter::UploadLinkFilter,
          Filter::VideoLinkFilter,
          Filter::ImageLinkFilter,
          Filter::EmojiFilter,
          Filter::TableOfContentsFilter,
          Filter::AutolinkFilter,
          Filter::ExternalLinkFilter,

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

          Filter::TaskListFilter,
          Filter::InlineDiffFilter,

          Filter::SetDirectionFilter
        ]
      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