RedCloth is a Ruby library for converting Textile into HTML.
Ruby C
Pull request Compare This branch is 72 commits behind jgarber:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


= RedCloth - Textile parser for Ruby

Author::    Jason Garber
Copyright:: (c) 2009 Jason Garber
License::   MIT

(See for a Textile reference.)

= RedCloth

RedCloth is a Ruby library for converting Textile into HTML.

== Installing

RedCloth can be installed via RubyGems:

  gem install RedCloth

It will install the appropriate Ruby, JRuby, or Win32 gem. If using JRuby,
version 1.1.5 or greater is required.

== Compiling

If you just want to use RedCloth, you do NOT need to build/compile it. It is
compiled from C sources automatically when you install the gem on the ruby
platform. Precompiled binary gems are provided for JRuby and Win32 platforms.

RedCloth can be compiled with <tt>rake compile</tt>. Ragel 6.3 or greater is
required. Again, Ragel is NOT needed to simply use RedCloth.

=== Supported platforms

By default, the rake compile task builds a native C extension (MRI 1.8 or 1.9)
or Java extension (JRuby 1.3). A pure Ruby version can also be generated, but
it's super slow and Ruby 1.8-only. The JRuby and pure-Ruby extensions don't
support multi-byte characters. Cross-compiling for win32 uses rake-compiler.

The RedCloth::EXTENSION_LANGUAGE constant indicates in which language your
copy of RedCloth is compiled.

=== Compiling gems

To compile MRI, JRuby, and win32 gems, you need rvm and rake-compiler. These
and other dependencies can be installed with bundler. Then rake build:all
takes care of compiling and packaging all gems.

# gem install bundler
# bundle install
# rake-compiler cross-ruby VERSION=1.8.6-p398
# rake-compiler cross-ruby VERSION=1.9.1-p243
# rake build:all

== Bugs

Please submit bugs to

== Using RedCloth

RedCloth is simply an extension of the String class that can handle
Textile formatting.  Use it like a String and output HTML with its
RedCloth#to_html method.

Simple use:
 text = "This is *my* text."

Multi-line example:

 doc = <<EOD
 h2. Test document
 Just a simple test.
 puts doc.to_html

== What is Textile?

Textile is a simple formatting style for text
documents, loosely based on some HTML conventions.

== Sample Textile Text

 h2. This is a title

 h3. This is a subhead

 This is a bit of paragraph.

 bq. This is a blockquote.

= Writing Textile

A Textile document consists of paragraphs.  Paragraphs
can be specially formatted by adding a small instruction
to the beginning of the paragraph.

 h3.     Header 3.
 bq.     Blockquote.
 #       Numeric list.
 *       Bulleted list.

== Quick Phrase Modifiers

Quick phrase modifiers are also included, to allow formatting
of small portions of text within a paragraph.

 -deleted text-
 +inserted text+

 ==notextile== (leave text alone)

== Links

To make a hypertext link, put the link text in "quotation 
marks" followed immediately by a colon and the URL of the link.

Optional: text in (parentheses) following the link text, 
but before the closing quotation mark, will become a title 
attribute for the link, visible as a tool tip when a cursor is above it.


 "This is a link (This is a title)":

Will become:

 <a href="" title="This is a title">This is a link</a>

== Images

To insert an image, put the URL for the image inside exclamation marks.

Optional: text that immediately follows the URL in (parentheses) will 
be used as the Alt text for the image. Images on the web should always 
have descriptive Alt text for the benefit of readers using non-graphical 

Optional: place a colon followed by a URL immediately after the 
closing ! to make the image into a link.



Will become:

 <img src="" alt="Textist" />

With a link:


Will become:

 <a href=""><img src="/common/textist.gif" alt="Textist" /></a>

== Defining Acronyms

HTML allows authors to define acronyms via the tag. The definition appears as a 
tool tip when a cursor hovers over the acronym. A crucial aid to clear writing, 
this should be used at least once for each acronym in documents where they appear.

To quickly define an acronym in Textile, place the full text in (parentheses) 
immediately following the acronym.


 ACLU(American Civil Liberties Union)

Will become:

 <acronym title="American Civil Liberties Union">ACLU</acronym>

== Adding Tables

In Textile, simple tables can be added by separating each column by
a pipe.


Styles are applied with curly braces.

    table{border:1px solid black}.
    {background:#ddd;color:red}. |a|red|row|