debian-mirror-gitlab/lib/banzai/pipeline/gfm_pipeline.rb

78 lines
2.6 KiB
Ruby
Raw Normal View History

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,
2019-09-04 21:01:54 +05:30
Filter::AssetProxyFilter,
2017-08-17 22:00:37 +05:30
Filter::SyntaxHighlightFilter,
Filter::MathFilter,
2018-03-17 18:26:18 +05:30
Filter::ColorFilter,
2021-02-22 17:27:13 +05:30
Filter::KrokiFilter,
2018-03-17 18:26:18 +05:30
Filter::MermaidFilter,
2016-08-24 12:49:21 +05:30
Filter::VideoLinkFilter,
2019-12-21 20:55:43 +05:30
Filter::AudioLinkFilter,
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,
2018-11-18 11:00:15 +05:30
Filter::TaskListFilter,
Filter::InlineDiffFilter,
Filter::SetDirectionFilter
]
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
[
2015-12-23 02:04:40 +05:30
Filter::UserReferenceFilter,
2018-11-20 20:47:30 +05:30
Filter::ProjectReferenceFilter,
2020-06-23 00:09:42 +05:30
Filter::DesignReferenceFilter,
2015-12-23 02:04:40 +05:30
Filter::IssueReferenceFilter,
Filter::ExternalIssueReferenceFilter,
Filter::MergeRequestReferenceFilter,
Filter::SnippetReferenceFilter,
Filter::CommitRangeReferenceFilter,
Filter::CommitReferenceFilter,
Filter::LabelReferenceFilter,
2020-11-24 15:15:51 +05:30
Filter::MilestoneReferenceFilter,
Filter::AlertReferenceFilter
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
Banzai::Pipeline::GfmPipeline.prepend_if_ee('EE::Banzai::Pipeline::GfmPipeline')