Created
May 6, 2010 16:02
-
-
Save troelskn/392292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def html_to_xml(html) | |
filename = "/tmp/tidyfy-#{ Time.now.strftime('%Y%m%d%H%M%S') }.html" | |
File.open(filename, 'w') {|f| f << html } | |
output = `tidy -asxml -numeric --output-encoding utf8 --doctype omit --add-xml-decl true #{filename} 2> /dev/null` | |
output.strip.gsub(/<html([^>]*)>/, "<html>") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment