From 05aba4b43420839df75a88c150e3c996bbbcbea8 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 30 Oct 2011 13:55:17 -0400 Subject: [PATCH] add support for custom rule functions in RedCloth --- lib/awestruct/textilable.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/awestruct/textilable.rb b/lib/awestruct/textilable.rb index a5638a08..a3d3ab8b 100644 --- a/lib/awestruct/textilable.rb +++ b/lib/awestruct/textilable.rb @@ -4,7 +4,11 @@ module Textilable def render(context) rendered = '' begin - rendered = RedCloth.new( context.interpolate_string( raw_page_content ) ).to_html + # a module of rule functions is included in RedCloth using RedCloth.send(:include, MyRules) + # rule functions on that module are activated by setting the property site.textile_rules + # ex. site.textile_rules = ['emoticons'] + rules = context.site.textile_rules ? context.site.textile_rules.map { |r| r.to_sym } : [] + rendered = RedCloth.new( context.interpolate_string( raw_page_content ) ).to_html(*rules) rescue => e puts e puts e.backtrace