Merge branch '58717-checkbox-cannot-be-checked-if-a-blockquote-is-above' into 'master'
Checkbox cannot be checked if preceded by a blockquote Closes #58717 See merge request gitlab-org/gitlab-ce!26937
This commit is contained in:
commit
9bee979872
6 changed files with 49 additions and 3 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Allow task lists that follow a blockquote to work correctly
|
||||||
|
merge_request: 26937
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -42,7 +42,9 @@ module Banzai
|
||||||
def call
|
def call
|
||||||
@text.gsub(REGEX) do
|
@text.gsub(REGEX) do
|
||||||
if $~[:quote]
|
if $~[:quote]
|
||||||
$~[:quote].gsub(/^/, "> ").gsub(/^> $/, ">")
|
# keep the same number of source lines/positions by replacing the
|
||||||
|
# fence lines with newlines
|
||||||
|
"\n" + $~[:quote].gsub(/^/, "> ").gsub(/^> $/, ">") + "\n"
|
||||||
else
|
else
|
||||||
$~[0]
|
$~[0]
|
||||||
end
|
end
|
||||||
|
|
16
spec/fixtures/blockquote_fence_after.md
vendored
16
spec/fixtures/blockquote_fence_after.md
vendored
|
@ -18,10 +18,13 @@ Double `>>>` inside code block:
|
||||||
|
|
||||||
Blockquote outside code block:
|
Blockquote outside code block:
|
||||||
|
|
||||||
|
|
||||||
> Quote
|
> Quote
|
||||||
|
|
||||||
|
|
||||||
Code block inside blockquote:
|
Code block inside blockquote:
|
||||||
|
|
||||||
|
|
||||||
> Quote
|
> Quote
|
||||||
>
|
>
|
||||||
> ```
|
> ```
|
||||||
|
@ -30,8 +33,10 @@ Code block inside blockquote:
|
||||||
>
|
>
|
||||||
> Quote
|
> Quote
|
||||||
|
|
||||||
|
|
||||||
Single `>>>` inside code block inside blockquote:
|
Single `>>>` inside code block inside blockquote:
|
||||||
|
|
||||||
|
|
||||||
> Quote
|
> Quote
|
||||||
>
|
>
|
||||||
> ```
|
> ```
|
||||||
|
@ -42,8 +47,10 @@ Single `>>>` inside code block inside blockquote:
|
||||||
>
|
>
|
||||||
> Quote
|
> Quote
|
||||||
|
|
||||||
|
|
||||||
Double `>>>` inside code block inside blockquote:
|
Double `>>>` inside code block inside blockquote:
|
||||||
|
|
||||||
|
|
||||||
> Quote
|
> Quote
|
||||||
>
|
>
|
||||||
> ```
|
> ```
|
||||||
|
@ -56,6 +63,7 @@ Double `>>>` inside code block inside blockquote:
|
||||||
>
|
>
|
||||||
> Quote
|
> Quote
|
||||||
|
|
||||||
|
|
||||||
Single `>>>` inside HTML:
|
Single `>>>` inside HTML:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
@ -76,10 +84,13 @@ Double `>>>` inside HTML:
|
||||||
|
|
||||||
Blockquote outside HTML:
|
Blockquote outside HTML:
|
||||||
|
|
||||||
|
|
||||||
> Quote
|
> Quote
|
||||||
|
|
||||||
|
|
||||||
HTML inside blockquote:
|
HTML inside blockquote:
|
||||||
|
|
||||||
|
|
||||||
> Quote
|
> Quote
|
||||||
>
|
>
|
||||||
> <pre>
|
> <pre>
|
||||||
|
@ -88,8 +99,10 @@ HTML inside blockquote:
|
||||||
>
|
>
|
||||||
> Quote
|
> Quote
|
||||||
|
|
||||||
|
|
||||||
Single `>>>` inside HTML inside blockquote:
|
Single `>>>` inside HTML inside blockquote:
|
||||||
|
|
||||||
|
|
||||||
> Quote
|
> Quote
|
||||||
>
|
>
|
||||||
> <pre>
|
> <pre>
|
||||||
|
@ -100,8 +113,10 @@ Single `>>>` inside HTML inside blockquote:
|
||||||
>
|
>
|
||||||
> Quote
|
> Quote
|
||||||
|
|
||||||
|
|
||||||
Double `>>>` inside HTML inside blockquote:
|
Double `>>>` inside HTML inside blockquote:
|
||||||
|
|
||||||
|
|
||||||
> Quote
|
> Quote
|
||||||
>
|
>
|
||||||
> <pre>
|
> <pre>
|
||||||
|
@ -113,3 +128,4 @@ Double `>>>` inside HTML inside blockquote:
|
||||||
> </pre>
|
> </pre>
|
||||||
>
|
>
|
||||||
> Quote
|
> Quote
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,6 @@ describe Banzai::Filter::BlockquoteFenceFilter do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows trailing whitespace on blockquote fence lines' do
|
it 'allows trailing whitespace on blockquote fence lines' do
|
||||||
expect(filter(">>> \ntest\n>>> ")).to eq("> test")
|
expect(filter(">>> \ntest\n>>> ")).to eq("\n> test\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,8 +58,10 @@ describe Issues::BuildService do
|
||||||
"> That has a quote\n"\
|
"> That has a quote\n"\
|
||||||
">>>\n"
|
">>>\n"
|
||||||
note_result = " > This is a string\n"\
|
note_result = " > This is a string\n"\
|
||||||
|
" > \n"\
|
||||||
" > > with a blockquote\n"\
|
" > > with a blockquote\n"\
|
||||||
" > > > That has a quote\n"
|
" > > > That has a quote\n"\
|
||||||
|
" > \n"
|
||||||
discussion = create(:diff_note_on_merge_request, note: note_text).to_discussion
|
discussion = create(:diff_note_on_merge_request, note: note_text).to_discussion
|
||||||
expect(service.item_for_discussion(discussion)).to include(note_result)
|
expect(service.item_for_discussion(discussion)).to include(note_result)
|
||||||
end
|
end
|
||||||
|
|
|
@ -113,4 +113,25 @@ describe TaskListToggleService do
|
||||||
|
|
||||||
expect(toggler.execute).to be_falsey
|
expect(toggler.execute).to be_falsey
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'properly handles a GitLab blockquote' do
|
||||||
|
markdown =
|
||||||
|
<<-EOT.strip_heredoc
|
||||||
|
>>>
|
||||||
|
gitlab blockquote
|
||||||
|
>>>
|
||||||
|
|
||||||
|
* [ ] Task 1
|
||||||
|
* [x] Task 2
|
||||||
|
EOT
|
||||||
|
|
||||||
|
markdown_html = Banzai::Pipeline::FullPipeline.call(markdown, project: nil)[:output].to_html
|
||||||
|
toggler = described_class.new(markdown, markdown_html,
|
||||||
|
toggle_as_checked: true,
|
||||||
|
line_source: '* [ ] Task 1', line_number: 5)
|
||||||
|
|
||||||
|
expect(toggler.execute).to be_truthy
|
||||||
|
expect(toggler.updated_markdown.lines[4]).to eq "* [x] Task 1\n"
|
||||||
|
expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue