From 9632830e5c8a504cbe9d3d68a7e421a45adf9d14 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Fri, 12 Mar 2010 17:45:42 +1100 Subject: [PATCH] Custom filter to enable smart quotes in RDiscount --- Rules | 4 ++-- lib/smart_rdiscount.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 lib/smart_rdiscount.rb diff --git a/Rules b/Rules index 8b217b4..d6872b0 100644 --- a/Rules +++ b/Rules @@ -16,7 +16,7 @@ compile %r{/(?:technical|personal|)articles/(page/|)} do end compile %r(/\d{4}/*) do - filter :rdiscount + filter :smart_rdiscount layout 'article' layout 'default' end @@ -30,7 +30,7 @@ compile %r{(?:/robots/|/sitemap)} do end compile '*' do - filter :rdiscount + filter :smart_rdiscount layout 'default' end diff --git a/lib/smart_rdiscount.rb b/lib/smart_rdiscount.rb new file mode 100644 index 0000000..bac131d --- /dev/null +++ b/lib/smart_rdiscount.rb @@ -0,0 +1,13 @@ +module WezM::Filters + class SmartRDiscount < Nanoc3::Filter + def run(content, params={}) + require 'rdiscount' + + markdown = ::RDiscount.new(content) + markdown.smart = true + markdown.to_html + end + end +end + +Nanoc3::Filter.register '::WezM::Filters::SmartRDiscount', :smart_rdiscount