Sha256: 8209e205b37f5c7902398c4eab55c5295ebde16550e07eb336bd25f24331ca0e

Contents?: true

Size: 1014 Bytes

Versions: 4

Compression:

Stored size: 1014 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.
  # keep_blank_lines - an integer for the number of consecutive empty lines
  # to keep in output.
  #
  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

4 entries across 4 versions & 2 rubygems

Version Path
zine_brewer-1.5.0 vendor/bundle/ruby/2.7.0/gems/htmlbeautifier-1.3.1/lib/htmlbeautifier.rb
zine_brewer-1.3.0 vendor/bundle/ruby/2.7.0/gems/htmlbeautifier-1.3.1/lib/htmlbeautifier.rb
htmlbeautifier-1.3.1 lib/htmlbeautifier.rb
htmlbeautifier-1.3.0 lib/htmlbeautifier.rb