FIX: Quotes should be ignored when parsing for onebox source.
This commit is contained in:
parent
0a4c30bce3
commit
3861bd2793
|
@ -85,7 +85,11 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
|||
end
|
||||
|
||||
when "aside"
|
||||
@in_quote = true unless @keep_onebox_source
|
||||
attributes = Hash[*attributes.flatten]
|
||||
|
||||
unless @keep_onebox_source && attributes['class'].include?('onebox')
|
||||
@in_quote = true
|
||||
end
|
||||
when 'article'
|
||||
if @keep_onebox_source && attributes.include?(['class', 'onebox-body'])
|
||||
@in_quote = true
|
||||
|
|
|
@ -289,7 +289,8 @@ HTML
|
|||
expect(PrettyText.excerpt(emoji_code, 100)).to eq(":heart:")
|
||||
end
|
||||
|
||||
it "should have an option to preserver onebox source" do
|
||||
context 'option ot preserve onebox source' do
|
||||
it "should return the right excerpt" do
|
||||
onebox = "<aside class=\"onebox whitelistedgeneric\">\n <header class=\"source\">\n <a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">meta.discourse.org</a>\n </header>\n <article class=\"onebox-body\">\n <img src=\"https://cdn-enterprise.discourse.org/meta/user_avatar/meta.discourse.org/gerhard/200/70381_1.png\" width=\"\" height=\"\" class=\"thumbnail\">\n\n<h3><a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">Infrequent translation updates in stable branch</a></h3>\n\n<p>Well, there's an Italian translation for \"New Topic\" in beta, it's been there since November 2014 and it works here on meta. Do you have any plugins installed? Try disabling them. I'm quite confident that it's either a plugin or a site...</p>\n\n </article>\n <div class=\"onebox-metadata\">\n \n \n </div>\n <div style=\"clear: both\"></div>\n</aside>\n\n\n"
|
||||
expected = "<a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">meta.discourse.org</a>"
|
||||
|
||||
|
@ -300,6 +301,13 @@ HTML
|
|||
.to eq("#{expected}\n\n#{expected}")
|
||||
end
|
||||
|
||||
it 'should continue to strip quotes' do
|
||||
expect(PrettyText.excerpt(
|
||||
"<aside class='quote'><p>a</p><p>b</p></aside>boom", 100, keep_onebox_source: true
|
||||
)).to eq("boom")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "strip links" do
|
||||
|
|
Loading…
Reference in New Issue