jeremy-RedCloth 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGELOG +135 -0
  2. data/COPYING +18 -0
  3. data/Manifest +56 -0
  4. data/README +171 -0
  5. data/Rakefile +205 -0
  6. data/bin/redcloth +28 -0
  7. data/ext/mingw-rbconfig.rb +176 -0
  8. data/ext/redcloth_scan/extconf.rb +9 -0
  9. data/ext/redcloth_scan/redcloth.h +178 -0
  10. data/ext/redcloth_scan/redcloth_attributes.c.rl +56 -0
  11. data/ext/redcloth_scan/redcloth_attributes.java.rl +96 -0
  12. data/ext/redcloth_scan/redcloth_attributes.rl +33 -0
  13. data/ext/redcloth_scan/redcloth_common.c.rl +18 -0
  14. data/ext/redcloth_scan/redcloth_common.java.rl +18 -0
  15. data/ext/redcloth_scan/redcloth_common.rl +111 -0
  16. data/ext/redcloth_scan/redcloth_inline.c.rl +159 -0
  17. data/ext/redcloth_scan/redcloth_inline.java.rl +108 -0
  18. data/ext/redcloth_scan/redcloth_inline.rl +159 -0
  19. data/ext/redcloth_scan/redcloth_scan.c.rl +237 -0
  20. data/ext/redcloth_scan/redcloth_scan.java.rl +573 -0
  21. data/ext/redcloth_scan/redcloth_scan.rl +325 -0
  22. data/extras/ragel_profiler.rb +73 -0
  23. data/lib/case_sensitive_require/RedCloth.rb +6 -0
  24. data/lib/redcloth.rb +37 -0
  25. data/lib/redcloth/erb_extension.rb +27 -0
  26. data/lib/redcloth/formatters/base.rb +57 -0
  27. data/lib/redcloth/formatters/html.rb +353 -0
  28. data/lib/redcloth/formatters/latex.rb +275 -0
  29. data/lib/redcloth/formatters/latex_entities.yml +2414 -0
  30. data/lib/redcloth/textile_doc.rb +103 -0
  31. data/lib/redcloth/version.rb +28 -0
  32. data/setup.rb +1585 -0
  33. data/test/basic.yml +922 -0
  34. data/test/code.yml +229 -0
  35. data/test/definitions.yml +82 -0
  36. data/test/extra_whitespace.yml +64 -0
  37. data/test/filter_html.yml +177 -0
  38. data/test/filter_pba.yml +20 -0
  39. data/test/helper.rb +108 -0
  40. data/test/html.yml +311 -0
  41. data/test/images.yml +254 -0
  42. data/test/instiki.yml +38 -0
  43. data/test/links.yml +275 -0
  44. data/test/lists.yml +283 -0
  45. data/test/poignant.yml +89 -0
  46. data/test/sanitize_html.yml +42 -0
  47. data/test/table.yml +336 -0
  48. data/test/test_custom_tags.rb +58 -0
  49. data/test/test_erb.rb +13 -0
  50. data/test/test_extensions.rb +31 -0
  51. data/test/test_formatters.rb +24 -0
  52. data/test/test_parser.rb +73 -0
  53. data/test/test_restrictions.rb +41 -0
  54. data/test/textism.yml +480 -0
  55. data/test/threshold.yml +772 -0
  56. data/test/validate_fixtures.rb +74 -0
  57. metadata +133 -0
@@ -0,0 +1,89 @@
1
+ --- # Tests from the (Poignant Guide)
2
+ in: >
3
+ h3. False
4
+
5
+
6
+ !<i/blix-neg.gif(Shape of a cat.)!
7
+
8
+
9
+ _The cat Trady Blix. Frozen in emptiness. Immaculate whiskers rigid. Placid
10
+ eyes of lake. Tail of warm icicle. Sponsored by a Very Powerful Pause Button._
11
+
12
+
13
+ The darkness surrounding Blix can be called *negative space*. Hang on to that phrase.
14
+ Let it suggest that the emptiness has a negative connotation. In a similar way,
15
+ @nil@ has a slightly sour note that it whistles.
16
+
17
+
18
+ Generally speaking, everything in Ruby has a positive charge to it. This spark
19
+ flows through strings, numbers, regexps, all of it. Only two keywords wear a
20
+ shady cloak: @nil@ and @false@ draggin us down.
21
+
22
+
23
+ You can test that charge with an @if@ keyword. It looks very much like the
24
+ @do@ blocks we saw in the last chapter, in that both end with an @end@.
25
+
26
+
27
+ <pre>
28
+ if plastic_cup
29
+ print "Plastic cup is on the up 'n' up!"
30
+ end
31
+ </pre>
32
+
33
+
34
+ If @plastic_cup@ contains either @nil@ or @false@, you won't see anything print
35
+ to the screen. They're not on the @if@ guest list. So @if@ isn't going to run
36
+ any of the code it's protecting.
37
+
38
+
39
+ But @nil@ and @false@ need not walk away in shame. They may be of questionable
40
+ character, but @unless@ runs a smaller establishment that caters to the bedraggled.
41
+ The @unless@ keyword has a policy of only allowing those with a negative charge in.
42
+ Who are: @nil@ and @false@.
43
+
44
+
45
+ <pre>
46
+ unless plastic_cup
47
+ print "Plastic cup is on the down low."
48
+ end
49
+ </pre>
50
+
51
+
52
+ You can also use @if@ and @unless@ at the end of a single line of code, if that's
53
+ all that is being protected.
54
+
55
+
56
+ <pre>
57
+ print "Yeah, plastic cup is up again!" if plastic_cup
58
+ print "Hardly. It's down." unless plastic_cup
59
+ </pre>
60
+
61
+
62
+ Now that you've met @false@, I'm sure you can see what's on next.
63
+
64
+ html: |-
65
+ <h3>False</h3>
66
+ <p style="float:left;"><img src="i/blix-neg.gif" title="Shape of a cat." alt="Shape of a cat." /></p>
67
+ <p><em>The cat Trady Blix. Frozen in emptiness. Immaculate whiskers rigid. Placid eyes of lake. Tail of warm icicle. Sponsored by a Very Powerful Pause Button.</em></p>
68
+ <p>The darkness surrounding Blix can be called <strong>negative space</strong>. Hang on to that phrase. Let it suggest that the emptiness has a negative connotation. In a similar way, <code>nil</code> has a slightly sour note that it whistles.</p>
69
+ <p>Generally speaking, everything in Ruby has a positive charge to it. This spark flows through strings, numbers, regexps, all of it. Only two keywords wear a shady cloak: <code>nil</code> and <code>false</code> draggin us down.</p>
70
+ <p>You can test that charge with an <code>if</code> keyword. It looks very much like the <code>do</code> blocks we saw in the last chapter, in that both end with an <code>end</code>.</p>
71
+ <pre>
72
+ if plastic_cup
73
+ print "Plastic cup is on the up 'n' up!"
74
+ end
75
+ </pre>
76
+ <p>If <code>plastic_cup</code> contains either <code>nil</code> or <code>false</code>, you won&#8217;t see anything print to the screen. They&#8217;re not on the <code>if</code> guest list. So <code>if</code> isn&#8217;t going to run any of the code it&#8217;s protecting.</p>
77
+ <p>But <code>nil</code> and <code>false</code> need not walk away in shame. They may be of questionable character, but <code>unless</code> runs a smaller establishment that caters to the bedraggled. The <code>unless</code> keyword has a policy of only allowing those with a negative charge in. Who are: <code>nil</code> and <code>false</code>.</p>
78
+ <pre>
79
+ unless plastic_cup
80
+ print "Plastic cup is on the down low."
81
+ end
82
+ </pre>
83
+ <p>You can also use <code>if</code> and <code>unless</code> at the end of a single line of code, if that&#8217;s all that is being protected.</p>
84
+ <pre>
85
+ print "Yeah, plastic cup is up again!" if plastic_cup
86
+ print "Hardly. It's down." unless plastic_cup
87
+ </pre>
88
+ <p>Now that you&#8217;ve met <code>false</code>, I&#8217;m sure you can see what&#8217;s on next.</p>
89
+
@@ -0,0 +1,42 @@
1
+ ---
2
+ in: Just a little harmless xss <script src=http://ha.ckers.org/xss.js>stuff</script>.
3
+ sanitized_html: <p>Just a little harmless xss stuff.</p>
4
+ ---
5
+ in: Here's a bad image <img src="JaVaScRiPt:alert('XSS');" />
6
+ sanitized_html: <p>Here&#8217;s a bad image <img /></p>
7
+ ---
8
+ in: Just some random > and < characters, but also a <br/> tag.
9
+ sanitized_html: <p>Just some random &gt; and &lt; characters, but also a <br/> tag.</p>
10
+ ---
11
+ name: processes text beginning with space
12
+ in: ' This began with a space and ends with some XSS: <script type="text/javascript">alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");</script>'
13
+ sanitized_html: 'This began with a space and ends with some <span class="caps">XSS</span>: alert(&#8220;Hai. I`m in ya PC. Makin ya <span class="caps">XSS</span> viruzz! KThxBye&#8221;);'
14
+ ---
15
+ name: processes text in notextile tags
16
+ in: |-
17
+ <notextile>
18
+ The bad tags should be <b>missing</b>: <script type="text/javascript">alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");</script>
19
+ </notextile>
20
+ sanitized_html: |-
21
+ The bad tags should be <b>missing</b>: alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");
22
+ ---
23
+ name: processes text in inline notextile tags
24
+ in: |-
25
+ The bad tags should be <b>missing</b>: <notextile><script type="text/javascript">alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");</script></notextile>
26
+ sanitized_html: |-
27
+ <p>The bad tags should be <b>missing</b>: alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");</p>
28
+ ---
29
+ name: removes script tags
30
+ in: |-
31
+ <script type="text/javascript">
32
+ alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");
33
+ </script>
34
+ sanitized_html: "alert(&#8220;Hai. I`m in ya PC. Makin ya <span class=\"caps\">XSS</span> viruzz! KThxBye&#8221;);"
35
+ ---
36
+ name: removes nested script tags
37
+ in: |-
38
+ <script type="text/javascript"><script>
39
+ alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");
40
+ </script></script>
41
+ sanitized_html: |-
42
+ alert(&#8220;Hai. I`m in ya PC. Makin ya <span class="caps">XSS</span> viruzz! KThxBye&#8221;);
@@ -0,0 +1,336 @@
1
+ ---
2
+ in: |
3
+ |a|b|c|
4
+ |1|2|3|
5
+
6
+ h3. A header after the table
7
+ html: |-
8
+ <table>
9
+ <tr>
10
+ <td>a</td>
11
+ <td>b</td>
12
+ <td>c</td>
13
+ </tr>
14
+ <tr>
15
+ <td>1</td>
16
+ <td>2</td>
17
+ <td>3</td>
18
+ </tr>
19
+ </table>
20
+ <h3>A header after the table</h3>
21
+ latex: |+
22
+ \begin{tabular}{ l l l }
23
+ a & b & c \\
24
+ 1 & 2 & 3 \\
25
+ \end{tabular}
26
+ \subsubsection*{A header after the table}
27
+
28
+ ---
29
+ in: |
30
+ |_. a|_. b|_. c|
31
+ |1|2|3|
32
+ html: |-
33
+ <table>
34
+ <tr>
35
+ <th>a</th>
36
+ <th>b</th>
37
+ <th>c</th>
38
+ </tr>
39
+ <tr>
40
+ <td>1</td>
41
+ <td>2</td>
42
+ <td>3</td>
43
+ </tr>
44
+ </table>
45
+ ---
46
+ in: |-
47
+ |This|is|a|simple|table|
48
+ |This|is|a|simple|row|
49
+ html: |-
50
+ <table>
51
+ <tr>
52
+ <td>This</td>
53
+ <td>is</td>
54
+ <td>a</td>
55
+ <td>simple</td>
56
+ <td>table</td>
57
+ </tr>
58
+ <tr>
59
+ <td>This</td>
60
+ <td>is</td>
61
+ <td>a</td>
62
+ <td>simple</td>
63
+ <td>row</td>
64
+ </tr>
65
+ </table>
66
+ latex: |+
67
+ \begin{tabular}{ l l l l l }
68
+ This & is & a & simple & table \\
69
+ This & is & a & simple & row \\
70
+ \end{tabular}
71
+ ---
72
+ in: |-
73
+ table{border:1px solid black}.
74
+ |This|is|a|row|
75
+ |This|is|a|row|
76
+ html: |-
77
+ <table style="border:1px solid black;">
78
+ <tr>
79
+ <td>This</td>
80
+ <td>is</td>
81
+ <td>a</td>
82
+ <td>row</td>
83
+ </tr>
84
+ <tr>
85
+ <td>This</td>
86
+ <td>is</td>
87
+ <td>a</td>
88
+ <td>row</td>
89
+ </tr>
90
+ </table>
91
+ ---
92
+ in: '{background:#ddd}. |This|is|a|row|'
93
+ html: |-
94
+ <table>
95
+ <tr style="background:#ddd;">
96
+ <td>This</td>
97
+ <td>is</td>
98
+ <td>a</td>
99
+ <td>row</td>
100
+ </tr>
101
+ </table>
102
+ ---
103
+ in: |-
104
+ |a|b|c|
105
+ | |2|3|
106
+ html: |-
107
+ <table>
108
+ <tr>
109
+ <td>a</td>
110
+ <td>b</td>
111
+ <td>c</td>
112
+ </tr>
113
+ <tr>
114
+ <td> </td>
115
+ <td>2</td>
116
+ <td>3</td>
117
+ </tr>
118
+ </table>
119
+ ---
120
+ in: |-
121
+ table{width: 200px; border:2px solid gray;}.
122
+ |_=. Alignment|
123
+ |=. centered|
124
+ |=(. a bit right|
125
+ |=). a bit left|
126
+ |>). almost right|
127
+ |<(. almost left|
128
+ |>. right|
129
+ |<. left|
130
+ html: |-
131
+ <table style="width: 200px; border:2px solid gray;">
132
+ <tr>
133
+ <th style="text-align:center;">Alignment</th>
134
+ </tr>
135
+ <tr>
136
+ <td style="text-align:center;">centered</td>
137
+ </tr>
138
+ <tr>
139
+ <td style="padding-left:1em;text-align:center;">a bit right</td>
140
+ </tr>
141
+ <tr>
142
+ <td style="padding-right:1em;text-align:center;">a bit left</td>
143
+ </tr>
144
+ <tr>
145
+ <td style="padding-right:1em;text-align:right;">almost right</td>
146
+ </tr>
147
+ <tr>
148
+ <td style="padding-left:1em;text-align:left;">almost left</td>
149
+ </tr>
150
+ <tr>
151
+ <td style="text-align:right;">right</td>
152
+ </tr>
153
+ <tr>
154
+ <td style="text-align:left;">left</td>
155
+ </tr>
156
+ </table>
157
+ ---
158
+ in: |-
159
+ |{background:#ddd}. Cell with gray background|Normal cell|
160
+ |\2. Cell spanning 2 columns|
161
+ |/2. Cell spanning 2 rows|one|
162
+ |two|
163
+ |>. Right-aligned cell|<. Left-aligned cell|
164
+ html: |-
165
+ <table>
166
+ <tr>
167
+ <td style="background:#ddd;">Cell with gray background</td>
168
+ <td>Normal cell</td>
169
+ </tr>
170
+ <tr>
171
+ <td colspan="2">Cell spanning 2 columns</td>
172
+ </tr>
173
+ <tr>
174
+ <td rowspan="2">Cell spanning 2 rows</td>
175
+ <td>one</td>
176
+ </tr>
177
+ <tr>
178
+ <td>two</td>
179
+ </tr>
180
+ <tr>
181
+ <td style="text-align:right;">Right-aligned cell</td>
182
+ <td style="text-align:left;">Left-aligned cell</td>
183
+ </tr>
184
+ </table>
185
+ latex: |+
186
+ \begin{tabular}{ l l }
187
+ Cell with gray background & Normal cell \\
188
+ \multicolumn{2}{ l l }{Cell spanning 2 columns} \\
189
+ \multirow{2}{*}{Cell spanning 2 rows} & one \\
190
+ & two \\
191
+ Right-aligned cell & Left-aligned cell \\
192
+ \end{tabular}
193
+ ---
194
+ name: row spanning mid-row
195
+ in: |-
196
+ |1|2|3|
197
+ |1|/3. 2|3|
198
+ |1|3|
199
+ |1|3|
200
+ |1|2|3|
201
+ html: |-
202
+ <table>
203
+ <tr>
204
+ <td>1</td>
205
+ <td>2</td>
206
+ <td>3</td>
207
+ </tr>
208
+ <tr>
209
+ <td>1</td>
210
+ <td rowspan="3">2</td>
211
+ <td>3</td>
212
+ </tr>
213
+ <tr>
214
+ <td>1</td>
215
+ <td>3</td>
216
+ </tr>
217
+ <tr>
218
+ <td>1</td>
219
+ <td>3</td>
220
+ </tr>
221
+ <tr>
222
+ <td>1</td>
223
+ <td>2</td>
224
+ <td>3</td>
225
+ </tr>
226
+ </table>
227
+ latex: |+
228
+ \begin{tabular}{ l l l }
229
+ 1 & 2 & 3 \\
230
+ 1 & \multirow{3}{*}{2} & 3 \\
231
+ 1 & & 3 \\
232
+ 1 & & 3 \\
233
+ 1 & 2 & 3 \\
234
+ \end{tabular}
235
+ ---
236
+ in: |
237
+ {background:#ddd}. |S|Target|Complete|App|Milestone|
238
+ |!/i/g.gif!|11/29/04|11/29/04|011|XML spec complete (KH is on schedule)|
239
+ |!/i/g.gif!|11/22/04|11/22/04|070|Dialog pass 1 builds an index file|
240
+ |!/i/g.gif!|11/24/04|11/24/04|070|Dialog pass 2 98% complete|
241
+ |!/i/g.gif!|11/30/04|11/30/04|070|Feature complete. Passes end-to-end smoke test.|
242
+ |!/i/w.gif!|12/02/04| |011|Dialog pass 1 and 2 complete (98+%)|
243
+ |!/i/w.gif!|12/03/04| |081|Feature complete|
244
+ html: |-
245
+ <table>
246
+ <tr style="background:#ddd;">
247
+ <td>S</td>
248
+ <td>Target</td>
249
+ <td>Complete</td>
250
+ <td>App</td>
251
+ <td>Milestone</td>
252
+ </tr>
253
+ <tr>
254
+ <td><img src="/i/g.gif" alt="" /></td>
255
+ <td>11/29/04</td>
256
+ <td>11/29/04</td>
257
+ <td>011</td>
258
+ <td><span class="caps">XML</span> spec complete (KH is on schedule)</td>
259
+ </tr>
260
+ <tr>
261
+ <td><img src="/i/g.gif" alt="" /></td>
262
+ <td>11/22/04</td>
263
+ <td>11/22/04</td>
264
+ <td>070</td>
265
+ <td>Dialog pass 1 builds an index file</td>
266
+ </tr>
267
+ <tr>
268
+ <td><img src="/i/g.gif" alt="" /></td>
269
+ <td>11/24/04</td>
270
+ <td>11/24/04</td>
271
+ <td>070</td>
272
+ <td>Dialog pass 2 98% complete</td>
273
+ </tr>
274
+ <tr>
275
+ <td><img src="/i/g.gif" alt="" /></td>
276
+ <td>11/30/04</td>
277
+ <td>11/30/04</td>
278
+ <td>070</td>
279
+ <td>Feature complete. Passes end-to-end smoke test.</td>
280
+ </tr>
281
+ <tr>
282
+ <td><img src="/i/w.gif" alt="" /></td>
283
+ <td>12/02/04</td>
284
+ <td> </td>
285
+ <td>011</td>
286
+ <td>Dialog pass 1 and 2 complete (98+%)</td>
287
+ </tr>
288
+ <tr>
289
+ <td><img src="/i/w.gif" alt="" /></td>
290
+ <td>12/03/04</td>
291
+ <td> </td>
292
+ <td>081</td>
293
+ <td>Feature complete</td>
294
+ </tr>
295
+ </table>
296
+ ---
297
+ name: combined table header and colspan
298
+ in: |-
299
+ table(my_class).
300
+ |_\2. a |_. b |_. c |
301
+ | 1 | 2 | 3 | 4 |
302
+ html: |-
303
+ <table class="my_class">
304
+ <tr>
305
+ <th colspan="2">a </th>
306
+ <th>b </th>
307
+ <th>c </th>
308
+ </tr>
309
+ <tr>
310
+ <td> 1 </td>
311
+ <td> 2 </td>
312
+ <td> 3 </td>
313
+ <td> 4 </td>
314
+ </tr>
315
+ </table>
316
+ ---
317
+ name: two adjacent tables
318
+ in: |-
319
+ |a|b|c|
320
+
321
+ |1|2|3|
322
+ html: |-
323
+ <table>
324
+ <tr>
325
+ <td>a</td>
326
+ <td>b</td>
327
+ <td>c</td>
328
+ </tr>
329
+ </table>
330
+ <table>
331
+ <tr>
332
+ <td>1</td>
333
+ <td>2</td>
334
+ <td>3</td>
335
+ </tr>
336
+ </table>