Pretty print with nokogiri

This commit is contained in:
bootstraponline
2012-11-10 16:34:37 -07:00
parent f6245c53dd
commit ca7d82278c
7 changed files with 116 additions and 50 deletions
+13 -1
View File
@@ -68,10 +68,22 @@ def write file, content
end
end
@@format_xslt = File.expand_path(File.join(File.dirname(__FILE__), 'format.xslt'))
def to_html html
# Remove blank nodes for proper formatting
doc = Nokogiri.XML(html) do |cfg|
cfg.default_xml.noblanks
end
# Save as XHTML
doc.to_xml( { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML, :indent => 2, :encoding => 'UTF-8' } )
end
def check name, pages_array
pages = FakePages.new pages_array
expected = read name
actual = view pages
actual = to_html view pages
# Uncomment when updating tests
# write name, actual