2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
module Banzai
|
|
|
|
module Pipeline
|
|
|
|
class GfmPipeline < BasePipeline
|
2017-08-17 22:00:37 +05:30
|
|
|
# These filters convert GitLab Flavored Markdown (GFM) to HTML.
|
2018-05-09 12:01:36 +05:30
|
|
|
# The handlers defined in app/assets/javascripts/behaviors/markdown/copy_as_gfm.js
|
2017-08-17 22:00:37 +05:30
|
|
|
# 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
|
2018-05-09 12:01:36 +05:30
|
|
|
# app/assets/javascripts/behaviors/markdown/copy_as_gfm.js, in reverse order.
|
2017-08-17 22:00:37 +05:30
|
|
|
# The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.
|
2015-12-23 02:04:40 +05:30
|
|
|
def self.filters
|
2016-06-02 11:05:42 +05:30
|
|
|
@filters ||= FilterArray[
|
2017-08-17 22:00:37 +05:30
|
|
|
Filter::PlantumlFilter,
|
2018-11-29 20:51:05 +05:30
|
|
|
|
|
|
|
# Must always be before the SanitizationFilter to prevent XSS attacks
|
|
|
|
Filter::SpacedLinkFilter,
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
Filter::SanitizationFilter,
|
2017-08-17 22:00:37 +05:30
|
|
|
Filter::SyntaxHighlightFilter,
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
Filter::MathFilter,
|
2018-03-17 18:26:18 +05:30
|
|
|
Filter::ColorFilter,
|
|
|
|
Filter::MermaidFilter,
|
2016-08-24 12:49:21 +05:30
|
|
|
Filter::VideoLinkFilter,
|
2017-09-10 17:25:29 +05:30
|
|
|
Filter::ImageLazyLoadFilter,
|
2016-06-02 11:05:42 +05:30
|
|
|
Filter::ImageLinkFilter,
|
2015-12-23 02:04:40 +05:30
|
|
|
Filter::EmojiFilter,
|
|
|
|
Filter::TableOfContentsFilter,
|
|
|
|
Filter::AutolinkFilter,
|
|
|
|
Filter::ExternalLinkFilter,
|
2019-02-13 22:33:31 +05:30
|
|
|
Filter::SuggestionFilter,
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
*reference_filters,
|
|
|
|
|
|
|
|
Filter::TaskListFilter,
|
|
|
|
Filter::InlineDiffFilter,
|
|
|
|
|
|
|
|
Filter::SetDirectionFilter
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reference_filters
|
|
|
|
[
|
2015-12-23 02:04:40 +05:30
|
|
|
Filter::UserReferenceFilter,
|
2018-11-20 20:47:30 +05:30
|
|
|
Filter::ProjectReferenceFilter,
|
2015-12-23 02:04:40 +05:30
|
|
|
Filter::IssueReferenceFilter,
|
|
|
|
Filter::ExternalIssueReferenceFilter,
|
|
|
|
Filter::MergeRequestReferenceFilter,
|
|
|
|
Filter::SnippetReferenceFilter,
|
|
|
|
Filter::CommitRangeReferenceFilter,
|
|
|
|
Filter::CommitReferenceFilter,
|
|
|
|
Filter::LabelReferenceFilter,
|
2018-11-18 11:00:15 +05:30
|
|
|
Filter::MilestoneReferenceFilter
|
2015-12-23 02:04:40 +05:30
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.transform_context(context)
|
2018-11-08 19:23:39 +05:30
|
|
|
context[:only_path] = true unless context.key?(:only_path)
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
context
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|