RedCloth 4.0.0-x86-mswin32-60

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.

Files changed (49) hide show
  1. data/CHANGELOG +17 -0
  2. data/COPYING +18 -0
  3. data/README +156 -0
  4. data/Rakefile +240 -0
  5. data/bin/redcloth +28 -0
  6. data/ext/redcloth_scan/extconf.rb +9 -0
  7. data/ext/redcloth_scan/redcloth.h +149 -0
  8. data/ext/redcloth_scan/redcloth_attributes.c +650 -0
  9. data/ext/redcloth_scan/redcloth_attributes.rl +78 -0
  10. data/ext/redcloth_scan/redcloth_common.rl +113 -0
  11. data/ext/redcloth_scan/redcloth_inline.c +5102 -0
  12. data/ext/redcloth_scan/redcloth_inline.rl +282 -0
  13. data/ext/redcloth_scan/redcloth_scan.c +9300 -0
  14. data/ext/redcloth_scan/redcloth_scan.rl +523 -0
  15. data/extras/mingw-rbconfig.rb +176 -0
  16. data/extras/ragel_profiler.rb +73 -0
  17. data/lib/redcloth.rb +24 -0
  18. data/lib/redcloth/formatters/base.rb +50 -0
  19. data/lib/redcloth/formatters/html.rb +342 -0
  20. data/lib/redcloth/formatters/latex.rb +227 -0
  21. data/lib/redcloth/formatters/latex_entities.yml +2414 -0
  22. data/lib/redcloth/textile_doc.rb +105 -0
  23. data/lib/redcloth/version.rb +18 -0
  24. data/lib/redcloth_scan.bundle +0 -0
  25. data/lib/redcloth_scan.so +0 -0
  26. data/test/basic.yml +794 -0
  27. data/test/code.yml +195 -0
  28. data/test/definitions.yml +71 -0
  29. data/test/extra_whitespace.yml +64 -0
  30. data/test/filter_html.yml +177 -0
  31. data/test/filter_pba.yml +12 -0
  32. data/test/helper.rb +108 -0
  33. data/test/html.yml +271 -0
  34. data/test/images.yml +202 -0
  35. data/test/instiki.yml +38 -0
  36. data/test/links.yml +214 -0
  37. data/test/lists.yml +283 -0
  38. data/test/poignant.yml +89 -0
  39. data/test/sanitize_html.yml +42 -0
  40. data/test/table.yml +267 -0
  41. data/test/test_custom_tags.rb +46 -0
  42. data/test/test_extensions.rb +31 -0
  43. data/test/test_formatters.rb +15 -0
  44. data/test/test_parser.rb +68 -0
  45. data/test/test_restrictions.rb +41 -0
  46. data/test/textism.yml +480 -0
  47. data/test/threshold.yml +772 -0
  48. data/test/validate_fixtures.rb +73 -0
  49. metadata +104 -0
data/test/poignant.yml ADDED
@@ -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;);
data/test/table.yml ADDED
@@ -0,0 +1,267 @@
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
+ ---
22
+ in: |
23
+ |_. a|_. b|_. c|
24
+ |1|2|3|
25
+ html: |-
26
+ <table>
27
+ <tr>
28
+ <th>a</th>
29
+ <th>b</th>
30
+ <th>c</th>
31
+ </tr>
32
+ <tr>
33
+ <td>1</td>
34
+ <td>2</td>
35
+ <td>3</td>
36
+ </tr>
37
+ </table>
38
+ ---
39
+ in: |-
40
+ |This|is|a|simple|table|
41
+ |This|is|a|simple|row|
42
+ html: |-
43
+ <table>
44
+ <tr>
45
+ <td>This</td>
46
+ <td>is</td>
47
+ <td>a</td>
48
+ <td>simple</td>
49
+ <td>table</td>
50
+ </tr>
51
+ <tr>
52
+ <td>This</td>
53
+ <td>is</td>
54
+ <td>a</td>
55
+ <td>simple</td>
56
+ <td>row</td>
57
+ </tr>
58
+ </table>
59
+ ---
60
+ in: |-
61
+ table{border:1px solid black}.
62
+ |This|is|a|row|
63
+ |This|is|a|row|
64
+ html: |-
65
+ <table style="border:1px solid black;">
66
+ <tr>
67
+ <td>This</td>
68
+ <td>is</td>
69
+ <td>a</td>
70
+ <td>row</td>
71
+ </tr>
72
+ <tr>
73
+ <td>This</td>
74
+ <td>is</td>
75
+ <td>a</td>
76
+ <td>row</td>
77
+ </tr>
78
+ </table>
79
+ ---
80
+ in: '{background:#ddd}. |This|is|a|row|'
81
+ html: |-
82
+ <table>
83
+ <tr style="background:#ddd;">
84
+ <td>This</td>
85
+ <td>is</td>
86
+ <td>a</td>
87
+ <td>row</td>
88
+ </tr>
89
+ </table>
90
+ ---
91
+ in: |-
92
+ |a|b|c|
93
+ | |2|3|
94
+ html: |-
95
+ <table>
96
+ <tr>
97
+ <td>a</td>
98
+ <td>b</td>
99
+ <td>c</td>
100
+ </tr>
101
+ <tr>
102
+ <td> </td>
103
+ <td>2</td>
104
+ <td>3</td>
105
+ </tr>
106
+ </table>
107
+ ---
108
+ in: |-
109
+ table{width: 200px; border:2px solid gray;}.
110
+ |_=. Alignment|
111
+ |=. centered|
112
+ |=(. a bit right|
113
+ |=). a bit left|
114
+ |>). almost right|
115
+ |<(. almost left|
116
+ |>. right|
117
+ |<. left|
118
+ html: |-
119
+ <table style="width: 200px; border:2px solid gray;">
120
+ <tr>
121
+ <th style="text-align:center;">Alignment</th>
122
+ </tr>
123
+ <tr>
124
+ <td style="text-align:center;">centered</td>
125
+ </tr>
126
+ <tr>
127
+ <td style="padding-left:1em;text-align:center;">a bit right</td>
128
+ </tr>
129
+ <tr>
130
+ <td style="padding-right:1em;text-align:center;">a bit left</td>
131
+ </tr>
132
+ <tr>
133
+ <td style="padding-right:1em;text-align:right;">almost right</td>
134
+ </tr>
135
+ <tr>
136
+ <td style="padding-left:1em;text-align:left;">almost left</td>
137
+ </tr>
138
+ <tr>
139
+ <td style="text-align:right;">right</td>
140
+ </tr>
141
+ <tr>
142
+ <td style="text-align:left;">left</td>
143
+ </tr>
144
+ </table>
145
+ ---
146
+ in: |-
147
+ |{background:#ddd}. Cell with gray background|
148
+ |\2. Cell spanning 2 columns|
149
+ |/3. Cell spanning 3 rows|
150
+ |>. Right-aligned cell|
151
+ html: |-
152
+ <table>
153
+ <tr>
154
+ <td style="background:#ddd;">Cell with gray background</td>
155
+ </tr>
156
+ <tr>
157
+ <td colspan="2">Cell spanning 2 columns</td>
158
+ </tr>
159
+ <tr>
160
+ <td rowspan="3">Cell spanning 3 rows</td>
161
+ </tr>
162
+ <tr>
163
+ <td style="text-align:right;">Right-aligned cell</td>
164
+ </tr>
165
+ </table>
166
+ ---
167
+ in: |
168
+ {background:#ddd}. |S|Target|Complete|App|Milestone|
169
+ |!/i/g.gif!|11/29/04|11/29/04|011|XML spec complete (KH is on schedule)|
170
+ |!/i/g.gif!|11/22/04|11/22/04|070|Dialog pass 1 builds an index file|
171
+ |!/i/g.gif!|11/24/04|11/24/04|070|Dialog pass 2 98% complete|
172
+ |!/i/g.gif!|11/30/04|11/30/04|070|Feature complete. Passes end-to-end smoke test.|
173
+ |!/i/w.gif!|12/02/04| |011|Dialog pass 1 and 2 complete (98+%)|
174
+ |!/i/w.gif!|12/03/04| |081|Feature complete|
175
+ html: |-
176
+ <table>
177
+ <tr style="background:#ddd;">
178
+ <td>S</td>
179
+ <td>Target</td>
180
+ <td>Complete</td>
181
+ <td>App</td>
182
+ <td>Milestone</td>
183
+ </tr>
184
+ <tr>
185
+ <td><img src="/i/g.gif" alt="" /></td>
186
+ <td>11/29/04</td>
187
+ <td>11/29/04</td>
188
+ <td>011</td>
189
+ <td><span class="caps">XML</span> spec complete (KH is on schedule)</td>
190
+ </tr>
191
+ <tr>
192
+ <td><img src="/i/g.gif" alt="" /></td>
193
+ <td>11/22/04</td>
194
+ <td>11/22/04</td>
195
+ <td>070</td>
196
+ <td>Dialog pass 1 builds an index file</td>
197
+ </tr>
198
+ <tr>
199
+ <td><img src="/i/g.gif" alt="" /></td>
200
+ <td>11/24/04</td>
201
+ <td>11/24/04</td>
202
+ <td>070</td>
203
+ <td>Dialog pass 2 98% complete</td>
204
+ </tr>
205
+ <tr>
206
+ <td><img src="/i/g.gif" alt="" /></td>
207
+ <td>11/30/04</td>
208
+ <td>11/30/04</td>
209
+ <td>070</td>
210
+ <td>Feature complete. Passes end-to-end smoke test.</td>
211
+ </tr>
212
+ <tr>
213
+ <td><img src="/i/w.gif" alt="" /></td>
214
+ <td>12/02/04</td>
215
+ <td> </td>
216
+ <td>011</td>
217
+ <td>Dialog pass 1 and 2 complete (98+%)</td>
218
+ </tr>
219
+ <tr>
220
+ <td><img src="/i/w.gif" alt="" /></td>
221
+ <td>12/03/04</td>
222
+ <td> </td>
223
+ <td>081</td>
224
+ <td>Feature complete</td>
225
+ </tr>
226
+ </table>
227
+ ---
228
+ name: combined table header and colspan
229
+ in: |-
230
+ table(my_class).
231
+ |_\2. a |_. b |_. c |
232
+ | 1 | 2 | 3 | 4 |
233
+ html: |-
234
+ <table class="my_class">
235
+ <tr>
236
+ <th colspan="2">a </th>
237
+ <th>b </th>
238
+ <th>c </th>
239
+ </tr>
240
+ <tr>
241
+ <td> 1 </td>
242
+ <td> 2 </td>
243
+ <td> 3 </td>
244
+ <td> 4 </td>
245
+ </tr>
246
+ </table>
247
+ ---
248
+ name: two adjacent tables
249
+ in: |-
250
+ |a|b|c|
251
+
252
+ |1|2|3|
253
+ html: |-
254
+ <table>
255
+ <tr>
256
+ <td>a</td>
257
+ <td>b</td>
258
+ <td>c</td>
259
+ </tr>
260
+ </table>
261
+ <table>
262
+ <tr>
263
+ <td>1</td>
264
+ <td>2</td>
265
+ <td>3</td>
266
+ </tr>
267
+ </table>
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'helper'
4
+
5
+ class TestCustomTags < Test::Unit::TestCase
6
+
7
+ module FigureTag
8
+ def fig( opts )
9
+ label, img = opts[:text].split('|').map! {|str| str.strip}
10
+
11
+ html = %Q{<div class="img" id="figure-#{label.tr('.', '-')}">\n}
12
+ html << %Q{ <a class="fig" href="/images/#{img}">\n}
13
+ html << %Q{ <img src="/images/thumbs/#{img}" alt="Figure #{label}" />\n}
14
+ html << %Q{ </a>\n}
15
+ html << %Q{ <p>Figure #{label}</p>\n}
16
+ html << %Q{<div>\n}
17
+ end
18
+ end
19
+
20
+ def test_fig_tag
21
+ input = %Q{The first line of text.\n\n}
22
+ input << %Q{fig. 1.1 | img.jpg\n\n}
23
+ input << %Q{The last line of text.\n}
24
+ r = RedCloth.new input
25
+ r.extend FigureTag
26
+ str = r.to_html
27
+
28
+ html = %Q{<p>The first line of text.</p>\n}
29
+ html << %Q{<div class="img" id="figure-1-1">\n}
30
+ html << %Q{ <a class="fig" href="/images/img.jpg">\n}
31
+ html << %Q{ <img src="/images/thumbs/img.jpg" alt="Figure 1.1" />\n}
32
+ html << %Q{ </a>\n}
33
+ html << %Q{ <p>Figure 1.1</p>\n}
34
+ html << %Q{<div>\n}
35
+ html << %Q{<p>The last line of text.</p>}
36
+
37
+ assert_equal(html, str)
38
+ end
39
+
40
+ def test_fallback
41
+ r = RedCloth.new %Q/fig()>[no]{color:red}. 1.1 | img.jpg/
42
+ str = r.to_html
43
+
44
+ assert_equal "<p>fig()>[no]{color:red}. 1.1 | img.jpg</p>", str
45
+ end
46
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'helper'
4
+
5
+ class TestExtensions < Test::Unit::TestCase
6
+
7
+ require 'redcloth'
8
+
9
+ # http://www.ralree.info/2006/9/13/extending-redcloth
10
+ module RedClothSmileyExtension
11
+ def refs_smiley(text)
12
+ text.gsub!(/(\s)~(:P|:D|:O|:o|:S|:\||;\)|:'\(|:\)|:\()/) do |m|
13
+ bef,ma = $~[1..2]
14
+ filename = "/images/emoticons/"+(ma.split(//).collect{|l| l[0] }.join('_'))+".png"
15
+ "#{bef}<img src='#{filename}' title='#{ma}' class='smiley' />"
16
+ end
17
+ end
18
+ end
19
+
20
+ RedCloth.send(:include, RedClothSmileyExtension)
21
+
22
+ def test_smiley
23
+ input = %Q{You're so silly! ~:P}
24
+
25
+ str = RedCloth.new(input).to_html(:textile, :refs_smiley)
26
+
27
+ html = %Q{<p>You&#8217;re so silly! <img src='/images/emoticons/58_80.png' title=':P' class='smiley' /></p>}
28
+
29
+ assert_equal(html, str)
30
+ end
31
+ end