mirror of
https://github.com/discourse/discourse.git
synced 2025-08-21 19:11:18 +08:00
FEATURE: Add option for ExcerptParser
to keep onebox source.
This commit is contained in:
parent
e7c2f5fd96
commit
e49f3a408e
2 changed files with 19 additions and 3 deletions
|
@ -14,6 +14,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
|||
@markdown_images = options[:markdown_images] == true
|
||||
@keep_newlines = options[:keep_newlines] == true
|
||||
@keep_emoji_images = options[:keep_emoji_images] == true
|
||||
@keep_onebox_source = options[:keep_onebox_source] == true
|
||||
@remap_emoji = options[:remap_emoji] == true
|
||||
@start_excerpt = false
|
||||
end
|
||||
|
@ -27,6 +28,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
|||
parser.parse(html)
|
||||
end
|
||||
excerpt = me.excerpt.strip
|
||||
excerpt = excerpt.gsub(/\s*\n+\s*/, "\n\n") if options[:keep_onebox_source]
|
||||
excerpt = CGI.unescapeHTML(excerpt) if options[:text_entities] == true
|
||||
excerpt
|
||||
end
|
||||
|
@ -83,8 +85,11 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
|||
end
|
||||
|
||||
when "aside"
|
||||
@in_quote = true
|
||||
|
||||
@in_quote = true unless @keep_onebox_source
|
||||
when 'article'
|
||||
if @keep_onebox_source && attributes.include?(['class', 'onebox-body'])
|
||||
@in_quote = true
|
||||
end
|
||||
when "div", "span"
|
||||
if attributes.include?(["class", "excerpt"])
|
||||
@excerpt = ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue