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
|
||||
@text.gsub(REGEX) do
|
||||
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
|
||||
$~[0]
|
||||
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:
|
||||
|
||||
|
||||
> Quote
|
||||
|
||||
|
||||
Code block inside blockquote:
|
||||
|
||||
|
||||
> Quote
|
||||
>
|
||||
> ```
|
||||
|
@ -30,8 +33,10 @@ Code block inside blockquote:
|
|||
>
|
||||
> Quote
|
||||
|
||||
|
||||
Single `>>>` inside code block inside blockquote:
|
||||
|
||||
|
||||
> Quote
|
||||
>
|
||||
> ```
|
||||
|
@ -42,8 +47,10 @@ Single `>>>` inside code block inside blockquote:
|
|||
>
|
||||
> Quote
|
||||
|
||||
|
||||
Double `>>>` inside code block inside blockquote:
|
||||
|
||||
|
||||
> Quote
|
||||
>
|
||||
> ```
|
||||
|
@ -56,6 +63,7 @@ Double `>>>` inside code block inside blockquote:
|
|||
>
|
||||
> Quote
|
||||
|
||||
|
||||
Single `>>>` inside HTML:
|
||||
|
||||
<pre>
|
||||
|
@ -76,10 +84,13 @@ Double `>>>` inside HTML:
|
|||
|
||||
Blockquote outside HTML:
|
||||
|
||||
|
||||
> Quote
|
||||
|
||||
|
||||
HTML inside blockquote:
|
||||
|
||||
|
||||
> Quote
|
||||
>
|
||||
> <pre>
|
||||
|
@ -88,8 +99,10 @@ HTML inside blockquote:
|
|||
>
|
||||
> Quote
|
||||
|
||||
|
||||
Single `>>>` inside HTML inside blockquote:
|
||||
|
||||
|
||||
> Quote
|
||||
>
|
||||
> <pre>
|
||||
|
@ -100,8 +113,10 @@ Single `>>>` inside HTML inside blockquote:
|
|||
>
|
||||
> Quote
|
||||
|
||||
|
||||
Double `>>>` inside HTML inside blockquote:
|
||||
|
||||
|
||||
> Quote
|
||||
>
|
||||
> <pre>
|
||||
|
@ -113,3 +128,4 @@ Double `>>>` inside HTML inside blockquote:
|
|||
> </pre>
|
||||
>
|
||||
> Quote
|
||||
|
||||
|
|
|
@ -13,6 +13,6 @@ describe Banzai::Filter::BlockquoteFenceFilter do
|
|||
end
|
||||
|
||||
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
|
||||
|
|
|
@ -58,8 +58,10 @@ describe Issues::BuildService do
|
|||
"> That has a quote\n"\
|
||||
">>>\n"
|
||||
note_result = " > This is a string\n"\
|
||||
" > \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
|
||||
expect(service.item_for_discussion(discussion)).to include(note_result)
|
||||
end
|
||||
|
|
|
@ -113,4 +113,25 @@ describe TaskListToggleService do
|
|||
|
||||
expect(toggler.execute).to be_falsey
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue