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.
This commit is contained in:
Blake Erickson 2020-02-06 07:43:27 -07:00
parent db4ae50928
commit 9207c370d9
2 changed files with 0 additions and 10 deletions

View File

@ -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

View File

@ -589,11 +589,6 @@ describe PrettyText do
expect(PrettyText.excerpt("<img src='http://cnn.com/a.gif' title='car'>", 100, markdown_images: true)).to eq("![car](http://cnn.com/a.gif)")
end
it "should keep spoilers" do
expect(PrettyText.excerpt("<div class='spoiler'><img src='http://cnn.com/a.gif'></div>", 100)).to match_html "<span class='spoiler'>[image]</span>"
expect(PrettyText.excerpt("<span class='spoiler'>spoiler</div>", 100)).to match_html "<span class='spoiler'>spoiler</span>"
end
it "should keep details if too long" do
expect(PrettyText.excerpt("<details><summary>expand</summary><p>hello</p></details>", 6)).to match_html "<details class='disabled'><summary>expand</summary></details>"
end