Permalink
Browse files

Doctype advanced

  • Loading branch information...
1 parent cfec843 commit 7646ef485c3f99a0e887b4e6597c2314d0b686f4 @DamirSvrtan DamirSvrtan committed Oct 17, 2013
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/html2slim/hpricot_monkeypatches.rb
@@ -23,7 +23,15 @@ def to_slim(lvl=0)
class Hpricot::DocType
def to_slim(lvl=0)
- 'doctype html'
+ if self.to_s.include? "xml"
+ self.to_s.include?("iso-8859-1") ? "doctype xml ISO-88591" : "doctype xml"
+ elsif self.to_s.include? "XHTML" or self.to_s.include? "HTML 4.01"
+ available_versions = Regexp.union ["Basic", "1.1", "strict", "Frameset", "Mobile", "Transitional"]
+ version = self.to_s.match(available_versions).to_s.downcase
+ "doctype #{version}"
+ else
+ "doctype html"
+ end
end
end

0 comments on commit 7646ef4

Please sign in to comment.