2018-10-06 19:10:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-15 09:51:16 -05:00
|
|
|
module Banzai
|
|
|
|
module Pipeline
|
|
|
|
class GfmPipeline < BasePipeline
|
2019-01-23 06:21:12 -05:00
|
|
|
# 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.
|
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.
|
2015-12-15 09:51:16 -05:00
|
|
|
def self.filters
|
2016-03-01 15:54:35 -05:00
|
|
|
@filters ||= FilterArray[
|
2017-01-15 19:07:02 -05:00
|
|
|
Filter::PlantumlFilter,
|
2018-11-28 14:02:01 -05:00
|
|
|
|
|
|
|
# Must always be before the SanitizationFilter to prevent XSS attacks
|
|
|
|
Filter::SpacedLinkFilter,
|
|
|
|
|
2015-12-15 09:51:16 -05:00
|
|
|
Filter::SanitizationFilter,
|
2017-04-02 13:39:41 -04:00
|
|
|
Filter::SyntaxHighlightFilter,
|
2015-12-15 09:51:16 -05:00
|
|
|
|
2016-12-08 19:15:08 -05:00
|
|
|
Filter::MathFilter,
|
2017-12-20 06:39:40 -05:00
|
|
|
Filter::ColorFilter,
|
2017-11-21 22:12:04 -05:00
|
|
|
Filter::MermaidFilter,
|
2016-04-03 01:00:06 -04:00
|
|
|
Filter::VideoLinkFilter,
|
2017-07-24 13:36:52 -04:00
|
|
|
Filter::ImageLazyLoadFilter,
|
2016-07-12 13:31:20 -04:00
|
|
|
Filter::ImageLinkFilter,
|
2015-12-15 09:51:16 -05:00
|
|
|
Filter::EmojiFilter,
|
|
|
|
Filter::TableOfContentsFilter,
|
|
|
|
Filter::AutolinkFilter,
|
|
|
|
Filter::ExternalLinkFilter,
|
2018-12-13 14:17:19 -05:00
|
|
|
Filter::SuggestionFilter,
|
2019-01-04 21:54:02 -05:00
|
|
|
Filter::FootnoteFilter,
|
2015-12-15 09:51:16 -05:00
|
|
|
|
2018-07-13 06:32:49 -04:00
|
|
|
*reference_filters,
|
|
|
|
|
|
|
|
Filter::TaskListFilter,
|
|
|
|
Filter::InlineDiffFilter,
|
|
|
|
|
|
|
|
Filter::SetDirectionFilter
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reference_filters
|
|
|
|
[
|
2015-12-15 09:51:16 -05:00
|
|
|
Filter::UserReferenceFilter,
|
2018-06-30 05:17:03 -04:00
|
|
|
Filter::ProjectReferenceFilter,
|
2015-12-15 09:51:16 -05:00
|
|
|
Filter::IssueReferenceFilter,
|
|
|
|
Filter::ExternalIssueReferenceFilter,
|
|
|
|
Filter::MergeRequestReferenceFilter,
|
|
|
|
Filter::SnippetReferenceFilter,
|
|
|
|
Filter::CommitRangeReferenceFilter,
|
|
|
|
Filter::CommitReferenceFilter,
|
|
|
|
Filter::LabelReferenceFilter,
|
2018-07-13 06:32:49 -04:00
|
|
|
Filter::MilestoneReferenceFilter
|
2015-12-15 09:51:16 -05:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.transform_context(context)
|
2018-05-18 06:25:59 -04:00
|
|
|
context[:only_path] = true unless context.key?(:only_path)
|
2015-12-15 09:51:16 -05:00
|
|
|
|
2018-06-29 05:21:13 -04:00
|
|
|
context
|
2015-12-15 09:51:16 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|