RedCloth is a module for using Textile in Ruby. Textile is a text format. A very simple text format. Another stab at making readable text that can be converted to HTML.
Textile is a simple markup language.
textile | to | html |
---|---|---|
_a phrase_ | -> | a phrase |
*a phrase* | -> | a phrase |
_*a phrase*_ | -> | a phrase |
"Google":http://google.com | -> |
No need to use verbose HTML to build your docs, your blogs, your pages. Textile gives you readable text while you’re writing and beautiful text for your readers. And if you need to break out into HTML, Textile will allow you to do so.
Textile also handles some subtleties of formatting which will enhance your document’s readability:
For more on Textile’s language, hop over to A Textile Reference.
The RedCloth class is an extension of Ruby’s String class. Use it like you would a String:
>> r = RedCloth.new "*strong text* and _emphasized text_" => "*strong text* and _emphasized text_" >> r.gsub!( 'text', 'words' ) => "*strong words* and _emphasized words_"
To generate HTML from your RedCloth object, use the RedCloth#to_html
method:
>> r.to_html => "<p><strong>strong words</strong> and <em>emphasized words</em></p>"
To install RedCloth via RubyGems:
gem install RedCloth
Or download RedCloth and simply run the install.rb like so:
ruby install.rb config ruby install.rb setup sudo ruby install.rb install
Textile is© 2003 Dean Allen. All rights reserved. You can read more here.
RedCloth is also based on PyTextile, which is: Copyright© 2003, Mark Pilgrim. All rights reserved. You can read more about PyTextile here.