From 9207c370d9142f1dd37e7446f006ee86697713bc Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Thu, 6 Feb 2020 07:43:27 -0700 Subject: [PATCH] FIX: Spoiler logic should live inside of spoiler plugin This commit removes logic about spoilers because it should live inside of the discourse-spoiler-alert plugin. This PR: https://github.com/discourse/discourse-spoiler-alert/pull/38 also completely removes spoilers from excerpts in order to keep them from leaking in topic previews and notifications. --- lib/excerpt_parser.rb | 5 ----- spec/components/pretty_text_spec.rb | 5 ----- 2 files changed, 10 deletions(-) diff --git a/lib/excerpt_parser.rb b/lib/excerpt_parser.rb index 24fc89792f6..4a2f483f36f 100644 --- a/lib/excerpt_parser.rb +++ b/lib/excerpt_parser.rb @@ -123,11 +123,6 @@ class ExcerptParser < Nokogiri::XML::SAX::Document @current_length = 0 @start_excerpt = true end - # Preserve spoilers - if attributes.include?(["class", "spoiler"]) - include_tag("span", attributes) - @in_spoiler = true - end when "details" @detail_contents = +"" if @in_details_depth == 0 diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 11da34414cc..1a9118d08c0 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -589,11 +589,6 @@ describe PrettyText do expect(PrettyText.excerpt("", 100, markdown_images: true)).to eq("![car](http://cnn.com/a.gif)") end - it "should keep spoilers" do - expect(PrettyText.excerpt("
", 100)).to match_html "[image]" - expect(PrettyText.excerpt("spoiler", 100)).to match_html "spoiler" - end - it "should keep details if too long" do expect(PrettyText.excerpt("
expand

hello

", 6)).to match_html "
expand
" end