Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Doctype advanced

  • Loading branch information...
commit 7646ef485c3f99a0e887b4e6597c2314d0b686f4 1 parent cfec843
@DamirSvrtan DamirSvrtan authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/html2slim/hpricot_monkeypatches.rb
View
10 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
Please sign in to comment.
Something went wrong with that request. Please try again.