mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:51:07 +08:00
Feature: allow mods to cut pinned topic excerpts
This commit is contained in:
@ -10,6 +10,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
||||
@strip_links = options[:strip_links] == true
|
||||
@text_entities = options[:text_entities] == true
|
||||
@markdown_images = options[:markdown_images] == true
|
||||
@start_excerpt = false
|
||||
end
|
||||
|
||||
def self.get_excerpt(html, length, options)
|
||||
@ -54,8 +55,11 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
||||
@in_quote = true
|
||||
|
||||
when "div", "span"
|
||||
if attributes.include?(["class", "excerpt"])
|
||||
@start_excerpt = true
|
||||
end
|
||||
# Preserve spoilers
|
||||
if attributes.any? {|x| x == ["class", "spoiler"] }
|
||||
if attributes.include?(["class", "spoiler"])
|
||||
include_tag("span", attributes)
|
||||
@in_spoiler = true
|
||||
end
|
||||
@ -74,6 +78,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
||||
when "aside"
|
||||
@in_quote = false
|
||||
when "div", "span"
|
||||
throw :done if @start_excerpt
|
||||
characters("</span>", false, false, false) if @in_spoiler
|
||||
@in_spoiler = false
|
||||
end
|
||||
|
Reference in New Issue
Block a user