Method: Glyph::Utils#clean_xml_document
- Defined in:
- lib/glyph/utils.rb
#clean_xml_document(doc) ⇒ Object
Re-indents source code and removes unnecessary spacing
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/glyph/utils.rb', line 186 def clean_xml_document(doc) return doc unless current_output_setting :clean_source begin require 'nokogiri' rescue Exception warning "Cannot clean source because Nokogiri is not installed. Please run: gem install nokogiri" return doc end begin Nokogiri.XML(doc.to_s, &:noblanks).to_xml :indent => 2 rescue Exception => e warning "Unable to clean up source" debug e. debug e.backtrace.join("\n") doc end end |