| 1 | #!/usr/bin/env ruby |
|---|
| 2 | |
|---|
| 3 | ## Test a specific number of list items, or a range of numbers of list items. |
|---|
| 4 | ## With the default list item length (26), it breaks at 78 list items: |
|---|
| 5 | # |
|---|
| 6 | # irb(main):001:0> test_ol_range(0..100) |
|---|
| 7 | # Testing with 0 ol lines... |
|---|
| 8 | # Testing with 50 ol lines... |
|---|
| 9 | # Error while testing with 78 ol lines: |
|---|
| 10 | # RegexpError: Stack overflow in regexp matcher: / |
|---|
| 11 | # ^ # Start of line |
|---|
| 12 | # <(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script) # Start tag: \2 |
|---|
| 13 | # \b # word break |
|---|
| 14 | # (.*\n)*? # Any number of lines, minimal match |
|---|
| 15 | # <\/\1> # Matching end tag |
|---|
| 16 | # [ ]* # trailing spaces |
|---|
| 17 | # (?=\n+|\Z) # End of line or document |
|---|
| 18 | # /ix |
|---|
| 19 | # from ./bluecloth.rb:342:in `gsub!' |
|---|
| 20 | # from ./bluecloth.rb:342:in `hide_html_blocks' |
|---|
| 21 | # from ./bluecloth.rb:248:in `apply_block_transforms' |
|---|
| 22 | # from ./bluecloth.rb:202:in `to_html' |
|---|
| 23 | # [snip] |
|---|
| 24 | # |
|---|
| 25 | require "bluecloth" |
|---|
| 26 | |
|---|
| 27 | ALPHAPERLINE = 1 |
|---|
| 28 | OLLINE = "1. %s\n"%[('a'..'z').to_a.to_s * ALPHAPERLINE] |
|---|
| 29 | ULLINE = "* %s\n"%[('a'..'z').to_a.to_s * ALPHAPERLINE] |
|---|
| 30 | |
|---|
| 31 | def test_lines(n,line) |
|---|
| 32 | begin |
|---|
| 33 | puts "Testing with %d ol lines..."%n if n%50 == 0 |
|---|
| 34 | BlueCloth.new(line * n).to_html |
|---|
| 35 | rescue |
|---|
| 36 | puts "Error while testing with %d ol lines:"%n |
|---|
| 37 | raise |
|---|
| 38 | end |
|---|
| 39 | end |
|---|
| 40 | |
|---|
| 41 | def test_ol_range(range) |
|---|
| 42 | range.each do |num| test_lines(num, OLLINE) end |
|---|
| 43 | end |
|---|
| 44 | |
|---|
| 45 | def test_ul_range(range) |
|---|
| 46 | range.each do |num| test_lines(num, ULLINE) end |
|---|
| 47 | end |
|---|