Sha256: 9831433fc05bdf3d9182040fd6c54dffd6318b9a987279f40cb268b7d6b579ba

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

class Nokogiri::XML::Text

  def normalize
    self.content =~ /\S/ ? self.content.gsub(/\s+/,' ').strip : self.content
  end

  def normalize!
    self.content = self.normalize
  end

end

class Nokogiri::XML::Node

  def normalize_text!
    self.xpath('//text()').each { |t| t.normalize! }
  end

end

class Nokogiri::XML::Document

  def prettify
    xslt = Nokogiri::XSLT <<-EOC
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output omit-xml-declaration="yes" indent="yes"/>
      <xsl:template match="node()|@*">
        <xsl:copy>
          <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
      </xsl:template>
    </xsl:stylesheet>
    EOC
    xslt.transform(self).to_xml
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dor-services-5.2.0 lib/dor/utils/ng_tidy.rb