lib/kramdown/converter/base.rb in kramdown-0.14.2 vs lib/kramdown/converter/base.rb in kramdown-1.0.0

- old
+ new

@@ -1,28 +1,16 @@ # -*- 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. #++ # require 'erb' +require 'kramdown/utils' module Kramdown module Converter @@ -88,10 +76,11 @@ # directory. def self.convert(tree, options = {}) converter = new(tree, ::Kramdown::Options.merge(options.merge(tree.options[:options] || {}))) result = converter.convert(tree) result = apply_template(converter, result) if !converter.options[:template].empty? + result.encode!(tree.options[:encoding]) if result.respond_to?(:encode!) [result, converter.warnings] end # Convert the element +el+ and return the resulting object. # @@ -162,9 +151,10 @@ # Generate an unique alpha-numeric ID from the the string +str+ for use as a header ID. # # Uses the option +auto_id_prefix+: the value of this option is prepended to every generated # ID. def generate_id(str) + str = ::Kramdown::Utils::Unidecoder.decode(str) if @options[:transliterated_header_ids] gen_id = str.gsub(/^[^a-zA-Z]+/, '') gen_id.tr!('^a-zA-Z0-9 -', '') gen_id.tr!(' ', '-') gen_id.downcase! gen_id = 'section' if gen_id.length == 0