Sha256: c1d655a356d05e31ed4c67ec7389a981f2389dab4708fcbdb44739a839238cc5
Contents?: true
Size: 915 Bytes
Versions: 2
Compression:
Stored size: 915 Bytes
Contents
require "htmlbeautifier/builder" require "htmlbeautifier/html_parser" require "htmlbeautifier/version" module HtmlBeautifier # # Returns a beautified HTML/HTML+ERB document as a String. # html must be an object that responds to +#to_s+. # # Available options are: # tab_stops - an integer for the number of spaces to indent, default 2. # Deprecated: see indent. # indent - what to indent with (" ", "\t" etc.), default " " # stop_on_errors - raise an exception on a badly-formed document. Default # is false, i.e. continue to process the rest of the document. # initial_level - The entire output will be indented by this number of steps. # Default is 0. # def self.beautify(html, options = {}) if options[:tab_stops] options[:indent] = " " * options[:tab_stops] end "".tap { |output| HtmlParser.new.scan html.to_s, Builder.new(output, options) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
htmlbeautifier-1.2.1 | lib/htmlbeautifier.rb |
htmlbeautifier-1.2.0 | lib/htmlbeautifier.rb |