Class: Redmine::WikiFormatting::HtmlParser
- Inherits:
-
Object
- Object
- Redmine::WikiFormatting::HtmlParser
- Defined in:
- lib/redmine/wiki_formatting/html_parser.rb
Direct Known Subclasses
Defined Under Namespace
Classes: WikiTags
Class Method Summary collapse
Class Method Details
.to_text(html) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/redmine/wiki_formatting/html_parser.rb', line 31 def self.to_text(html) html = html.gsub(/[\n\r]/, ' ') doc = Loofah.document(html) doc.scrub!(WikiTags.new()) doc.scrub!(:newline_block_elements) Loofah.remove_extraneous_whitespace(doc.text(:encode_special_chars => false)).strip.squeeze(' ').gsub(/^ +/, '') end |