Last active
December 24, 2015 14:29
-
-
Save cbronazc/6813471 to your computer and use it in GitHub Desktop.
Convert xml to html with a ruby script. Basically just a cheap, badly done .html_safe
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
require 'tempfile' | |
require 'fileutils' | |
# To run: ruby ./convert_xml_to_html.rb thefile.xml | |
# | |
path = ARGV[0] | |
begin | |
orig = File.open(path, 'r') | |
file = File.open("converted_" + path, "w") | |
contents = orig.read | |
contents.gsub!("<", "<") | |
contents.gsub!(">", ">") | |
contents.gsub!(""", "\"") | |
contents.gsub!("'", "\'") | |
contents.gsub("&", "&") | |
file.write(contents) | |
puts path + " converted" | |
ensure | |
file.close unless file == nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment