gitlab-org--gitlab-foss/lib/banzai/pipeline/gfm_pipeline.rb

62 lines
1.9 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Banzai
module Pipeline
class GfmPipeline < BasePipeline
2017-01-16 18:11:15 -05:00
# These filters convert GitLab Flavored Markdown (GFM) to HTML.
# The handlers defined in app/assets/javascripts/behaviors/markdown/copy_as_gfm.js
# 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/behaviors/markdown/copy_as_gfm.js, in reverse order.
2017-01-16 18:11:15 -05:00
# The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.
def self.filters
2016-03-01 15:54:35 -05:00
@filters ||= FilterArray[
Filter::PlantumlFilter,
Filter::SanitizationFilter,
Filter::SyntaxHighlightFilter,
Filter::MathFilter,
2017-12-20 06:39:40 -05:00
Filter::ColorFilter,
2017-11-21 22:12:04 -05:00
Filter::MermaidFilter,
Filter::SpacedLinkFilter,
Filter::VideoLinkFilter,
Filter::ImageLazyLoadFilter,
Filter::ImageLinkFilter,
Filter::EmojiFilter,
Filter::TableOfContentsFilter,
Filter::AutolinkFilter,
Filter::ExternalLinkFilter,
*reference_filters,
Filter::TaskListFilter,
Filter::InlineDiffFilter,
Filter::SetDirectionFilter
]
end
def self.reference_filters
[
Filter::UserReferenceFilter,
Filter::ProjectReferenceFilter,
Filter::IssueReferenceFilter,
Filter::ExternalIssueReferenceFilter,
Filter::MergeRequestReferenceFilter,
Filter::SnippetReferenceFilter,
Filter::CommitRangeReferenceFilter,
Filter::CommitReferenceFilter,
Filter::LabelReferenceFilter,
Filter::MilestoneReferenceFilter
]
end
def self.transform_context(context)
context[:only_path] = true unless context.key?(:only_path)
context
end
end
end
end