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) entity_output = @options[:entity_output] if e.char.respond_to?(:encoding) && entity_output == :as_char && (c = e.char.encode(@root.options[:encoding]) rescue nil) && ((c = e.char) == '"' || !ESCAPE_MAP.has_key?(c)) c elsif (entity_output == :as_input || entity_output == :as_char) && original original elsif (entity_output == :symbolic || ESCAPE_MAP.has_key?(e.char)) && !e.name.nil? "&#{e.name};" else # default to :numeric "&##{e.code_point};" end end
def escape_html(str, type = :all)
entities, :text - all special HTML characters except the quotation mark but no entities and
is escaped: :all - all special HTML characters except the quotation mark as well as
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 == 'id' && v.strip.empty?) ? '' : " #{k}=\"#{escape_html(v.to_s, :attribute)}\"" }.join('') end