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

69 lines
2.2 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,
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,
2019-09-30 21:07:59 +05:30
Filter::InlineMetricsFilter,
2015-12-23 02:04:40 +05:30
Filter::TableOfContentsFilter,
Filter::AutolinkFilter,
Filter::ExternalLinkFilter,
2019-02-15 15:39:39 +05:30
Filter::SuggestionFilter,
2019-03-02 22:35:43 +05:30
Filter::FootnoteFilter,
2015-12-23 02:04:40 +05:30
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
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
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