lib/bergamasco/summarize.rb in bergamasco-0.1.4 vs lib/bergamasco/summarize.rb in bergamasco-0.2.1
- old
+ new
@@ -9,9 +9,14 @@
ellipsis = options[:ellipsis] || "..."
truncate_at_length(text, max_length, ellipsis)
end
end
+ def self.summary_from_html(html, options={})
+ summary = Bergamasco::Sanitize.sanitize(html, options).squish
+ summary(summary, options)
+ end
+
# from https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/truncate_html.rb
def self.truncate_at_separator(text, separator)
text = text.encode('UTF-8') if text.respond_to?(:encode)
doc = Nokogiri::HTML::DocumentFragment.parse text.split(separator).first
doc.inner_html