• Stars
    star
    443
  • Rank 94,781 (Top 2 %)
  • Language Ragel
  • License
    Other
  • Created about 16 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RedCloth is a Ruby library for converting Textile into HTML.

RedCloth - Textile parser for Ruby¶ ↑

Homepage

github.com/jgarber/redcloth

Maintainer

Helio Cola github.com/heliocola

Author

Jason Garber

Copyright

© 2011 Jason Garber

License

MIT

RedCloth¶ ↑

RedCloth is a Ruby library for converting Textile into HTML.

Attention - Deprecating JRuby and Windows support in version 4.3¶ ↑

In order to prioritize merging a fix for the long standing vulnerability CVE-2012-6684, our new maintainer has elected to stop maintaining the precompiled versions for Windows and JRuby.

Installing¶ ↑

RedCloth can be installed via RubyGems:

gem install RedCloth

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 prior to version 4.3.

RedCloth can be compiled with rake compile. 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). A pure Ruby version can also be generated, but it’s super slow and Ruby 1.8-only, and doesn’t support multi-byte characters.

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

Please submit bugs as issues to this repo.

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."
RedCloth.new(text).to_html

Multi-line example:

doc = RedCloth.new <<EOD
h2. Test document

Just a simple test.
EOD
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.

_emphasis_
__italicized__
*strong*
**bold**
??citation??
-deleted text-
+inserted text+
^superscript^
~subscript~
@code@
%(classname)span%

==notextile== (leave text alone)

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.

Example:

"This is a link (This is a title)":http://www.textism.com

Will become:

<a href="http://www.textism.com" title="This is a title">This is a link</a>

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 browsers.

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

Example:

!http://www.textism.com/common/textist.gif(Textist)!

Will become:

<img src="http://www.textism.com/common/textist.gif" alt="Textist" />

With a link:

!/common/textist.gif(Textist)!:http://textism.com

Will become:

<a href="http://textism.com"><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.

Example:

ACLU(American Civil Liberties Union)

Will become:

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

Filtering HTML¶ ↑

RedCloth doesn’t filter unsafe html tags by default, do to this use the following syntax:

RedCloth.new("<script>alert(1)</script>", [:filter_html]).to_html

which will filter the script tags from the HTML resulting in:

"&lt;script&gt;alert(1)&lt;/script&gt;"

Adding Tables¶ ↑

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

|a|simple|table|row|
|And|Another|table|row|

Styles are applied with curly braces.

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

More Repositories

1

radiant-chronicle-extension

Provides history, diffs, and dev-only drafts to Radiant CMS
Ruby
42
star
2

radiant-textile_editor-extension

Adds a toolbar to make editing pages and snippets written in Textile easier.
JavaScript
19
star
3

redcloth-parslet

Rewrite of RedCloth in Parslet
Ruby
15
star
4

radiant-vhost-extension

Like the multi_site extension but each domain appears to operate independently with its own scoped pages, snippets, and layouts. Host multiple, independent web sites. Right now only works with Radiant 0.6.9
8
star
5

paa5

A PaaS on your own server for about $5 a month.
Ruby
7
star
6

radiant-page_attachments_xsendfile-extension

Works with the page_attachments extension to make attached files available under the page they're attached to, so you can link to files at sane URLs. Also uses X-Sendfile to speed up the ResponseCache. N.B. the performance warning in the README
Ruby
6
star
7

redcloth-treetop

Just playing around with treetop; seeing how well/fast it would work for RedCloth.
Ruby
3
star
8

radiant-find_replace-extension

Mass find and replace with Radiant.
Ruby
3
star
9

camo_image_tag

Rails plugin to rewrite any image URIs passed to image_tag to proxy through camo
Ruby
2
star
10

try-redcloth

A little sinatra app to serve up interactive RedCloth on redcloth.org
JavaScript
2
star
11

radiant-redcloth4-extension

Overrides Radiant's packaged RedCloth version so you can use a newer RedCloth gem.
Ruby
2
star
12

redcloth-upwards

Framework for comparing prototypes of the next version of RedCloth
Ruby
2
star
13

dvorak-typing-tutor

CoffeeScript
1
star
14

good_food

Our recipes
1
star
15

radiant-draftable-extension

Lets you work on a draft copy of a public page.
Ruby
1
star
16

redsnakephilly2012

Talk on RedCloth that I gave at RedSnakePhilly, 2012. 3D presentation best viewed in Chrome.
Ruby
1
star
17

radiant-no_dev_cache-extension

Tiny little extension to disable the cache in dev mode
Ruby
1
star
18

radiant-comments

Radiant Comments with some fixes
Ruby
1
star
19

truxi

PHLSW 2012
Ruby
1
star
20

CreditDisputeHub

Ruby
1
star