jgarber / redcloth

RedCloth is a Ruby library for converting Textile into HTML.

jgarber (author)
Wed Feb 18 13:11:49 -0800 2009
commit  35753ec72d0e691875fcc2f3df36e813a8636eb9
tree    698274edaebb8cb7e5541dea98103b619dc4a19d
parent  2782d23c76e20fa2688dad9f148595140c0c3b64 parent  48085584e5e33cdf0d2e3537a4358e5826d9aac1
redcloth / README
100644 172 lines (105 sloc) 4.208 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
= RedCloth - Textile parser for Ruby
 
Homepage:: http://redcloth.org
Author:: Jason Garber
Copyright:: (c) 2008 Jason Garber
License:: MIT
 
(See http://redcloth.org/textile/ 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. Binary gems are provided for JRuby and Win32 platforms.
 
RedCloth can be compiled with <tt>rake compile</tt>. Ragel 6.3 or greater and the
echoe gem are needed to build, compile, and package RedCloth. Again, Ragel and echoe are NOT needed to simply use RedCloth.
 
You can cross-compile for JRuby with rake java compile and for Win32 with rake mingw compile.
 
== Using RedCloth
 
RedCloth is simply an extension of the String class, which 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)
 
== 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.
 
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>
 
== 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
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>
 
== 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|