lib/kramdown/parser/base.rb in kramdown-0.14.2 vs lib/kramdown/parser/base.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 @@ -96,9 +83,13 @@ end # Modify the string +source+ to be usable by the parser (unifies line ending characters to # +\n+ and makes sure +source+ ends with a new line character). def adapt_source(source) + if source.respond_to?(:encode!) + raise "The encoding of the source text is not valid!" if !source.valid_encoding? + source.encode!('UTF-8') + end source.gsub(/\r\n?/, "\n").chomp + "\n" end # This helper method adds the given +text+ either to the last element in the +tree+ if it is a # +type+ element or creates a new text element with the given +type+.