RedCloth 4.0 Released: 40x Faster Textile Rendering
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.
July 22, 2008 at 6:32 pm
Nice! This is definitely long overdue.
Glad to see Jason picked the ball up and ran with it.
July 22, 2008 at 8:52 pm
You need to camel case "RedCloth" to install it. Lowercase doesn't work.
gem install RedCloth
July 22, 2008 at 8:52 pm
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.
July 22, 2008 at 9:16 pm
Thanks for the fix!
July 22, 2008 at 11:33 pm
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?
July 22, 2008 at 11:37 pm
John: See http://tomayko.com/writings/ruby-markdown-libraries-real-cheap-for-you-two-for-price-of-one
July 23, 2008 at 3:39 am
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!
July 23, 2008 at 2:42 pm
Peter: Thanks, the Markdown packages at that link are exactly what I was looking for.
July 24, 2008 at 7:15 am
@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!)
July 24, 2008 at 1:43 pm
@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.
July 25, 2008 at 12:13 am
@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!
July 27, 2008 at 7:39 am
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.
July 30, 2008 at 1:56 pm
#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.
July 31, 2008 at 3:56 pm
@bruce
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.