Class: Banzai::Pipeline::GfmPipeline

Inherits:
BasePipeline show all
Defined in:
lib/banzai/pipeline/gfm_pipeline.rb

Direct Known Subclasses

SingleLinePipeline

Class Method Summary collapse

Methods inherited from BasePipeline

html_pipeline

Class Method Details

.filtersObject

These filters transform GitLab Flavored Markdown (GFM) to HTML. The nodes and marks referenced in app/assets/javascripts/behaviors/markdown/editor_extensions.js consequently transform that same HTML to GFM to be copied to the clipboard. Every filter that generates HTML from GFM should have a node or mark in app/assets/javascripts/behaviors/markdown/editor_extensions.js. The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.


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
# File 'lib/banzai/pipeline/gfm_pipeline.rb', line 12

def self.filters
  @filters ||= FilterArray[
    Filter::PlantumlFilter,
    # Must always be before the SanitizationFilter to prevent XSS attacks
    Filter::SpacedLinkFilter,
    Filter::SanitizationFilter,
    Filter::KrokiFilter,
    Filter::AssetProxyFilter,
    Filter::SyntaxHighlightFilter,
    Filter::MathFilter,
    Filter::ColorFilter,
    Filter::MermaidFilter,
    Filter::VideoLinkFilter,
    Filter::AudioLinkFilter,
    Filter::ImageLazyLoadFilter,
    Filter::ImageLinkFilter,
    *metrics_filters,
    Filter::TableOfContentsFilter,
    Filter::TableOfContentsTagFilter,
    Filter::AutolinkFilter,
    Filter::ExternalLinkFilter,
    Filter::SuggestionFilter,
    Filter::FootnoteFilter,
    *reference_filters,
    Filter::EmojiFilter,
    Filter::CustomEmojiFilter,
    Filter::TaskListFilter,
    Filter::InlineDiffFilter,
    Filter::SetDirectionFilter
  ]
end

.metrics_filtersObject


44
45
46
47
48
49
50
# File 'lib/banzai/pipeline/gfm_pipeline.rb', line 44

def self.metrics_filters
  [
    Filter::InlineMetricsFilter,
    Filter::InlineGrafanaMetricsFilter,
    Filter::InlineClusterMetricsFilter
  ]
end

.reference_filtersObject


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/banzai/pipeline/gfm_pipeline.rb', line 52

def self.reference_filters
  [
    Filter::References::UserReferenceFilter,
    Filter::References::ProjectReferenceFilter,
    Filter::References::DesignReferenceFilter,
    Filter::References::IssueReferenceFilter,
    Filter::References::ExternalIssueReferenceFilter,
    Filter::References::MergeRequestReferenceFilter,
    Filter::References::SnippetReferenceFilter,
    Filter::References::CommitRangeReferenceFilter,
    Filter::References::CommitReferenceFilter,
    Filter::References::LabelReferenceFilter,
    Filter::References::MilestoneReferenceFilter,
    Filter::References::AlertReferenceFilter,
    Filter::References::FeatureFlagReferenceFilter
  ]
end

.transform_context(context) ⇒ Object


70
71
72
73
74
# File 'lib/banzai/pipeline/gfm_pipeline.rb', line 70

def self.transform_context(context)
  context[:only_path] = true unless context.key?(:only_path)

  Filter::AssetProxyFilter.transform_context(context)
end