Class: Raw::CleanupFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/raw/compiler/filter/cleanup.rb

Overview

Cleanup the xhtml code generated by REXML used in other filters.

Instance Method Summary collapse

Instance Method Details

#apply(source) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/raw/compiler/filter/cleanup.rb', line 8

def apply(source)
  source = source.dup

  elements = "input|img|br|hr|link|style|render|include|inject|base|meta"
  source.gsub! /<textarea ([^>]*)><\/textarea>/, '<textarea \1>#{}</textarea>'
  source.gsub! /<(#{elements}) ([^>]*)><\/\1>/, '<\1 \2 />'
  source.gsub! /<(#{elements})><\/\1>/, '<\1 />'

  return source
end