mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 04:34:13 -06:00
DEV: Add option to keep quoted content in post excerpt.
This commit is contained in:
parent
7dbde18f02
commit
9a6606dd30
@ -19,6 +19,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
|||||||
@keep_emoji_images = options[:keep_emoji_images] == true
|
@keep_emoji_images = options[:keep_emoji_images] == true
|
||||||
@keep_onebox_source = options[:keep_onebox_source] == true
|
@keep_onebox_source = options[:keep_onebox_source] == true
|
||||||
@keep_onebox_body = options[:keep_onebox_body] == true
|
@keep_onebox_body = options[:keep_onebox_body] == true
|
||||||
|
@keep_quotes = options[:keep_quotes] == true
|
||||||
@remap_emoji = options[:remap_emoji] == true
|
@remap_emoji = options[:remap_emoji] == true
|
||||||
@start_excerpt = false
|
@start_excerpt = false
|
||||||
@in_details_depth = 0
|
@in_details_depth = 0
|
||||||
@ -100,8 +101,10 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
|||||||
@in_quote = true
|
@in_quote = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if @keep_onebox_body && attributes['class'].include?('quote') && attributes['data-topic'].present?
|
if attributes['class'].include?('quote')
|
||||||
@in_quote = false
|
if @keep_quotes || (@keep_onebox_body && attributes['data-topic'].present?)
|
||||||
|
@in_quote = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'article'
|
when 'article'
|
||||||
|
@ -81,4 +81,17 @@ describe ExcerptParser do
|
|||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "keep_quotes parameter" do
|
||||||
|
it "should keep the quoted content in html" do
|
||||||
|
html = <<~HTML.strip
|
||||||
|
<aside class="quote">
|
||||||
|
<blockquote>
|
||||||
|
This is a quoted text.
|
||||||
|
</blockquote>
|
||||||
|
</aside>
|
||||||
|
HTML
|
||||||
|
expect(ExcerptParser.get_excerpt(html, 100, keep_quotes: true)).to eq("This is a quoted text.")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user