bobmcwhirter/awestruct — pull request #39 by mojavelinux (2011-10-30 18:00:29+00:00)
Title: add support for custom rule functions in RedCloth

Custom rule functions must be passed to the to_html method of the RedCloth object. Pass the method names defined by site.textile_rules to this method, first converting them to symbols (as required by RedCloth).

The functions must be included into the RedCloth class using an Awestruct Extension. For example:

module Awestruct::Extensions
class TextilePlus
def initialize()
RedCloth.send(:include, CustomRules)
end

module CustomRules
def emoticons(text)
# replace emoticons in text
end
end
end
end

You can either set site.textile_rules in this extension, or in _config/site.yml. Here's an example in site.yml:

textile_rules = [emoticons]