Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

RedCloth 4.0 Released: 40x Faster Textile Rendering

By Peter Cooper / July 22, 2008


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 @&lt;br /&gt;@ 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.


  1. Jonathan George says:

    Nice! This is definitely long overdue.

    Glad to see Jason picked the ball up and ran with it.

  2. Ryan Bates says:

    You need to camel case "RedCloth" to install it. Lowercase doesn't work.

    gem install RedCloth

  3. Jason Garber says:

    One correction, you have to gem install RedCloth with RedCloth in CamelCase. We've been trying to get the RubyGems developers to make gem names case-insensitive, but it doesn't seem likely to change.

  4. Peter Cooper says:

    Thanks for the fix!

  5. John says:

    This is great about the new improvements in the new version of RedCloth.

    Unfortunately, it no longer supports Markdown.

    Does anyone know an alternative library to use with Ruby for Markdown?

  6. Peter Cooper says:

    John: See

  7. Everton J. Carpes says:

    Nice... yesterday i decide: "i will change my applications to use another textile gem"!

    today i found this post - great!!! just in time :D

    In true... "long, long overdue"!

    But "40 times faster" is a really good news!
    Thanks for RedCloth and for inhibit me to lose my time!

  8. John says:

    Peter: Thanks, the Markdown packages at that link are exactly what I was looking for.

  9. Luis Lavena says:

    @Jason Garber:

    Can you point the exact version of ragel parser used? I'm trying to build a mswin32 and mingw32 gems for it and used 6.2 but it fails.

    Thank you and great work (tested under linux, it not only solve lot of problems but is faster indeed!)

  10. Jason Garber says:

    @Luis Lavena:

    There was a problem with my cross-compiled win32 gems not getting picked up by RubyForge. The file was there but it wasn't getting added to the gem index, so if you tried to install on Windows, it tried to install for the "ruby" platform, not "mswin32". Give it another go and it should install the precompiled Windows binary. There's no need for Ragel on Linux, either, unless you're compiling from source.

  11. Luis Lavena says:

    @Jason Garber:

    Good to know, I'll like to build also the MinGW one (i386-mingw32 platform) since One-Click Installer is moving to it.

    I tried to git clone your repo and found the Ragel output a bunch of errors trying to build on Windows (all the time).

    Again, thanks for your time and hard work!

  12. Ericson Smith says:

    This is purely philosophical, but why the need for Textile? Seriously.

    HTML is more widely known. Should not we focus on building a library that limits the HTML that someone can use, instead of getting them to learn another dialect?

    This is why I stopped requiring my visitors to learn Textile in any of my projects and just did simple formatting, while allowing the simplest of HTML tags from users. The issue of formatting thus never comes up. People who want to format something invariable know a little bit of HTML. And if you make links and emails clickable, that solves most of the problem anyway.

    Die RedCloth! Die.

  13. Bruce Williams says:

    #12, Ericson: Sounds like a nice idea, but completely unrealistic for people that have to cater to people who don't know HTML, or don't want to learn. There's a lot of them, unfortunately.

    One plus for Textile and formats like it, even in geek-circles, is the fact a block of text is a paragraph, and you can get away with writing fluidly without the need for paragraph tags. Lists are another draw, considering the amount of markup required to make a simple list in HTML (18 additional characters for a simple one-item UL or OL). Sometimes Textile is just more casual and easy to use, matching how people would type in plain text; saving keystrokes isn't philosophical.

    Textile + HTML is my preferred approach.

  14. Ericson Smith says:


    Not unrealistic at all. Right now, people type naturally and you can use simple_format to deal with 90% of the use cases out there to format fluid paragraphs. No need for textile.

    And, even better, there's 1,000,000 times more documentation for HTML than Textile out there as well.

    Again, I don't recommend people using textile or other "variants" of HTML in their projects. I'd go so far to say its a waste of time.

Other Posts to Enjoy

Twitter Mentions