From 138e26b1fad6730aa048b8cc91f92a597e323162 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 4 Oct 2016 14:06:44 +0100 Subject: Adds v-pre to code blocks in comments Closes #22911 --- CHANGELOG | 3 ++- lib/banzai/filter/sanitization_filter.rb | 2 +- lib/banzai/filter/syntax_highlight_filter.rb | 3 ++- spec/features/notes_on_merge_requests_spec.rb | 12 ++++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9f871360bf4..8c1b5235443 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ v 8.13.0 (unreleased) - Simplify Mentionable concern instance methods - Fix permission for setting an issue's due date - Expose expires_at field when sharing project on API + - Fix VueJS template tags being rendered in code comments - Fix issue with page scrolling to top when closing or pinning sidebar (lukehowell) - Allow the Koding integration to be configured through the API - Added soft wrap button to repository file/blob editor @@ -44,7 +45,7 @@ v 8.13.0 (unreleased) - Notify the Merger about merge after successful build (Dimitris Karakasilis) - Fix broken repository 500 errors in project list - Close todos when accepting merge requests via the API !6486 (tonygambone) - - Changed Slack service user referencing from full name to username (Sebastian Poxhofer) + - Changed Slack service user referencing from full name to username (Sebastian Poxhofer) - Add Container Registry on/off status to Admin Area !6638 (the-undefined) v 8.12.4 (unreleased) diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb index 2470362e019..af1e575fc89 100644 --- a/lib/banzai/filter/sanitization_filter.rb +++ b/lib/banzai/filter/sanitization_filter.rb @@ -25,7 +25,7 @@ module Banzai return if customized?(whitelist[:transformers]) # Allow code highlighting - whitelist[:attributes]['pre'] = %w(class) + whitelist[:attributes]['pre'] = %w(class v-pre) whitelist[:attributes]['span'] = %w(class) # Allow table alignment diff --git a/lib/banzai/filter/syntax_highlight_filter.rb b/lib/banzai/filter/syntax_highlight_filter.rb index fcdb496aed2..bb6b4582e4f 100644 --- a/lib/banzai/filter/syntax_highlight_filter.rb +++ b/lib/banzai/filter/syntax_highlight_filter.rb @@ -30,7 +30,8 @@ module Banzai # users can still access an issue/comment/etc. end - highlighted = %(
#{code}
) + highlighted = %(
#{code}
) + puts highlighted # Extracted to a method to measure it replace_parent_pre_element(node, highlighted) diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index f1c522155d3..5d7247e2a62 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -240,6 +240,18 @@ describe 'Comments', feature: true do is_expected.to have_css('.notes_holder .note', count: 1) is_expected.to have_button('Reply...') end + + it 'adds code to discussion' do + click_button 'Reply...' + + page.within(first('.js-discussion-note-form')) do + fill_in 'note[note]', with: '```{{ test }}```' + + click_button('Comment') + end + + expect(page).to have_content('{{ test }}') + end end end end -- cgit v1.2.1 From cd2556e73792f018af71e8910b4f556e29de1985 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 4 Oct 2016 14:28:57 +0100 Subject: Removed puts code :see_no_evil: --- lib/banzai/filter/syntax_highlight_filter.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/banzai/filter/syntax_highlight_filter.rb b/lib/banzai/filter/syntax_highlight_filter.rb index bb6b4582e4f..026b81ac175 100644 --- a/lib/banzai/filter/syntax_highlight_filter.rb +++ b/lib/banzai/filter/syntax_highlight_filter.rb @@ -31,7 +31,6 @@ module Banzai end highlighted = %(
#{code}
) - puts highlighted # Extracted to a method to measure it replace_parent_pre_element(node, highlighted) -- cgit v1.2.1 From f377f82651998dc56301cc6540867b5120da43f2 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 4 Oct 2016 16:13:55 +0100 Subject: Fixed banzai test failures --- spec/lib/banzai/filter/syntax_highlight_filter_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb index b1370bca833..d265d29ee86 100644 --- a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb +++ b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb @@ -6,21 +6,21 @@ describe Banzai::Filter::SyntaxHighlightFilter, lib: true do context "when no language is specified" do it "highlights as plaintext" do result = filter('
def fun end
') - expect(result.to_html).to eq('
def fun end
') + expect(result.to_html).to eq('
def fun end
') end end context "when a valid language is specified" do it "highlights as that language" do result = filter('
def fun end
') - expect(result.to_html).to eq('
def fun end
') + expect(result.to_html).to eq('
def fun end
') end end context "when an invalid language is specified" do it "highlights as plaintext" do result = filter('
This is a test
') - expect(result.to_html).to eq('
This is a test
') + expect(result.to_html).to eq('
This is a test
') end end @@ -31,7 +31,7 @@ describe Banzai::Filter::SyntaxHighlightFilter, lib: true do it "highlights as plaintext" do result = filter('
This is a test
') - expect(result.to_html).to eq('
This is a test
') + expect(result.to_html).to eq('
This is a test
') end end end -- cgit v1.2.1