Class: Canon::PrettyPrinter::Html

Inherits:
Object
  • Object
show all
Defined in:
lib/canon/pretty_printer/html.rb

Overview

Pretty printer for HTML with consistent indentation

Instance Method Summary collapse

Constructor Details

#initialize(indent: 2, indent_type: "space") ⇒ Html

Returns a new instance of Html.



9
10
11
12
# File 'lib/canon/pretty_printer/html.rb', line 9

def initialize(indent: 2, indent_type: "space")
  @indent = indent.to_i
  @indent_type = indent_type
end

Instance Method Details

#format(html_string) ⇒ Object

Pretty print HTML with consistent indentation



15
16
17
18
19
20
21
22
# File 'lib/canon/pretty_printer/html.rb', line 15

def format(html_string)
  # Detect if this is XHTML or HTML
  if xhtml?(html_string)
    format_as_xhtml(html_string)
  else
    format_as_html(html_string)
  end
end