RedCloth 4.1.0-universal-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of RedCloth might be problematic. Click here for more details.
- data/CHANGELOG +103 -0
- data/COPYING +18 -0
- data/Manifest +57 -0
- data/README +156 -0
- data/Rakefile +205 -0
- data/RedCloth.gemspec +141 -0
- data/bin/redcloth +28 -0
- data/ext/mingw-rbconfig.rb +176 -0
- data/ext/redcloth_scan/extconf.rb +9 -0
- data/ext/redcloth_scan/redcloth.h +164 -0
- data/ext/redcloth_scan/redcloth_attributes.c.rl +56 -0
- data/ext/redcloth_scan/redcloth_attributes.java.rl +96 -0
- data/ext/redcloth_scan/redcloth_attributes.rl +33 -0
- data/ext/redcloth_scan/redcloth_common.c.rl +18 -0
- data/ext/redcloth_scan/redcloth_common.java.rl +18 -0
- data/ext/redcloth_scan/redcloth_common.rl +111 -0
- data/ext/redcloth_scan/redcloth_inline.c.rl +159 -0
- data/ext/redcloth_scan/redcloth_inline.java.rl +108 -0
- data/ext/redcloth_scan/redcloth_inline.rl +157 -0
- data/ext/redcloth_scan/redcloth_scan.c.rl +227 -0
- data/ext/redcloth_scan/redcloth_scan.java.rl +555 -0
- data/ext/redcloth_scan/redcloth_scan.rl +323 -0
- data/extras/ragel_profiler.rb +73 -0
- data/lib/case_sensitive_require/RedCloth.rb +6 -0
- data/lib/redcloth.rb +37 -0
- data/lib/redcloth/erb_extension.rb +27 -0
- data/lib/redcloth/formatters/base.rb +57 -0
- data/lib/redcloth/formatters/html.rb +349 -0
- data/lib/redcloth/formatters/latex.rb +249 -0
- data/lib/redcloth/formatters/latex_entities.yml +2414 -0
- data/lib/redcloth/textile_doc.rb +105 -0
- data/lib/redcloth/version.rb +28 -0
- data/lib/redcloth_scan.jar +0 -0
- data/setup.rb +1585 -0
- data/test/basic.yml +870 -0
- data/test/code.yml +229 -0
- data/test/definitions.yml +82 -0
- data/test/extra_whitespace.yml +64 -0
- data/test/filter_html.yml +177 -0
- data/test/filter_pba.yml +20 -0
- data/test/helper.rb +108 -0
- data/test/html.yml +305 -0
- data/test/images.yml +246 -0
- data/test/instiki.yml +38 -0
- data/test/links.yml +259 -0
- data/test/lists.yml +283 -0
- data/test/poignant.yml +89 -0
- data/test/sanitize_html.yml +42 -0
- data/test/table.yml +267 -0
- data/test/test_custom_tags.rb +46 -0
- data/test/test_erb.rb +13 -0
- data/test/test_extensions.rb +31 -0
- data/test/test_formatters.rb +24 -0
- data/test/test_parser.rb +73 -0
- data/test/test_restrictions.rb +41 -0
- data/test/textism.yml +480 -0
- data/test/threshold.yml +772 -0
- data/test/validate_fixtures.rb +73 -0
- metadata +139 -0
@@ -0,0 +1,323 @@
|
|
1
|
+
/*
|
2
|
+
* redcloth_scan.rl
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008 Jason Garber
|
5
|
+
*/
|
6
|
+
%%{
|
7
|
+
|
8
|
+
machine redcloth_scan;
|
9
|
+
|
10
|
+
# blocks
|
11
|
+
notextile_tag_start = "<notextile>" ;
|
12
|
+
notextile_tag_end = "</notextile>" LF? ;
|
13
|
+
noparagraph_line_start = " "+ ;
|
14
|
+
notextile_block_start = ( "notextile" >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) " "+ ) ;
|
15
|
+
pre_tag_start = "<pre" [^>]* ">" (space* "<code>")? ;
|
16
|
+
pre_tag_end = ("</code>" space*)? "</pre>" LF? ;
|
17
|
+
pre_block_start = ( "pre" >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) " "+ ) ;
|
18
|
+
bc_start = ( "bc" >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) " "+ ) ;
|
19
|
+
bq_start = ( "bq" >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) ( ":" %A uri %{ STORE("cite"); } )? " "+ ) ;
|
20
|
+
non_ac_btype = ( "bq" | "bc" | "pre" | "notextile" );
|
21
|
+
btype = (alpha alnum*) -- (non_ac_btype | "fn" digit+);
|
22
|
+
block_start = ( btype >A %{ STORE("type"); } A C :> "." ( "." %extend | "" ) " "+ ) >B %{ STORE_B("fallback"); };
|
23
|
+
all_btypes = btype | non_ac_btype;
|
24
|
+
next_block_start = ( all_btypes A_noactions C_noactions :> "."+ " " ) >A @{ p = reg - 1; } ;
|
25
|
+
double_return = LF{2,} ;
|
26
|
+
block_end = ( double_return | EOF );
|
27
|
+
ftype = ( "fn" >A %{ STORE("type"); } digit+ >A %{ STORE("id"); } ) ;
|
28
|
+
footnote_start = ( ftype A C :> dotspace ) ;
|
29
|
+
ul = "*" %{nest++; list_type = "ul";};
|
30
|
+
ol = "#" %{nest++; list_type = "ol";};
|
31
|
+
ul_start = ( ul | ol )* ul A C :> " "+ ;
|
32
|
+
ol_start = ( ul | ol )* ol N A C :> " "+ ;
|
33
|
+
list_start = ( ul_start | ol_start ) >{nest = 0;} ;
|
34
|
+
dt_start = "-" . " "+ ;
|
35
|
+
dd_start = ":=" ;
|
36
|
+
long_dd = dd_start " "* LF %{ ADD_BLOCK(); ASET("type", "dd"); } any+ >A %{ TRANSFORM("text"); } :>> "=:" ;
|
37
|
+
dl_start = (dt_start mtext (LF dt_start mtext)* " "* dd_start) ;
|
38
|
+
blank_line = LF;
|
39
|
+
link_alias = ( "[" >{ ASET("type", "ignore"); } %A chars %T "]" %A uri %{ STORE_URL("href"); } ) ;
|
40
|
+
|
41
|
+
# image lookahead
|
42
|
+
IMG_A_LEFT = "<" %{ ASET("float", "left"); } ;
|
43
|
+
IMG_A_RIGHT = ">" %{ ASET("float", "right"); } ;
|
44
|
+
aligned_image = ( "["? "!" (IMG_A_LEFT | IMG_A_RIGHT) ) >A @{ p = reg - 1; } ;
|
45
|
+
|
46
|
+
# html blocks
|
47
|
+
BlockTagName = Name - ("pre" | "notextile" | "a" | "applet" | "basefont" | "bdo" | "br" | "font" | "iframe" | "img" | "map" | "object" | "param" | "q" | "script" | "span" | "sub" | "sup" | "abbr" | "acronym" | "cite" | "code" | "del" | "dfn" | "em" | "ins" | "kbd" | "samp" | "strong" | "var" | "b" | "big" | "i" | "s" | "small" | "strike" | "tt" | "u");
|
48
|
+
block_start_tag = "<" BlockTagName space+ AttrSet* (AttrEnd)? ">" | "<" BlockTagName ">";
|
49
|
+
block_empty_tag = "<" BlockTagName space+ AttrSet* (AttrEnd)? "/>" | "<" BlockTagName "/>" ;
|
50
|
+
block_end_tag = "</" BlockTagName space* ">" ;
|
51
|
+
html_start = indent >B %{STORE_B("indent_before_start");} block_start_tag >B %{STORE_B("start_tag");} indent >B %{STORE_B("indent_after_start");} ;
|
52
|
+
html_end = indent >B %{STORE_B("indent_before_end");} block_end_tag >B %{STORE_B("end_tag");} (indent LF?) >B %{STORE_B("indent_after_end");} ;
|
53
|
+
standalone_html = indent (block_start_tag | block_empty_tag | block_end_tag) indent (LF+ | EOF);
|
54
|
+
html_end_terminating_block = ( LF indent block_end_tag ) >A @{ p = reg - 1; } ;
|
55
|
+
|
56
|
+
# tables
|
57
|
+
para = ( default+ ) -- LF ;
|
58
|
+
btext = para ( LF{2} )? ;
|
59
|
+
tddef = ( D? S A C :> dotspace ) ;
|
60
|
+
td = ( tddef? btext >A %T :> "|" >{PASS(table, "text", "td");} ) >X ;
|
61
|
+
trdef = ( A C :> dotspace ) ;
|
62
|
+
tr = ( trdef? "|" %{INLINE(table, "tr_open");} td+ ) >X %{INLINE(table, "tr_close");} ;
|
63
|
+
trows = ( tr (LF >X tr)* ) ;
|
64
|
+
tdef = ( "table" >X A C :> dotspace LF ) ;
|
65
|
+
table = ( tdef? trows >{CLEAR(table); INLINE(table, "table_open"); RESET_REG();} ) ;
|
66
|
+
|
67
|
+
# info
|
68
|
+
redcloth_version = ("RedCloth" >A ("::" | " " ) "VERSION"i ":"? " ")? %{STORE("prefix");} "RedCloth::VERSION" (LF* EOF | double_return) ;
|
69
|
+
|
70
|
+
pre_tag := |*
|
71
|
+
pre_tag_end { CAT(block); DONE(block); fgoto main; };
|
72
|
+
default => esc_pre;
|
73
|
+
*|;
|
74
|
+
|
75
|
+
pre_block := |*
|
76
|
+
EOF {
|
77
|
+
ADD_BLOCKCODE();
|
78
|
+
fgoto main;
|
79
|
+
};
|
80
|
+
double_return {
|
81
|
+
if (IS_NOT_EXTENDED()) {
|
82
|
+
ADD_BLOCKCODE();
|
83
|
+
fgoto main;
|
84
|
+
} else {
|
85
|
+
ADD_EXTENDED_BLOCKCODE();
|
86
|
+
}
|
87
|
+
};
|
88
|
+
double_return next_block_start {
|
89
|
+
if (IS_NOT_EXTENDED()) {
|
90
|
+
ADD_BLOCKCODE();
|
91
|
+
fgoto main;
|
92
|
+
} else {
|
93
|
+
ADD_EXTENDED_BLOCKCODE();
|
94
|
+
END_EXTENDED();
|
95
|
+
fgoto main;
|
96
|
+
}
|
97
|
+
};
|
98
|
+
default => esc_pre;
|
99
|
+
*|;
|
100
|
+
|
101
|
+
script_tag := |*
|
102
|
+
script_tag_end { CAT(block); ASET("type", "ignore"); ADD_BLOCK(); fgoto main; };
|
103
|
+
EOF { ASET("type", "ignore"); ADD_BLOCK(); fgoto main; };
|
104
|
+
default => cat;
|
105
|
+
*|;
|
106
|
+
|
107
|
+
noparagraph_line := |*
|
108
|
+
LF { ADD_BLOCK(); fgoto main; };
|
109
|
+
default => cat;
|
110
|
+
*|;
|
111
|
+
|
112
|
+
notextile_tag := |*
|
113
|
+
notextile_tag_end { ADD_BLOCK(); fgoto main; };
|
114
|
+
default => cat;
|
115
|
+
*|;
|
116
|
+
|
117
|
+
notextile_block := |*
|
118
|
+
EOF {
|
119
|
+
ADD_BLOCK();
|
120
|
+
fgoto main;
|
121
|
+
};
|
122
|
+
double_return {
|
123
|
+
if (IS_NOT_EXTENDED()) {
|
124
|
+
ADD_BLOCK();
|
125
|
+
CAT(html);
|
126
|
+
fgoto main;
|
127
|
+
} else {
|
128
|
+
CAT(block);
|
129
|
+
ADD_EXTENDED_BLOCK();
|
130
|
+
CAT(html);
|
131
|
+
}
|
132
|
+
};
|
133
|
+
double_return next_block_start {
|
134
|
+
if (IS_NOT_EXTENDED()) {
|
135
|
+
ADD_BLOCK();
|
136
|
+
CAT(html);
|
137
|
+
fgoto main;
|
138
|
+
} else {
|
139
|
+
CAT(block);
|
140
|
+
ADD_EXTENDED_BLOCK();
|
141
|
+
END_EXTENDED();
|
142
|
+
fgoto main;
|
143
|
+
}
|
144
|
+
};
|
145
|
+
default => cat;
|
146
|
+
*|;
|
147
|
+
|
148
|
+
html := |*
|
149
|
+
html_end { ADD_BLOCK(); fgoto main; };
|
150
|
+
default => cat;
|
151
|
+
*|;
|
152
|
+
|
153
|
+
bc := |*
|
154
|
+
EOF {
|
155
|
+
ADD_BLOCKCODE();
|
156
|
+
INLINE(html, "bc_close");
|
157
|
+
SET_PLAIN_BLOCK("p");
|
158
|
+
fgoto main;
|
159
|
+
};
|
160
|
+
double_return {
|
161
|
+
if (IS_NOT_EXTENDED()) {
|
162
|
+
ADD_BLOCKCODE();
|
163
|
+
INLINE(html, "bc_close");
|
164
|
+
SET_PLAIN_BLOCK("p");
|
165
|
+
fgoto main;
|
166
|
+
} else {
|
167
|
+
ADD_EXTENDED_BLOCKCODE();
|
168
|
+
CAT(html);
|
169
|
+
}
|
170
|
+
};
|
171
|
+
double_return next_block_start {
|
172
|
+
if (IS_NOT_EXTENDED()) {
|
173
|
+
ADD_BLOCKCODE();
|
174
|
+
INLINE(html, "bc_close");
|
175
|
+
SET_PLAIN_BLOCK("p");
|
176
|
+
fgoto main;
|
177
|
+
} else {
|
178
|
+
ADD_EXTENDED_BLOCKCODE();
|
179
|
+
CAT(html);
|
180
|
+
INLINE(html, "bc_close");
|
181
|
+
SET_PLAIN_BLOCK("p");
|
182
|
+
END_EXTENDED();
|
183
|
+
fgoto main;
|
184
|
+
}
|
185
|
+
};
|
186
|
+
default => esc_pre;
|
187
|
+
*|;
|
188
|
+
|
189
|
+
bq := |*
|
190
|
+
EOF {
|
191
|
+
ADD_BLOCK();
|
192
|
+
INLINE(html, "bq_close");
|
193
|
+
fgoto main;
|
194
|
+
};
|
195
|
+
double_return {
|
196
|
+
if (IS_NOT_EXTENDED()) {
|
197
|
+
ADD_BLOCK();
|
198
|
+
INLINE(html, "bq_close");
|
199
|
+
fgoto main;
|
200
|
+
} else {
|
201
|
+
ADD_EXTENDED_BLOCK();
|
202
|
+
}
|
203
|
+
};
|
204
|
+
double_return next_block_start {
|
205
|
+
if (IS_NOT_EXTENDED()) {
|
206
|
+
ADD_BLOCK();
|
207
|
+
INLINE(html, "bq_close");
|
208
|
+
fgoto main;
|
209
|
+
} else {
|
210
|
+
ADD_EXTENDED_BLOCK();
|
211
|
+
INLINE(html, "bq_close");
|
212
|
+
END_EXTENDED();
|
213
|
+
fgoto main;
|
214
|
+
}
|
215
|
+
};
|
216
|
+
html_end_terminating_block {
|
217
|
+
if (IS_NOT_EXTENDED()) {
|
218
|
+
ADD_BLOCK();
|
219
|
+
INLINE(html, "bq_close");
|
220
|
+
fgoto main;
|
221
|
+
} else {
|
222
|
+
ADD_EXTENDED_BLOCK();
|
223
|
+
INLINE(html, "bq_close");
|
224
|
+
END_EXTENDED();
|
225
|
+
fgoto main;
|
226
|
+
}
|
227
|
+
};
|
228
|
+
default => cat;
|
229
|
+
*|;
|
230
|
+
|
231
|
+
block := |*
|
232
|
+
EOF {
|
233
|
+
ADD_BLOCK();
|
234
|
+
fgoto main;
|
235
|
+
};
|
236
|
+
double_return {
|
237
|
+
if (IS_NOT_EXTENDED()) {
|
238
|
+
ADD_BLOCK();
|
239
|
+
fgoto main;
|
240
|
+
} else {
|
241
|
+
ADD_EXTENDED_BLOCK();
|
242
|
+
}
|
243
|
+
};
|
244
|
+
double_return next_block_start {
|
245
|
+
if (IS_NOT_EXTENDED()) {
|
246
|
+
ADD_BLOCK();
|
247
|
+
fgoto main;
|
248
|
+
} else {
|
249
|
+
ADD_EXTENDED_BLOCK();
|
250
|
+
END_EXTENDED();
|
251
|
+
fgoto main;
|
252
|
+
}
|
253
|
+
};
|
254
|
+
html_end_terminating_block {
|
255
|
+
if (IS_NOT_EXTENDED()) {
|
256
|
+
ADD_BLOCK();
|
257
|
+
fgoto main;
|
258
|
+
} else {
|
259
|
+
ADD_EXTENDED_BLOCK();
|
260
|
+
END_EXTENDED();
|
261
|
+
fgoto main;
|
262
|
+
}
|
263
|
+
};
|
264
|
+
LF list_start {
|
265
|
+
ADD_BLOCK();
|
266
|
+
CLEAR_LIST();
|
267
|
+
LIST_ITEM();
|
268
|
+
fgoto list;
|
269
|
+
};
|
270
|
+
|
271
|
+
default => cat;
|
272
|
+
*|;
|
273
|
+
|
274
|
+
footnote := |*
|
275
|
+
block_end { ADD_BLOCK(); fgoto main; };
|
276
|
+
default => cat;
|
277
|
+
*|;
|
278
|
+
|
279
|
+
list := |*
|
280
|
+
LF list_start { ADD_BLOCK(); LIST_ITEM(); };
|
281
|
+
block_end { ADD_BLOCK(); nest = 0; LIST_CLOSE(); fgoto main; };
|
282
|
+
default => cat;
|
283
|
+
*|;
|
284
|
+
|
285
|
+
dl := |*
|
286
|
+
LF dt_start { ADD_BLOCK(); ASET("type", "dt"); };
|
287
|
+
dd_start { ADD_BLOCK(); ASET("type", "dd"); };
|
288
|
+
long_dd { INLINE(html, "dd"); CLEAR_REGS(); };
|
289
|
+
block_end { ADD_BLOCK(); INLINE(html, "dl_close"); fgoto main; };
|
290
|
+
default => cat;
|
291
|
+
*|;
|
292
|
+
|
293
|
+
main := |*
|
294
|
+
noparagraph_line_start { ASET("type", "ignored_line"); fgoto noparagraph_line; };
|
295
|
+
notextile_tag_start { ASET("type", "notextile"); fgoto notextile_tag; };
|
296
|
+
notextile_block_start { ASET("type", "notextile"); fgoto notextile_block; };
|
297
|
+
script_tag_start { CAT(block); fgoto script_tag; };
|
298
|
+
pre_tag_start { ASET("type", "notextile"); CAT(block); fgoto pre_tag; };
|
299
|
+
pre_block_start { fgoto pre_block; };
|
300
|
+
standalone_html { ASET("type", "html"); CAT(block); ADD_BLOCK(); };
|
301
|
+
html_start { ASET("type", "html_block"); fgoto html; };
|
302
|
+
bc_start { INLINE(html, "bc_open"); ASET("type", "code"); SET_PLAIN_BLOCK("code"); fgoto bc; };
|
303
|
+
bq_start { INLINE(html, "bq_open"); ASET("type", "p"); fgoto bq; };
|
304
|
+
block_start { fgoto block; };
|
305
|
+
footnote_start { fgoto footnote; };
|
306
|
+
list_start { CLEAR_LIST(); LIST_ITEM(); fgoto list; };
|
307
|
+
dl_start { p = ts; INLINE(html, "dl_open"); ASET("type", "dt"); fgoto dl; };
|
308
|
+
table { INLINE(table, "table_close"); DONE(table); fgoto block; };
|
309
|
+
link_alias { STORE_LINK_ALIAS(); DONE(block); };
|
310
|
+
aligned_image { RESET_TYPE(); fgoto block; };
|
311
|
+
redcloth_version { INLINE(html, "redcloth_version"); };
|
312
|
+
blank_line => cat;
|
313
|
+
default
|
314
|
+
{
|
315
|
+
CLEAR_REGS();
|
316
|
+
RESET_TYPE();
|
317
|
+
CAT(block);
|
318
|
+
fgoto block;
|
319
|
+
};
|
320
|
+
EOF;
|
321
|
+
*|;
|
322
|
+
|
323
|
+
}%%;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class RagelProfiler
|
2
|
+
MEM_CONVERSION = 1024
|
3
|
+
|
4
|
+
COMMANDS = { :compile => %w(ragel rlgen-cd gcc-4.0 gnumake cc1),
|
5
|
+
:test => %w(ruby) }
|
6
|
+
|
7
|
+
FIELDS = %w(compile_time compile_max_rss test_time test_max_rss ext_so_size)
|
8
|
+
|
9
|
+
@@results = {}
|
10
|
+
|
11
|
+
def initialize(name)
|
12
|
+
@name = name
|
13
|
+
@@results[name] = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def measure(type)
|
17
|
+
raise "not a valid type" unless COMMANDS.keys.include?(type)
|
18
|
+
regex = COMMANDS[type].map {|c| Regexp.escape(c) }.join("|")
|
19
|
+
t = Thread.new do
|
20
|
+
Thread.current[:max] = 0
|
21
|
+
loop do
|
22
|
+
Thread.current[:max] = [run(regex), Thread.current[:max]].max
|
23
|
+
sleep 0.5
|
24
|
+
end
|
25
|
+
end
|
26
|
+
begin_time = Time.now
|
27
|
+
yield
|
28
|
+
total_time = Time.now - begin_time
|
29
|
+
|
30
|
+
t.kill
|
31
|
+
store_result(type, "time", total_time)
|
32
|
+
store_result(type, "max_rss", t[:max])
|
33
|
+
end
|
34
|
+
|
35
|
+
def ext_size(ext_so)
|
36
|
+
store_result(:ext_so, "size", File.size(ext_so) / MEM_CONVERSION)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.results
|
40
|
+
out = []
|
41
|
+
out << "name\t" + FIELDS.join("\t")
|
42
|
+
@@results.each do |name, results|
|
43
|
+
out << [name, results ].flatten.join("\t")
|
44
|
+
end
|
45
|
+
out.join("\n")
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def store_result(type, metric, value)
|
51
|
+
index = FIELDS.index("#{type.to_s}_#{metric}")
|
52
|
+
@@results[@name][index] = "%.2f" % value
|
53
|
+
end
|
54
|
+
|
55
|
+
def run(ps_regex)
|
56
|
+
ps_command = "ps axucww"
|
57
|
+
ps_output = `#{ps_command}`
|
58
|
+
fields = ps_output.to_a.first.downcase.split
|
59
|
+
memory_index = fields.index("rss")
|
60
|
+
pid_index = fields.index("pid")
|
61
|
+
ppid_index = fields.index("ppid")
|
62
|
+
total = ps_output.grep(/(#{ps_regex})\s+$/i).map do |com|
|
63
|
+
Float(com.split[memory_index]).abs
|
64
|
+
end.inject(0) { |s,v| s += v }
|
65
|
+
if total
|
66
|
+
return total/MEM_CONVERSION
|
67
|
+
else
|
68
|
+
STDERR.puts "Command not found. No processes found matching #{ps_regex}."
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# A workaround to make Rails 2.1 gem dependency easier on case-sensitive filesystems.
|
2
|
+
# Since the gem name is RedCloth and the file is redcloth.rb, config.gem 'RedCloth' doesn't
|
3
|
+
# work. You'd have to use config.gem 'RedCloth', :lib => 'redcloth', and that's not
|
4
|
+
# immediately obvious. This file remedies that.
|
5
|
+
#
|
6
|
+
require File.join(File.dirname(__FILE__), '..', 'redcloth')
|
data/lib/redcloth.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
# If this is a frozen gem in Rails 2.1 and RedCloth 3.x was already
|
4
|
+
# loaded by Rails' ActionView::Helpers::TextHelper, the user will get
|
5
|
+
# "redcloth_scan.bundle: Class is not a module (TypeError)"
|
6
|
+
# This hack is to work around that Rails loading problem. The problem
|
7
|
+
# appears to be fixed in Edge Rails [51e4106].
|
8
|
+
Object.send(:remove_const, :RedCloth) if Object.const_defined?(:RedCloth) && RedCloth.is_a?(Class)
|
9
|
+
|
10
|
+
require 'redcloth_scan'
|
11
|
+
require 'redcloth/version'
|
12
|
+
require 'redcloth/textile_doc'
|
13
|
+
require 'redcloth/formatters/base'
|
14
|
+
require 'redcloth/formatters/html'
|
15
|
+
require 'redcloth/formatters/latex'
|
16
|
+
|
17
|
+
module RedCloth
|
18
|
+
|
19
|
+
# A convenience method for creating a new TextileDoc. See
|
20
|
+
# RedCloth::TextileDoc.
|
21
|
+
def self.new( *args, &block )
|
22
|
+
RedCloth::TextileDoc.new( *args, &block )
|
23
|
+
end
|
24
|
+
|
25
|
+
# Include extension modules (if any) in TextileDoc.
|
26
|
+
def self.include(*args)
|
27
|
+
RedCloth::TextileDoc.send(:include, *args)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
require 'erb'
|
34
|
+
require 'redcloth/erb_extension'
|
35
|
+
include ERB::Util
|
36
|
+
rescue LoadError
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class ERB
|
2
|
+
module Util
|
3
|
+
|
4
|
+
#
|
5
|
+
# A utility method for transforming Textile in _s_ to HTML.
|
6
|
+
#
|
7
|
+
# require "erb"
|
8
|
+
# include ERB::Util
|
9
|
+
#
|
10
|
+
# puts textilize("Isn't ERB *great*?")
|
11
|
+
#
|
12
|
+
# _Generates_
|
13
|
+
#
|
14
|
+
# <p>Isn’t <span class="caps">ERB</span> <strong>great</strong>?</p>
|
15
|
+
#
|
16
|
+
def textilize( s )
|
17
|
+
if s && s.respond_to?(:to_s)
|
18
|
+
RedCloth.new( s.to_s ).to_html
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
alias t textilize
|
23
|
+
module_function :t
|
24
|
+
module_function :textilize
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|