RedCloth is a popular Ruby library for converting Textile-formatted text into HTML. Initially developed by WhyTheLuckyStiff, it's now under the guardianship of Jason Garber, who has just released version 4 (RubyForge or Github). This is a significant update, following on from 3.0.4 which was released almost three years ago, and features a handful of significant improvements and changes:
- New SuperRedCloth (RedCloth 4.0) is a total rewrite using Ragel for the parsing.
- Markdown support has been removed.
- Single newlines become <br> tags, just as in traditional RedCloth and other Textile parsers.
- HTML special characters are automatically escaped inside code signatures, like Textile 2. This means you can simply write @<br />@ and the symbols are escaped whereas in RedCloth 3 you had to write @<br />@ to make the code fragment readable.
- HTML embedded in the Textile input does not often need to be escaped from Textile parsing.
- The parser will not wrap lines that begin with a space in paragraph tags.
- Rudimentary support for LaTeX is built in.
- RedCloth::VERSION on a line by itself inserts the version number into the output.
- Output (less newlines and tabs) is identical to Textile 2 except a few cases where the RedCloth way was preferable.
- Over 500 tests prevent regression
- It's 40 times faster than the previous version.
Unless fiddling with the edge version on Github interests you, you can install or update with gem in the usual way - gem install RedCloth, etc.

Ruby's is not known for its deftness with XML. On RubyFlow, I considered calling the community to arms over it, and solicited twenty responses on what the problem is, and what we could do about it. Robert Fischer was lamenting on the state of Ruby's libxml library, and didn't seem to like REXML much either. Tim Bray has also had a few complaints about REXML. It seemed there was a problem to be fixed; a gap in the market, as it were, for a decent XML parser for Ruby. Hpricot, despite really being an HTML parser, would have to get us by in the meantime.
Today, however, libxml-ruby 0.8.0 has been released, and Charlie Savage explains why this is such a big deal. libxml-ruby now runs on Windows (thanks to Charlie), doesn't segfault all the time, and the bindings have all been fixed over the past year (thanks to Dan Janowski). You can get going with it right now with a simple gem install libxml-ruby
libxml-ruby is known for its performance, the latest release doesn't disappoint. For a range of simple tasks, libxml clocks in at ten times quicker than Hpricot like-for-like and between 30 and 60 times faster than REXML. Charles adds:
In addition to performance, the libxml-ruby bindings provide impressive coverage of libxml's functionality. Goodies include:
- SAX
- DOM
- XMLReader (streaming interface)
- XPath
- XPointer
- XML Schema
- DTDs
- XSLT (split into the libxslt-ruby bindings)
Charles is planning to write a proper tutorial in the next week, covering some of the key features, but suggests referring to the API documentation in the meantime. The test suite (located in the test directory that comes with libxml-ruby) also looks like a great resource for code examples; very clean and straightforward. If you have any libxml-ruby tutorials or resources of your own, please post them in the comments here.
Congratulations to all of those involved in libxml-ruby's long history and especially to Charlie Savage for giving it the finish push to this mature state. Ruby's XML woes are tempered, for now at least.
opensource: del.icio.us tag/opensource
graphics
visualization
tools
news
opensource
resources
History