module Kramdown::Utils::Html
def entity_to_str(e, original = nil)
original representation of the entity.
Convert the entity +e+ to a string. The optional parameter +original+ may contain the
def entity_to_str(e, original = nil) if RUBY_VERSION >= '1.9' && @options[:entity_output] == :as_char && (c = e.char.encode(@root.options[:encoding]) rescue nil) && !ESCAPE_MAP.has_key?(c) c elsif (@options[:entity_output] == :as_input || @options[:entity_output] == :as_char) && original original elsif @options[:entity_output] == :numeric || e.name.nil? "&##{e.code_point};" else "&#{e.name};" end end
def escape_html(str, type = :all)
:attribute - all special HTML characters including the quotation mark but no
\- all special HTML characters except the quotation mark but no entities and
is escaped: :all - all special HTML characters as well as entities, :text
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(attr)
def html_attributes(attr) attr.map {|k,v| v.nil? ? '' : " #{k}=\"#{escape_html(v.to_s, :attribute)}\"" }.join('') end