diff --git a/lib/jekyll/converters/markdown/rdiscount_parser.rb b/lib/jekyll/converters/markdown/rdiscount_parser.rb index ca868d7a..bfe1a7ca 100644 --- a/lib/jekyll/converters/markdown/rdiscount_parser.rb +++ b/lib/jekyll/converters/markdown/rdiscount_parser.rb @@ -24,7 +24,9 @@ module Jekyll private def replace_generated_toc(rd, html, toc_token) if rd.generate_toc && html.include?(toc_token) - html.gsub(toc_token, rd.toc_content.force_encoding('utf-8')) + utf8_toc = rd.toc_content + utf8_toc.force_encoding('utf-8') if utf8_toc.respond_to?(:force_encoding) + html.gsub(toc_token, utf8_toc) else html end diff --git a/lib/jekyll/core_ext.rb b/lib/jekyll/core_ext.rb index 00f64fcf..1a7b1816 100644 --- a/lib/jekyll/core_ext.rb +++ b/lib/jekyll/core_ext.rb @@ -69,11 +69,3 @@ module Enumerable any? { |exp| File.fnmatch?(exp, e) } end end - -if RUBY_VERSION < "1.9" - class String - def force_encoding(enc) - self - end - end -end