summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-02-20 01:41:55 -0800
committerelijah <elijah@riseup.net>2013-02-20 01:41:55 -0800
commitdb22c6c5dabac89b66aab8dd0710636d9be75a67 (patch)
tree1220f5170c56c31484c37d38f3e8ebc689f32984
parent52983c10242fa879ab6b5f5e5864b59f93d98afa (diff)
force valid utf8 for older versions of pandoc that barf on illegal utf-8 bytes.
-rw-r--r--Gemfile3
-rw-r--r--lib/static_page.rb2
2 files changed, 5 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile
index 511bc73..4b38b7d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,6 +9,9 @@ gem 'haml' # allow pages with .haml
gem 'RedCloth' # allow :textile in HAML
gem 'sass-rails' # not sure why can't be in :assets group
gem 'pandoc-ruby'
+unless RUBY_VERSION =~ /1.8/
+ gem 'iconv' # required for older pandoc
+end
# Gems used only for assets and not required
# in production environments by default.
diff --git a/lib/static_page.rb b/lib/static_page.rb
index 6ad0c51..91032c7 100644
--- a/lib/static_page.rb
+++ b/lib/static_page.rb
@@ -10,6 +10,7 @@ require 'i18n'
require 'pathname'
require 'RedCloth'
require 'pandoc-ruby'
+require 'iconv'
class StaticPage
attr_accessor :path, :children, :name, :file_path, :props, :parent, :mount_point, :locales
@@ -349,6 +350,7 @@ class StaticPage
}
def render_pandoc(string, suffix, locale)
+ string = Iconv.conv("UTF-8//IGNORE", "UTF-8", string) # remove illegal utf-8
args = [string, {:from => PANDOC_FORMATS[suffix], :to => :html}, "smart"]
if props.locale(locale).toc != false
args << "table_of_contents"