Hello, I am in a bit of a bind. I need to reliably parse mediawiki markup to html, and the only parser that I can find (mediacloth) has a lot to be desired, so I would like to extend something that works and parse mediawiki markup. My question to this list is should I start working on RedCloth or SuperRedCloth or is there a difference as far as extending them? Also does anyone know of a write up that outlines extending RedCloth or SuperRedCloth with new markup? I apologize if these questions are a bit rudimentary for this list, but I appreciate any and all input and help. Thank you
Andrew, I''m no expert on RedCloth, but I can offer what I''ve gathered working with it for a little while (I''m jgarber if you''re looking at the RedCloth Timeline). IMHO, parsing with Ragel, as SuperRedCloth has done, is excellent because you get performance gains and the regexes are cleaner and more hierarchical. Hard to explain, but trust me that Ragel is hugely advantageous over plain Ruby. You have to learn Ragel, though. SuperRedCloth was slated to become RedCloth 4.0, so I don''t suggest investing any effort in RedCloth 3. Will SRC ever actually see a release? Hard to say. It would be really nice, since RedCloth 4.0.3 sucks so bad, but _Why hasn''t touched it in months. I''m fixing some bugs just so I can use it myself, but I don''t have time or desire to take it very far. I''m also a little leery of having RedCloth do too much. The 3.0 series majorly messed up, IMO, when it tried to integrate Markdown. It hybridized Textile and Markdown, but gave Textile priority when they conflicted unless you changed an option. But Markdown''s soft breaks became the default even when writing in Textile unless you turned on the :hard_breaks option, which didn''t work properly anyway. And then there was the :filter_html from early on, which was useful but often neglected. In short, it was a huge mess, largely because behavior changed over time and there were too many options. People don''t read instructions. They just install the RedCloth gem (or it''s automatically installed as a gem dependency) and they expect to get Textile like they''re used to from Textpattern or Movable Type or Word Press but they get this thing that doesn''t quite work the same, or else they update their gems and suddenly their output text looks different. So, I would like to keep SuperRedCloth pure and without many/any options. I was pleased to see that _Why put hard breaks back in and generally seems to be following the Textile2 "standards" (ha-- precedent?) more closely. I''m not the project owner, so he might have a different opinion, but I''m generally glad to see the direction it appears to be heading. I''d encourage you to look at Maruku. It''s a popular recent Markdown interpreter and I noticed recently that on the home page Andrea indicates he''d like to add Textile2 to the mix. I like the multiple- formats-in, multiple-formats-out approach. Maybe he''d consider adding Mediawiki too if you''d contribute it. Get in touch with him. If you can''t join Maruku, I''d recommend you make your own separate project to handle Mediawiki. I think you''ll have the easiest time running your own project and having a separate name and everything. Jason Garber On Jul 16, 2007, at 12:08 PM, andrew thornton wrote:> Hello, > > I am in a bit of a bind. I need to reliably parse mediawiki markup to > html, and the only parser that I can find (mediacloth) has a lot to be > desired, so I would like to extend something that works and parse > mediawiki markup. My question to this list is should I start working > on RedCloth or SuperRedCloth or is there a difference as far as > extending them? Also does anyone know of a write up that outlines > extending RedCloth or SuperRedCloth with new markup? I apologize if > these questions are a bit rudimentary for this list, but I appreciate > any and all input and help. > > Thank you > _______________________________________________ > Redcloth-upwards mailing list > Redcloth-upwards at rubyforge.org > http://rubyforge.org/mailman/listinfo/redcloth-upwards-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/redcloth-upwards/attachments/20070716/7c2e657f/attachment.html
On 7/16/07, Jason Garber <jg at jasongarber.com> wrote:> IMHO, parsing with Ragel, as SuperRedCloth has done, is excellent because > you get performance gains and the regexes are cleaner and more hierarchical. > Hard to explain, but trust me that Ragel is hugely advantageous over plain > Ruby. You have to learn Ragel, though.The current implementation of SRC makes it hard to subclass since Ragel passes the parsed strings to SuperRedCloth class methods, not instance methods. This would be the first thing that should be changed if SRC is going to be useful for subclassing and for parsing or emitting other formats. -- Geoffrey Grosenbach Screencast | http://peepcode.com
Sorry, what''s the problem with class methods? $ irb -r superredcloth irb(main):001:0> class MySrc < SuperRedCloth irb(main):002:1> def self.p(opts) irb(main):003:2> "my p" irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> SuperRedCloth.p(:text => ''hello'') => "<p>hello</p>" irb(main):007:0> MySrc.p(:text => ''hello'') => "my p" Makes sense to use class methods to me since it''s providing a service of the class ("translate this hash of options into an HTML tag") rather than working on an instance ("okay block object, translate yourself into an HTML tag"). Jason On Jul 16, 2007, at 1:42 PM, Geoffrey Grosenbach wrote:> On 7/16/07, Jason Garber <jg at jasongarber.com> wrote: >> IMHO, parsing with Ragel, as SuperRedCloth has done, is excellent >> because >> you get performance gains and the regexes are cleaner and more >> hierarchical. >> Hard to explain, but trust me that Ragel is hugely advantageous >> over plain >> Ruby. You have to learn Ragel, though. > > The current implementation of SRC makes it hard to subclass since > Ragel passes the parsed strings to SuperRedCloth class methods, not > instance methods. This would be the first thing that should be changed > if SRC is going to be useful for subclassing and for parsing or > emitting other formats. > > -- > Geoffrey Grosenbach > Screencast | http://peepcode.com > _______________________________________________ > Redcloth-upwards mailing list > Redcloth-upwards at rubyforge.org > http://rubyforge.org/mailman/listinfo/redcloth-upwards-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/redcloth-upwards/attachments/20070717/de30dbcc/attachment.html
On 7/17/07, Jason Garber <jg at jasongarber.com> wrote:> Makes sense to use class methods to me since it''s providing a service of the > class ("translate this hash of options into an HTML tag") rather than > working on an instance ("okay block object, translate yourself into an HTML > tag").Maybe my problem was a detail of how I was using it. I wanted to do state-based things like "Automatically apply this CSS class for the first h1 in the entire document" or "Read separate code files referenced by a special tag and inline them into the final document" which meant saving file paths in instance variables. -- Geoffrey Grosenbach ........................ Screencast | http://peepcode.com
On Mon, Jul 16, 2007 at 10:42:51AM -0700, Geoffrey Grosenbach wrote:> The current implementation of SRC makes it hard to subclass since > Ragel passes the parsed strings to SuperRedCloth class methods, not > instance methods. This would be the first thing that should be changed > if SRC is going to be useful for subclassing and for parsing or > emitting other formats.In the Super branch, this has changed and I really think it''s better than SuperRedCloth, guys!! You create class methods for everything you want to output and then you pass it into the SuperRedCloth#to method: class SuperRedCloth::Text class << self def p opts opts[:text] end # ... h1, h2, h3, etc ... end end Then to output: str = SuperRedCloth.new(str) str.to(SuperRedCloth::Text) So, basically, SuperRedCloth.to_html is syntactic sugar for SuperRedCloth.to(SuperRedCloth::HTML). Follow? _why
On 7/18/07, why the lucky stiff <why at hobix.com> wrote:> In the Super branch, this has changed and I really think it''s better > than SuperRedCloth, guys!! > > You create class methods for everything you want to output and then > you pass it into the SuperRedCloth#to method:Brilliant. I''ll try this. I''m using the feature of classic RedCloth where you can define a method to handle a new block: def textile_ruby return "ruby code with styling" end .... ruby. here''s some ruby code in my textile Geoffrey Grosenbach