lib/kramdown/utils/html.rb in kramdown-0.14.2 vs lib/kramdown/utils/html.rb in kramdown-1.0.0

- old
+ new

@@ -1,24 +1,11 @@ # -*- coding: utf-8 -*- # #-- -# Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at> +# Copyright (C) 2009-2013 Thomas Leitner <t_leitner@gmx.at> # -# This file is part of kramdown. -# -# kramdown is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# This file is part of kramdown which is licensed under the MIT. #++ # module Kramdown @@ -37,11 +24,12 @@ # This method uses the option +entity_output+ to determine the output form for the entity. 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) && !ESCAPE_MAP.has_key?(c) + (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};" @@ -71,12 +59,12 @@ :attribute => ESCAPE_ATTRIBUTE_RE } # :startdoc: # Escape the special HTML characters in the string +str+. The parameter +type+ specifies what - # is escaped: :all - all special HTML characters as well as entities, :text - all special HTML - # characters except the quotation mark but no entities and :attribute - all special HTML - # characters including the quotation mark but no entities. + # is escaped: :all - all special HTML characters except the quotation mark as well as + # entities, :text - all special HTML characters except the quotation mark but no entities and + # :attribute - all special HTML characters including the quotation mark but no entities. def escape_html(str, type = :all) str.gsub(ESCAPE_RE_FROM_TYPE[type]) {|m| ESCAPE_MAP[m] || m} end end