Class: Hpricot::DocType

Inherits:
Object
  • Object
show all
Defined in:
lib/html2slim/hpricot_monkeypatches.rb

Instance Method Summary collapse

Instance Method Details

#to_slim(lvl = 0) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/html2slim/hpricot_monkeypatches.rb', line 33

def to_slim(lvl=0)
  if to_s.include? "xml"
    to_s.include?("iso-8859-1") ? "doctype xml ISO-88591" : "doctype xml"
  elsif to_s.include? "XHTML" or self.to_s.include? "HTML 4.01"
    available_versions = Regexp.union ["Basic", "1.1", "strict", "Frameset", "Mobile", "Transitional"]
    version = to_s.match(available_versions).to_s.downcase
    "doctype #{version}"
  else
    "doctype html"
  end
end