lib/ecrire/app/models/admin/post.rb in ecrire-0.26.3 vs lib/ecrire/app/models/admin/post.rb in ecrire-0.27.0

- old
+ new

@@ -40,10 +40,17 @@ def excerptize! html = Nokogiri::HTML(self.compiled_content) html.xpath("//img").each do |img| img.remove end - self.compiled_excerpt = html.xpath('//body').children[0..20].to_s + + valid_elements = %w(p ul ol li).freeze + + elements = html.xpath('//body').children[0..4].take_while do |el| + valid_elements.include?(el.name) + end + + self.compiled_excerpt = elements.map(&:to_s).join end end end