module Kramdown::Utils::HTML

def entity_to_str(e, original = nil)

Convert the +entity+ to a string.
def entity_to_str(e, original = nil)
  if RUBY_VERSION >= '1.9' && @doc.options[:entity_output] == :as_char &&
      (c = e.char.encode(@doc.parse_infos[:encoding]) rescue nil) && !ESCAPE_MAP.has_key?(c)
    c
  elsif (@doc.options[:entity_output] == :as_input || @doc.options[:entity_output] == :as_char) && original
    original
  elsif @doc.options[:entity_output] == :numeric || e.name.nil?
    "&##{e.code_point};"
  else
    "&#{e.name};"
  end
end

def escape_html(str, type = :all)

special HTML characters except the quotation mark but no entities.
:no_entities - all special HTML characters but no entities, :text - all
is escaped: :all - all special HTML characters as well as entities,
Escape the special HTML characters in the string +str+. The parameter +type+ specifies what
def escape_html(str, type = :all)
  str.gsub(ESCAPE_RE_FROM_TYPE[type]) {|m| ESCAPE_MAP[m] || m}
end

def html_attributes(el)

Return the string with the attributes of the element +el+.
def html_attributes(el)
  (el.options[:attr] || {}).map {|k,v| v.nil? ? '' : " #{k}=\"#{escape_html(v.to_s, :no_entities)}\"" }.sort.join('')
end