diff options
author | Brett Walker <bwalker@gitlab.com> | 2019-04-03 16:42:23 +0300 |
---|---|---|
committer | Brett Walker <bwalker@gitlab.com> | 2019-04-05 02:59:31 +0300 |
commit | 949bcb1f8d9695171d0dc88461f6a16800ac57c9 (patch) | |
tree | 2716c2263861178b7ddd366f336700d40a73c35a /spec | |
parent | 3ccb4d954f4c51f4f3cc77ebd53f21425e0d4d09 (diff) |
Fenced blockquotes to not change source line pos
Replaces blockquote fences with \n,
keeping the line numbering intact.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fixtures/blockquote_fence_after.md | 16 | ||||
-rw-r--r-- | spec/lib/banzai/filter/blockquote_fence_filter_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/issues/build_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/task_list_toggle_service_spec.rb | 21 |
4 files changed, 41 insertions, 2 deletions
diff --git a/spec/fixtures/blockquote_fence_after.md b/spec/fixtures/blockquote_fence_after.md index 2652a842c0e..555905bf07e 100644 --- a/spec/fixtures/blockquote_fence_after.md +++ b/spec/fixtures/blockquote_fence_after.md @@ -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 + diff --git a/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb b/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb index b645e49bd43..5b3f679084e 100644 --- a/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb +++ b/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb @@ -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 diff --git a/spec/services/issues/build_service_spec.rb b/spec/services/issues/build_service_spec.rb index 86e58fe06b9..74f1e83b362 100644 --- a/spec/services/issues/build_service_spec.rb +++ b/spec/services/issues/build_service_spec.rb @@ -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 diff --git a/spec/services/task_list_toggle_service_spec.rb b/spec/services/task_list_toggle_service_spec.rb index b1260cf740a..9adaee6481b 100644 --- a/spec/services/task_list_toggle_service_spec.rb +++ b/spec/services/task_list_toggle_service_spec.rb @@ -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 |