From: Tom Counsell Date: 2005-07-20T18:26:56+09:00 Subject: Re: customizing redcloth? HI Bruce In case you haven't figured this out already, you need to either: a) add :inline_textile_quote to the list of rules in the RedCloth to_html method or b) call to_html with to_html(:textile,:inline_textile_quote) or c) add :inline_textile_quote DEFAULT_RULES constant. Redcloth should then call the rule at the appropriate moment. I needed to do some careful jiggling of the order of the rules in order to make my modifications work as expected. Tom On 19 Jul 2005, at 22:15, bdarcus@gmail.com wrote: > Newbie question: > > How do I add a new inline rule to RedCloth? > > I want to add support for inline semantic quotes, including > support for citation markup. So, I want ``this'':someid#pages=23, to > be converted to: > > this > > I'm not getting the pattern processed though. I'm thinking it's > because > RedCloth (and in particular the to_html method) doesn't know about the > new method I want to add, but have no idea how to resolve that (or if > I'm even right). > > Bruce > > #! /usr/bin/env ruby > > require 'rubygems' > require 'redcloth' > > class RedCloth > > QUOTE_RE = / > ([\s\[{(]|[#{PUNCT}])? # $pre > `` # start > (#{C}) # $atts > ([^"]+?) # $text > \s? > (?:\(([^)]+?)\)(?="))? # $quote > '': > (\S+?) # $citeid > (\/)? # $slash > ([^\w\/;]*?) # $post > (?=<|\s|$) > /x > > def inline_textile_quote( text ) > text.gsub!( QUOTE_RE ) do |m| > pre,atts,text,quote,citeid,slash,post = $~[1..7] > > # citeid, citeid_quote = check_refs( citeid ) > # quote ||= citeid_quote > > atts = pba( atts ) > atts = " cite=\"#{ citeid }\"#{ atts }" > text << "#{ quote }" if title > atts = shelve( atts ) if atts > > "#{ pre }#{ text }#{ post }" > end > end > > end > > >