Module: StripTags

Included in:
HTML::Converter, HTML::Tag, W3MExtractLinks
Defined in:
lib/langhelp/langhelp-base.rb

Constant Summary collapse

Q =
/[\"\']?/
NQ =
/[^\"\'> ]+/
ALT =
/[^\"\'>]+/

Instance Method Summary collapse

Instance Method Details

#html2txt!(s) ⇒ Object



216
217
218
219
220
221
222
223
224
# File 'lib/langhelp/langhelp-base.rb', line 216

def html2txt!(s)
  s.gsub!(/<img .*?alt=#{Q}(#{ALT})#{Q}.*?>/imo, '\1')
  s.gsub!(/<[^>]+>/,'')
  s.gsub!(/&nbsp;/, ' ')
  s.replace CGI.unescapeHTML(s)
  s.gsub!(/\r?\n/,' ')
  s.gsub!(/\s+/, ' ')
  s
end