From 7ffb1cf5eb362ac981733fdaa60912e3550fbfb2 Mon Sep 17 00:00:00 2001 From: Shel Tebbs Date: Thu, 19 Nov 2015 15:50:16 -0800 Subject: [PATCH] Added better support for XML, tag and attribute case is now kept. See issue #62 --- lib/html2haml/html.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/html2haml/html.rb b/lib/html2haml/html.rb index 80a651a..aca16a1 100644 --- a/lib/html2haml/html.rb +++ b/lib/html2haml/html.rb @@ -159,6 +159,10 @@ def detect_proper_parser(template) return Nokogiri.HTML(template).at('/html').children end + if template =~ /^\s*<\?xml/i + return Nokogiri.XML(template) + end + parsed = Nokogiri::HTML::DocumentFragment.parse(template) #detect missplaced head or body tag