From 40fd643680688ac1ca257c8e357cbdc248ec903a Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Sat, 3 Dec 2011 17:31:53 -0600 Subject: [PATCH] Update Maruku --- .../maruku/lib/maruku/input/parse_doc.rb | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/vendor/plugins/maruku/lib/maruku/input/parse_doc.rb b/vendor/plugins/maruku/lib/maruku/input/parse_doc.rb index 53c2674a..043eac4c 100644 --- a/vendor/plugins/maruku/lib/maruku/input/parse_doc.rb +++ b/vendor/plugins/maruku/lib/maruku/input/parse_doc.rb @@ -18,8 +18,6 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #++ - -require 'iconv' require 'nokogiri' require 'strscan' @@ -40,21 +38,23 @@ Summary: Encoding for the document. If the `encoding` attribute is specified, then the content will be converted from the specified encoding to UTF-8. - -Conversion happens using the `iconv` library. =end enc = self.attributes[:encoding] self.attributes.delete :encoding if enc && enc.downcase != 'utf-8' - converted = Iconv.new('utf-8', enc).iconv(data) - -# puts "Data: #{data.inspect}: #{data}" -# puts "Conv: #{converted.inspect}: #{converted}" - - data = converted + + # Switch to ruby 1.9 String#encode + # with backward 1.8 compatibility + if data.respond_to?(:encode!) + data.encode!('UTF-8', enc) + else + require 'iconv' + data = Iconv.new('utf-8', enc).iconv(data) + end + end - + @children = parse_text_as_markdown(data) if true #markdown_extra?