class Haml::HTML

It depends on Hpricot for HTML parsing (code.whytheluckystiff.net/hpricot/).
namely converting HTML documents to Haml templates.
This class contains the functionality used in the html2haml utility,

def self.haml_tag_loud(text)

def self.haml_tag_loud(text)
  "= #{text.gsub(/\n\s*/, ' ').strip}\n"
end

def self.haml_tag_silent(text)

def self.haml_tag_silent(text)
  text.split("\n").map { |line| "- #{line.strip}\n" }.join
end

def self.options

def self.options
  @@options
end

def initialize(template, options = {})

to a Haml string when +render+ is called.
which can either be a string containing HTML or an Hpricot node,
Creates a new instance of Haml::HTML that will compile the given template,
def initialize(template, options = {})
  @@options = options
  if template.is_a? Hpricot::Node
    @template = template
  else
    if template.is_a? IO
      template = template.read
    end
    if @@options[:rhtml]
      match_to_html(template, /<%=(.*?)-?%>/m, 'loud')
      match_to_html(template, /<%(.*?)-?%>/m,  'silent')
    end
    method = @@options[:xhtml] ? Hpricot.method(:XML) : method(:Hpricot)
    @template = method.call(template)
  end
end

def match_to_html(string, regex, tag)

def match_to_html(string, regex, tag)
  string.gsub!(regex) do
    "<haml:#{tag}>#{CGI.escapeHTML($1)}</haml:#{tag}>"
  end
end

def render

containing the Haml template.
Processes the document and returns the result as a string
def render
  @template.to_haml(0)
end