BBRedCloth 0.8.8 → 0.9.0.alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/BBRedCloth.gemspec +8 -8
  2. data/CHANGELOG +160 -3
  3. data/Manifest +0 -18
  4. data/README.textile +17 -2
  5. data/Rakefile +14 -12
  6. data/ext/redcloth_scan/redcloth.h +42 -16
  7. data/ext/redcloth_scan/redcloth_attributes.c +373 -379
  8. data/ext/redcloth_scan/redcloth_bbcode.c +57 -56
  9. data/ext/redcloth_scan/redcloth_bbcode_inline.c +22 -21
  10. data/ext/redcloth_scan/redcloth_inline.c +7488 -9996
  11. data/ext/redcloth_scan/redcloth_scan.c +22693 -8756
  12. data/lib/redcloth.rb +7 -0
  13. data/lib/redcloth/formatters/base.rb +26 -20
  14. data/lib/redcloth/formatters/html.rb +39 -96
  15. data/lib/redcloth/formatters/latex.rb +11 -11
  16. data/lib/redcloth/textile_doc.rb +0 -5
  17. data/lib/redcloth/version.rb +4 -4
  18. data/test/basic.yml +118 -13
  19. data/test/code.yml +15 -7
  20. data/test/html.yml +38 -1
  21. data/test/images.yml +51 -0
  22. data/test/links.yml +35 -1
  23. data/test/lists.yml +180 -1
  24. data/test/table.yml +86 -0
  25. data/test/test_restrictions.rb +0 -4
  26. data/test/textism.yml +2 -16
  27. data/test/threshold.yml +4 -19
  28. metadata +14 -31
  29. data/ext/mingw-rbconfig.rb +0 -176
  30. data/ext/redcloth_scan/redcloth_attributes.c.rl +0 -56
  31. data/ext/redcloth_scan/redcloth_attributes.java.rl +0 -96
  32. data/ext/redcloth_scan/redcloth_attributes.rl +0 -33
  33. data/ext/redcloth_scan/redcloth_bbcode.c.rl +0 -60
  34. data/ext/redcloth_scan/redcloth_bbcode.rl +0 -127
  35. data/ext/redcloth_scan/redcloth_bbcode_inline.c.rl +0 -72
  36. data/ext/redcloth_scan/redcloth_bbcode_inline.rl +0 -85
  37. data/ext/redcloth_scan/redcloth_common.c.rl +0 -19
  38. data/ext/redcloth_scan/redcloth_common.java.rl +0 -18
  39. data/ext/redcloth_scan/redcloth_common.rl +0 -111
  40. data/ext/redcloth_scan/redcloth_inline.c.rl +0 -205
  41. data/ext/redcloth_scan/redcloth_inline.java.rl +0 -108
  42. data/ext/redcloth_scan/redcloth_inline.rl +0 -176
  43. data/ext/redcloth_scan/redcloth_scan.c.rl +0 -236
  44. data/ext/redcloth_scan/redcloth_scan.java.rl +0 -555
  45. data/ext/redcloth_scan/redcloth_scan.rl +0 -426
  46. data/extras/ragel_profiler.rb +0 -73
@@ -96,7 +96,10 @@ in: |-
96
96
  <notextile>
97
97
  # *test*
98
98
  html: |-
99
- # *test*
99
+ <p><notextile></p>
100
+ <ol>
101
+ <li><strong>test</strong></li>
102
+ </ol>
100
103
  valid_html: false
101
104
  ---
102
105
  name: unfinished script tag
@@ -140,9 +143,7 @@ html: |-
140
143
  <pre><code>./foo.pl%
141
144
  &lt;p&gt;foo outputs an HTML paragraph&lt;/p&gt;</code>
142
145
 
143
- <code>&lt;p&gt;block of code keeps going until a different block signature is encountered&lt;/p&gt;</code>
144
-
145
- </pre>
146
+ <code>&lt;p&gt;block of code keeps going until a different block signature is encountered&lt;/p&gt;</code></pre>
146
147
  <p>And then go back with a normal paragraph.</p>
147
148
  ---
148
149
  name: extended block code preserves leading whitespace after blank line
@@ -167,9 +168,7 @@ html: |-
167
168
  <code> def baz
168
169
  'baz'
169
170
  end
170
- end</code>
171
-
172
- </pre>
171
+ end</code></pre>
173
172
  <p>That&#8217;s it!</p>
174
173
  ---
175
174
  name: block code containing code avoids nesting code tags
@@ -227,3 +226,12 @@ valid_html: false
227
226
  name: code containing parentheses
228
227
  in: 'p. @some_method(some_params, some => test);@ Oh dear this fails'
229
228
  html: '<p><code>some_method(some_params, some =&gt; test);</code> Oh dear this fails</p>'
229
+ ---
230
+ name: code preserves initial square brackets
231
+ description: usually square brackets are used for the language (English, French, Spanish...), but that doesn't make sense for code and apparently is needed for some computer languages.
232
+ in: @[project]_dff.skjd@
233
+ html: <p><code>[project]_dff.skjd</code></p>
234
+ ---
235
+ name: following also bracketed code in same line
236
+ in: "Some [@code@] and some [@more code@]."
237
+ html: "<p>Some <code>code</code> and some <code>more code</code>.</p>"
@@ -30,6 +30,21 @@ html: |-
30
30
  if you break.</li>
31
31
  </ul>
32
32
  ---
33
+ name: line breaks
34
+ desc: Explicit HTML line breaks are not double-broken
35
+ in: |-
36
+ I spoke.<br />
37
+ And none replied.
38
+ html: |-
39
+ <p>I spoke.<br />
40
+ And none replied.</p>
41
+ html_no_breaks: |-
42
+ <p>I spoke.<br />
43
+ And none replied.</p>
44
+ lite_mode_html: |-
45
+ I spoke.<br />
46
+ And none replied.
47
+ ---
33
48
  name: mixing of textile and XHTML
34
49
  in: |-
35
50
  <img src="test.jpg" alt="test" />
@@ -310,4 +325,26 @@ name: objects in paragraphs are not modified
310
325
  in: |-
311
326
  <p><object width="340" height="280"><param name="movie" value="http://www.youtube.com/v/iUbK1cBHm6E"></param><param name="wmode" value="opaque"></param><param name="allowScriptAccess" value="sameDomain"></param><embed src="http://www.youtube.com/v/iUbK1cBHm6E" type="application/x-shockwave-flash" width="340" height="280" wmode="opaque" allowScriptAccess="sameDomain"></embed></object></p>
312
327
  html: |-
313
- <p><object width="340" height="280"><param name="movie" value="http://www.youtube.com/v/iUbK1cBHm6E"></param><param name="wmode" value="opaque"></param><param name="allowScriptAccess" value="sameDomain"></param><embed src="http://www.youtube.com/v/iUbK1cBHm6E" type="application/x-shockwave-flash" width="340" height="280" wmode="opaque" allowScriptAccess="sameDomain"></embed></object></p>
328
+ <p><object width="340" height="280"><param name="movie" value="http://www.youtube.com/v/iUbK1cBHm6E"></param><param name="wmode" value="opaque"></param><param name="allowScriptAccess" value="sameDomain"></param><embed src="http://www.youtube.com/v/iUbK1cBHm6E" type="application/x-shockwave-flash" width="340" height="280" wmode="opaque" allowScriptAccess="sameDomain"></embed></object></p>
329
+ ---
330
+ name: in code escaped properly
331
+ in: "<pre><code>some <b>bold</b> text</code></pre>"
332
+ html: "<pre><code>some &lt;b&gt;bold&lt;/b&gt; text</code></pre>"
333
+ ---
334
+ name: in code with class attribute escaped properly
335
+ in: "<pre><code class='myclass'>some <b>bold</b> text</code></pre>"
336
+ html: "<pre><code class='myclass'>some &lt;b&gt;bold&lt;/b&gt; text</code></pre>"
337
+ ---
338
+ name: notextile beginning the line
339
+ in: |-
340
+ <notextile><a href="http://a.com">Sir Bobby Robson</a></notextile>, is a famous footballer
341
+ html: |-
342
+ <p><a href="http://a.com">Sir Bobby Robson</a>, is a famous footballer</p>
343
+ ---
344
+ name: br tag with class
345
+ in: "br(clear). "
346
+ html: "<br class=\"clear\" />"
347
+ ---
348
+ name: hr tag with class
349
+ in: "hr(clear). "
350
+ html: "<hr class=\"clear\" />"
@@ -252,3 +252,54 @@ latex: |+
252
252
  name: image attributes has single quote html entity in alt and title
253
253
  in: "!/pictures/bacon.jpg(The fox said: 'Have some chunky bacon')!"
254
254
  html: '<p><img src="/pictures/bacon.jpg" title="The fox said: &#39;Have some chunky bacon&#39;" alt="The fox said: &#39;Have some chunky bacon&#39;" /></p>'
255
+ ---
256
+ name: in square brackets
257
+ in: This is an [!image.jpg!] you see.
258
+ html: <p>This is an <img src="image.jpg" alt="" /> you see.</p>
259
+ disable_inline_images: <p>This is an [!image.jpg!] you see.</p>
260
+ ---
261
+ name: with link in square brackets
262
+ in: This is an [!image.jpg!:http://example.com/] you see.
263
+ html: <p>This is an <a href="http://example.com/"><img src="image.jpg" alt="" /></a> you see.</p>
264
+ disable_inline_images: <p>This is an [!image.jpg!:<a href="http://example.com">http://example.com</a>/] you see.</p>
265
+ ---
266
+ name: url containing parentheses
267
+ in: "!http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg!"
268
+ html: |-
269
+ <p><img src="http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg" alt="" /></p>
270
+ disable_inline_images: "<p>!<a href=\"http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg\">http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg</a>!</p>"
271
+ ---
272
+ name: with alt and url containing parentheses
273
+ in: "!http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg(a big rock)!"
274
+ html: |-
275
+ <p><img src="http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg" title="a big rock" alt="a big rock" /></p>
276
+ #TODO: below is non-ideal
277
+ disable_inline_images: "<p>!<a href=\"http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg(a\">http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg(a</a> big rock)!</p>"
278
+ ---
279
+ name: with link that contains parentheses
280
+ in: "!image.jpg(Alt text with (parentheses).)!"
281
+ html: |-
282
+ <p><img src="image.jpg" title="Alt text with (parentheses)." alt="Alt text with (parentheses)." /></p>
283
+ disable_inline_images: "<p>!image.jpg(Alt text with (parentheses).)!</p>"
284
+ ---
285
+ name: with link and title and text afterward
286
+ in: "!/image_r.jpg(description)!:image.jpg text."
287
+ html: |-
288
+ <p><a href="image.jpg"><img src="/image_r.jpg" title="description" alt="description" /></a> text.</p>
289
+ disable_inline_images: "<p>!/image_r.jpg(description)!:image.jpg text.</p>"
290
+ ---
291
+ name: CVE-2012-6684
292
+ in: |-
293
+ "!<javascript:alert(1)(2)!:javascript:prompt(document.domain)"
294
+ html: |- #unfiltered is still allowed
295
+ <p>&#8220;<a href="javascript:prompt(document.domain)"><img src="javascript:alert(1)" title="2" alt="2" /></a>&#8221;</p>
296
+ filtered_html: <p>&#8220;2&#8221;</p>
297
+ sanitized_html: <p>&#8220;2&#8221;</p>
298
+ ---
299
+ name: CVE-2012-6684 2
300
+ in: |-
301
+ "!<jAvascript:alert(1)(2)!:jAvascript:prompt(document.domain)"
302
+ html: |- #unfiltered is still allowed
303
+ <p>&#8220;<a href="jAvascript:prompt(document.domain)"><img src="jAvascript:alert(1)" title="2" alt="2" /></a>&#8221;</p>
304
+ filtered_html: <p>&#8220;2&#8221;</p>
305
+ sanitized_html: <p>&#8220;2&#8221;</p>
@@ -185,10 +185,14 @@ name: trailing period stays outside link
185
185
  in: '"Link":/foo.html.'
186
186
  html: "<p><a href=\"/foo.html\">Link</a>.</p>"
187
187
  ---
188
- name: parenthetical statement as a link
188
+ name: whose text is a parenthetical statement
189
189
  in: '"(just in case you were wondering)":http://slashdot.org/'
190
190
  html: '<p><a href="http://slashdot.org/">(just in case you were wondering)</a></p>'
191
191
  ---
192
+ name: that has a class and whose text is a parenthetical statement
193
+ in: '"(myclass) (just in case you were wondering)":http://slashdot.org/'
194
+ html: '<p><a href="http://slashdot.org/" class="myclass">(just in case you were wondering)</a></p>'
195
+ ---
192
196
  name: link containing parentheses
193
197
  in: '"It is (very) fortunate that this works":http://slashdot.org/'
194
198
  html: '<p><a href="http://slashdot.org/">It is (very) fortunate that this works</a></p>'
@@ -273,3 +277,33 @@ in: |-
273
277
  "My wife, Tipper, and I will donate 100% of the proceeds of the award to the "Alliance For Climate Protection":http://www.looktothestars.org/charity/638-alliance-for-climate-protection," said Gore in an email. "I am deeply honored to receive the Nobel Peace Prize."
274
278
  html: |-
275
279
  <p>&#8220;My wife, Tipper, and I will donate 100% of the proceeds of the award to the <a href="http://www.looktothestars.org/charity/638-alliance-for-climate-protection">Alliance For Climate Protection</a>,&#8221; said Gore in an email. &#8220;I am deeply honored to receive the Nobel Peace Prize.&#8221;</p>
280
+ ---
281
+ name: with caps in the title
282
+ in: |-
283
+ "British Skin Foundation (BSF)":http://www.britishskinfoundation.org.uk
284
+ html: |-
285
+ <p><a href="http://www.britishskinfoundation.org.uk" title="BSF">British Skin Foundation</a></p>
286
+ ---
287
+ name: containing HTML tags with quotes
288
+ in: |-
289
+ "<r:attachment:image name="checkmark.gif" alt="Apply online" />*apply online*":/admissions/apply/
290
+ html: |-
291
+ <p><a href="/admissions/apply/"><r:attachment:image name="checkmark.gif" alt="Apply online" /><strong>apply online</strong></a></p>
292
+ ---
293
+ # putting this here as I didn't port rspec
294
+ name: CVE-2012-6684
295
+ in: |-
296
+ ["clickme":javascript:alert(%27XSS%27)]
297
+ html: |- #unfiltered is still allowed
298
+ <p><a href="javascript:alert(%27XSS%27)">clickme</a></p>
299
+ filtered_html: <p>clickme</p>
300
+ sanitized_html: <p>clickme</p>
301
+ ---
302
+ # putting this here as I didn't port rspec
303
+ name: CVE-2012-6684 2
304
+ in: |-
305
+ ["clickme":jAvascript:alert(%27XSS%27)]
306
+ html: |- #unfiltered is still allowed
307
+ <p><a href="jAvascript:alert(%27XSS%27)">clickme</a></p>
308
+ filtered_html: <p>clickme</p>
309
+ sanitized_html: <p>clickme</p>
@@ -280,4 +280,183 @@ html: |-
280
280
  <ul>
281
281
  <li>One</li>
282
282
  <li>Two</li>
283
- </ul>
283
+ </ul>
284
+ ---
285
+ name: unordered list with leading spaces
286
+ in: " * notice the leading space\n * RedCloth 3.0.4 used to accept it\n * Now we do too"
287
+ html: |-
288
+ <ul>
289
+ <li>notice the leading space</li>
290
+ <li>RedCloth 3.0.4 used to accept it</li>
291
+ <li>Now we do too</li>
292
+ </ul>
293
+ ---
294
+ name: ordered list with leading spaces
295
+ in: " # notice the leading space\n # RedCloth 3.0.4 used to accept it\n # Now we do too"
296
+ html: |-
297
+ <ol>
298
+ <li>notice the leading space</li>
299
+ <li>RedCloth 3.0.4 used to accept it</li>
300
+ <li>Now we do too</li>
301
+ </ol>
302
+ ---
303
+ name: unordered with classes
304
+ in: |-
305
+ *(class-one) one
306
+ *(class-two) two
307
+ *(class-three) three
308
+ html: |-
309
+ <ul>
310
+ <li class="class-one">one</li>
311
+ <li class="class-two">two</li>
312
+ <li class="class-three">three</li>
313
+ </ul>
314
+ ---
315
+ name: unordered with alignments
316
+ in: |-
317
+ *< one
318
+ *> two
319
+ *<> three
320
+ *= four
321
+ html: |-
322
+ <ul>
323
+ <li style="text-align:left;">one</li>
324
+ <li style="text-align:right;">two</li>
325
+ <li style="text-align:justify;">three</li>
326
+ <li style="text-align:center;">four</li>
327
+ </ul>
328
+ ---
329
+ name: with attributes that apply to the whole list
330
+ in: |-
331
+ (class#id)# one
332
+ # two
333
+ # three
334
+ html: |-
335
+ <ol class="class" id="id">
336
+ <li>one</li>
337
+ <li>two</li>
338
+ <li>three</li>
339
+ </ol>
340
+ ---
341
+ name: with id on the list
342
+ in: |-
343
+ (#my-id)# one
344
+ # two
345
+ # three
346
+ html: |-
347
+ <ol id="my-id">
348
+ <li>one</li>
349
+ <li>two</li>
350
+ <li>three</li>
351
+ </ol>
352
+ ---
353
+ name: with class on the list
354
+ in: |-
355
+ (my-class)# one
356
+ # two
357
+ # three
358
+ html: |-
359
+ <ol class="my-class">
360
+ <li>one</li>
361
+ <li>two</li>
362
+ <li>three</li>
363
+ </ol>
364
+ ---
365
+ name: with id on the list item
366
+ in: |-
367
+ # one
368
+ #(#my-item) two
369
+ # three
370
+ html: |-
371
+ <ol>
372
+ <li>one</li>
373
+ <li id="my-item">two</li>
374
+ <li>three</li>
375
+ </ol>
376
+ ---
377
+ name: with attributes that apply to the first list item
378
+ in: |-
379
+ #(class#id) one
380
+ # two
381
+ # three
382
+ html: |-
383
+ <ol>
384
+ <li class="class" id="id">one</li>
385
+ <li>two</li>
386
+ <li>three</li>
387
+ </ol>
388
+ ---
389
+ name: changed from textism basics
390
+ desc: "This was in Textism basics, but when I changed the format of list styles, I removed it"
391
+ in: |-
392
+ {color:blue}# one
393
+ # two
394
+ # three
395
+ html: |-
396
+ <ol style="color:blue;">
397
+ <li>one</li>
398
+ <li>two</li>
399
+ <li>three</li>
400
+ </ol>
401
+ ---
402
+ name: changed from threshold list attributes
403
+ desc: "Was: 'Attributes applied to the first list item will apply to the list itself.' but then we changed it"
404
+ in: |-
405
+ *{color:red} Item one
406
+ * Item two
407
+ * Item three
408
+ html: |-
409
+ <ul>
410
+ <li style="color:red;">Item one</li>
411
+ <li>Item two</li>
412
+ <li>Item three</li>
413
+ </ul>
414
+ ---
415
+ name: with one padding-left increment
416
+ in: "(# one"
417
+ html: |-
418
+ <ol style="padding-left:1em;">
419
+ <li>one</li>
420
+ </ol>
421
+ ---
422
+ name: with one padding-left increment and class
423
+ in: "((myclass)# one"
424
+ html: |-
425
+ <ol style="padding-left:1em;" class="myclass">
426
+ <li>one</li>
427
+ </ol>
428
+ ---
429
+ name: with two padding-left increments
430
+ in: "((# two"
431
+ html: |-
432
+ <ol style="padding-left:2em;">
433
+ <li>two</li>
434
+ </ol>
435
+ ---
436
+ name: with one padding-right increment
437
+ in: ")# one"
438
+ html: |-
439
+ <ol style="padding-right:1em;">
440
+ <li>one</li>
441
+ </ol>
442
+ ---
443
+ name: with padding-left and padding-right increments
444
+ in: "()# two"
445
+ html: |-
446
+ <ol style="padding-left:1em;padding-right:1em;">
447
+ <li>two</li>
448
+ </ol>
449
+ ---
450
+ name: with padding-left and padding-right increments switched
451
+ in: ")(# two"
452
+ html: |-
453
+ <ol style="padding-left:1em;padding-right:1em;">
454
+ <li>two</li>
455
+ </ol>
456
+ ---
457
+ name: with padding-left and padding-right increments and class
458
+ in: "()(myclass)# two"
459
+ html: |-
460
+ <ol style="padding-left:1em;padding-right:1em;" class="myclass">
461
+ <li>two</li>
462
+ </ol>
@@ -265,3 +265,89 @@ html: |-
265
265
  <td>3</td>
266
266
  </tr>
267
267
  </table>
268
+ ---
269
+ name: with cell attributes
270
+ in: |[en]. lang-ok|{color:red;}. style-ok|(myclass). class-ok|
271
+ html: |-
272
+ <table>
273
+ <tr>
274
+ <td lang="en">lang-ok</td>
275
+ <td style="color:red;">style-ok</td>
276
+ <td class="myclass">class-ok</td>
277
+ </tr>
278
+ </table>
279
+ ---
280
+ name: with improper cell attributes
281
+ in: |[en]lang-bad|{color:red;}style-bad|(myclass)class-bad|
282
+ html: |-
283
+ <table>
284
+ <tr>
285
+ <td>[en]lang-bad</td>
286
+ <td>{color:red;}style-bad</td>
287
+ <td>(myclass)class-bad</td>
288
+ </tr>
289
+ </table>
290
+ ---
291
+ name: with line breaks in the cell
292
+ in: |-
293
+ |a|b
294
+ b|
295
+ |c
296
+ c|d|
297
+ html: |-
298
+ <table>
299
+ <tr>
300
+ <td>a</td>
301
+ <td>b<br />
302
+ b</td>
303
+ </tr>
304
+ <tr>
305
+ <td>c<br />
306
+ c</td>
307
+ <td>d</td>
308
+ </tr>
309
+ </table>
310
+ ---
311
+ name: with missing cells
312
+ desc: This is improper formatting, so as long as it doesn't choke, I don't care how it is handled
313
+ in: |-
314
+ |a|b|
315
+ |a|
316
+ |a|b|
317
+ html: |-
318
+ <table>
319
+ <tr>
320
+ <td>a</td>
321
+ <td>b</td>
322
+ </tr>
323
+ <tr>
324
+ <td>a</td>
325
+ </tr>
326
+ <tr>
327
+ <td>a</td>
328
+ <td>b</td>
329
+ </tr>
330
+ </table>
331
+ ---
332
+ name: with empty cells
333
+ desc: cells can be empty. Textile2 skips empties, but we don't want to do that.
334
+ in: |-
335
+ ||b|
336
+ |a||
337
+ |a| |
338
+ html: |-
339
+ <table>
340
+ <tr>
341
+ <td></td>
342
+ <td>b</td>
343
+ </tr>
344
+ <tr>
345
+ <td>a</td>
346
+ <td></td>
347
+ </tr>
348
+ <tr>
349
+ <td>a</td>
350
+ <td> </td>
351
+ </tr>
352
+ </table>
353
+