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
|
2019-03-02 22:35:43 +05:30
|
|
|
# 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-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,
|
2022-06-21 17:19:12 +05:30
|
|
|
Filter::KrokiFilter,
|
2019-09-04 21:01:54 +05:30
|
|
|
Filter::AssetProxyFilter,
|
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,
|
2019-12-21 20:55:43 +05:30
|
|
|
Filter::AudioLinkFilter,
|
2023-03-04 22:38:38 +05:30
|
|
|
Filter::AttributesFilter,
|
2017-09-10 17:25:29 +05:30
|
|
|
Filter::ImageLazyLoadFilter,
|
2016-06-02 11:05:42 +05:30
|
|
|
Filter::ImageLinkFilter,
|
2020-04-08 14:13:33 +05:30
|
|
|
*metrics_filters,
|
2015-12-23 02:04:40 +05:30
|
|
|
Filter::TableOfContentsFilter,
|
2020-03-13 15:44:24 +05:30
|
|
|
Filter::TableOfContentsTagFilter,
|
2015-12-23 02:04:40 +05:30
|
|
|
Filter::AutolinkFilter,
|
|
|
|
Filter::ExternalLinkFilter,
|
2019-02-15 15:39:39 +05:30
|
|
|
Filter::SuggestionFilter,
|
2019-03-02 22:35:43 +05:30
|
|
|
Filter::FootnoteFilter,
|
2018-11-18 11:00:15 +05:30
|
|
|
*reference_filters,
|
2019-09-04 21:01:54 +05:30
|
|
|
Filter::EmojiFilter,
|
2021-03-11 19:13:27 +05:30
|
|
|
Filter::CustomEmojiFilter,
|
2018-11-18 11:00:15 +05:30
|
|
|
Filter::TaskListFilter,
|
|
|
|
Filter::InlineDiffFilter,
|
2023-03-04 22:38:38 +05:30
|
|
|
Filter::InlineObservabilityFilter,
|
2023-01-13 00:05:48 +05:30
|
|
|
Filter::SetDirectionFilter,
|
2023-03-04 22:38:38 +05:30
|
|
|
Filter::SyntaxHighlightFilter # this filter should remain at the end
|
2018-11-18 11:00:15 +05:30
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
def self.metrics_filters
|
|
|
|
[
|
|
|
|
Filter::InlineMetricsFilter,
|
2020-07-28 23:09:34 +05:30
|
|
|
Filter::InlineGrafanaMetricsFilter,
|
|
|
|
Filter::InlineClusterMetricsFilter
|
2020-04-08 14:13:33 +05:30
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
def self.reference_filters
|
|
|
|
[
|
2021-04-29 21:17:54 +05:30
|
|
|
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
|
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
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
Filter::AssetProxyFilter.transform_context(context)
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
Banzai::Pipeline::GfmPipeline.prepend_mod_with('Banzai::Pipeline::GfmPipeline')
|