Class: Redmine::WikiFormatting::HtmlParser

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine/wiki_formatting/html_parser.rb

Overview

Since:

  • 3.1.0

Direct Known Subclasses

Markdown::HtmlParser, Textile::HtmlParser

Defined Under Namespace

Classes: WikiTags

Class Method Summary collapse

Class Method Details

.to_text(html) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/redmine/wiki_formatting/html_parser.rb', line 30

def self.to_text(html)
  html = html.gsub(/[\n\r]/, '').squeeze(' ')
    
  doc = Loofah.document(html)
  doc.scrub!(WikiTags.new(tags))
  doc.scrub!(:newline_block_elements)
    
  Loofah::Helpers.remove_extraneous_whitespace(doc.text).strip
end