Skip to content
Snippets Groups Projects
Commit da6b6936 authored by Marc Shaw's avatar Marc Shaw :two:
Browse files

Merge branch '331519-multi-line-blockquoting-does-not-work-in-lists' into 'master'

Support GitLab multi-line blockquoting inside lists

See merge request gitlab-org/gitlab!96188



Merged-by: default avatarMarc Shaw <mshaw@gitlab.com>
Approved-by: default avatarTianwen Chen <tchen@gitlab.com>
Approved-by: default avatarMarc Shaw <mshaw@gitlab.com>
Co-authored-by: default avatarBrett Walker <bwalker@gitlab.com>
parents bb4198b0 615ae8cd
No related branches found
No related tags found
No related merge requests found
Pipeline #766320968 failed
......@@ -6,14 +6,14 @@ class BlockquoteFenceFilter < HTML::Pipeline::TextFilter
REGEX = %r{
#{::Gitlab::Regex.markdown_code_or_html_blocks}
|
(?=(?<=^\n|\A)>>>\ *\n.*\n>>>\ *(?=\n$|\z))(?:
(?=(?<=^\n|\A)\ *>>>\ *\n.*\n\ *>>>\ *(?=\n$|\z))(?:
# Blockquote:
# >>>
# Anything, including code and HTML blocks
# >>>
(?<=^\n|\A)>>>\ *\n
(?<quote>
(?<=^\n|\A)(?<indent>\ *)>>>\ *\n
(?<blockquote>
(?:
# Any character that doesn't introduce a code or HTML block
(?!
......@@ -30,7 +30,7 @@ class BlockquoteFenceFilter < HTML::Pipeline::TextFilter
\g<html>
)+?
)
\n>>>\ *(?=\n$|\z)
\n\ *>>>\ *(?=\n$|\z)
)
}mx.freeze
......@@ -41,10 +41,11 @@ def initialize(text, context = nil, result = nil)
def call
@text.gsub(REGEX) do
if $~[:quote]
if $~[:blockquote]
# keep the same number of source lines/positions by replacing the
# fence lines with newlines
"\n" + $~[:quote].gsub(/^/, "> ").gsub(/^> $/, ">") + "\n"
indent = $~[:indent]
"\n" + $~[:blockquote].gsub(/^#{Regexp.quote(indent)}/, "#{indent}> ").gsub(/^> $/, ">") + "\n"
else
$~[0]
end
......
......@@ -130,6 +130,35 @@ Double `>>>` inside HTML inside blockquote:
> Quote
Blockquote inside an unordered list
- Item one
> Foo and
> bar
- Sub item
> Foo
Blockquote inside an ordered list
1. Item one
> Bar
1. Sub item
> Foo
Requires a leading blank line
>>>
Not a quote
......
......@@ -130,6 +130,35 @@ Quote
Quote
>>>
Blockquote inside an unordered list
- Item one
>>>
Foo and
bar
>>>
- Sub item
>>>
Foo
>>>
Blockquote inside an ordered list
1. Item one
>>>
Bar
>>>
1. Sub item
>>>
Foo
>>>
Requires a leading blank line
>>>
Not a quote
......
......@@ -5,7 +5,7 @@
RSpec.describe Banzai::Filter::BlockquoteFenceFilter, feature_category: :team_planning do
include FilterSpecHelper
it 'converts blockquote fences to blockquote lines' do
it 'converts blockquote fences to blockquote lines', :unlimited_max_formatted_output_length do
content = File.read(Rails.root.join('spec/fixtures/blockquote_fence_before.md'))
expected = File.read(Rails.root.join('spec/fixtures/blockquote_fence_after.md'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment