1617aa2756
If we put the emoji filter before the reference filters, each emoji will
have a wrapper element that prevents the reference filter from detecting
the presence of the emoji.
As the emoji filter now runs after the reference filters, references
must contain a literal emoji, not the GitLab Flavored Markdown
versions (:100`, for example).
A weird side-effect is that if you have a label with the 100 emoji, and
a label named 💯, then trying to reference the latter will work (link
to the correct label), but will render with the 100 emoji. I'm
comfortable with that edge case, I think.
66 lines
2.1 KiB
Ruby
66 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Banzai
|
|
module Pipeline
|
|
class GfmPipeline < BasePipeline
|
|
# 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.
|
|
# The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.
|
|
def self.filters
|
|
@filters ||= FilterArray[
|
|
Filter::PlantumlFilter,
|
|
|
|
# Must always be before the SanitizationFilter to prevent XSS attacks
|
|
Filter::SpacedLinkFilter,
|
|
|
|
Filter::SanitizationFilter,
|
|
Filter::SyntaxHighlightFilter,
|
|
|
|
Filter::MathFilter,
|
|
Filter::ColorFilter,
|
|
Filter::MermaidFilter,
|
|
Filter::VideoLinkFilter,
|
|
Filter::ImageLazyLoadFilter,
|
|
Filter::ImageLinkFilter,
|
|
Filter::TableOfContentsFilter,
|
|
Filter::AutolinkFilter,
|
|
Filter::ExternalLinkFilter,
|
|
Filter::SuggestionFilter,
|
|
Filter::FootnoteFilter,
|
|
|
|
*reference_filters,
|
|
|
|
Filter::EmojiFilter,
|
|
Filter::TaskListFilter,
|
|
Filter::InlineDiffFilter,
|
|
|
|
Filter::SetDirectionFilter
|
|
]
|
|
end
|
|
|
|
def self.reference_filters
|
|
[
|
|
Filter::UserReferenceFilter,
|
|
Filter::ProjectReferenceFilter,
|
|
Filter::IssueReferenceFilter,
|
|
Filter::ExternalIssueReferenceFilter,
|
|
Filter::MergeRequestReferenceFilter,
|
|
Filter::SnippetReferenceFilter,
|
|
Filter::CommitRangeReferenceFilter,
|
|
Filter::CommitReferenceFilter,
|
|
Filter::LabelReferenceFilter,
|
|
Filter::MilestoneReferenceFilter
|
|
]
|
|
end
|
|
|
|
def self.transform_context(context)
|
|
context[:only_path] = true unless context.key?(:only_path)
|
|
|
|
context
|
|
end
|
|
end
|
|
end
|
|
end
|