Sha256: d9b153c3703bfa85d38a39c1b0568298f365c0217d268e923605d1ab7ca457f2

Contents?: true

Size: 1007 Bytes

Versions: 3

Compression:

Stored size: 1007 Bytes

Contents

require "htmlformatter/builder"
require "htmlformatter/html_parser"
require "htmlformatter/version"

module HtmlFormatter
  #
  # Returns a formatted HTML/HTML+EEX 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.format(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

3 entries across 3 versions & 1 rubygems

Version Path
htmlformatter-1.5.3 lib/htmlformatter.rb
htmlformatter-1.5.1 lib/htmlformatter.rb
htmlformatter-1.5.0 lib/htmlformatter.rb