RedCloth 4.1.9-universal-java → 4.2.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.

Files changed (68) hide show
  1. data/CHANGELOG +55 -0
  2. data/Manifest +34 -38
  3. data/README +17 -5
  4. data/Rakefile +79 -30
  5. data/RedCloth.gemspec +8 -9
  6. data/ext/redcloth_scan/redcloth.h +38 -13
  7. data/lib/redcloth.rb +9 -3
  8. data/lib/redcloth/formatters/html.rb +2 -2
  9. data/lib/redcloth/formatters/latex.rb +99 -54
  10. data/lib/redcloth/formatters/latex_entities.yml +2 -2
  11. data/lib/redcloth/version.rb +9 -4
  12. data/lib/redcloth_scan.jar +0 -0
  13. data/lib/tasks/pureruby.rake +12 -0
  14. data/spec/custom_tags_spec.rb +50 -0
  15. data/spec/differs/inline.rb +48 -0
  16. data/{test/test_erb.rb → spec/erb_spec.rb} +6 -9
  17. data/spec/extension_spec.rb +26 -0
  18. data/{test → spec/fixtures}/basic.yml +90 -4
  19. data/{test → spec/fixtures}/code.yml +29 -0
  20. data/{test → spec/fixtures}/definitions.yml +0 -0
  21. data/{test → spec/fixtures}/extra_whitespace.yml +0 -0
  22. data/{test → spec/fixtures}/filter_html.yml +0 -0
  23. data/{test → spec/fixtures}/filter_pba.yml +0 -0
  24. data/{test → spec/fixtures}/html.yml +15 -0
  25. data/{test → spec/fixtures}/images.yml +16 -6
  26. data/{test → spec/fixtures}/instiki.yml +0 -0
  27. data/{test → spec/fixtures}/links.yml +7 -1
  28. data/{test → spec/fixtures}/lists.yml +162 -1
  29. data/{test → spec/fixtures}/poignant.yml +0 -0
  30. data/{test → spec/fixtures}/sanitize_html.yml +0 -0
  31. data/{test → spec/fixtures}/table.yml +121 -23
  32. data/{test → spec/fixtures}/textism.yml +44 -15
  33. data/{test → spec/fixtures}/threshold.yml +6 -14
  34. data/spec/formatters/class_filtered_html_spec.rb +7 -0
  35. data/spec/formatters/filtered_html_spec.rb +7 -0
  36. data/spec/formatters/html_no_breaks_spec.rb +9 -0
  37. data/spec/formatters/html_spec.rb +13 -0
  38. data/spec/formatters/id_filtered_html_spec.rb +7 -0
  39. data/spec/formatters/latex_spec.rb +13 -0
  40. data/spec/formatters/lite_mode_html_spec.rb +7 -0
  41. data/spec/formatters/no_span_caps_html_spec.rb +7 -0
  42. data/spec/formatters/sanitized_html_spec.rb +7 -0
  43. data/spec/formatters/style_filtered_html_spec.rb +7 -0
  44. data/spec/parser_spec.rb +95 -0
  45. data/spec/spec.opts +3 -0
  46. data/spec/spec_helper.rb +42 -0
  47. metadata +46 -51
  48. data/ext/mingw-rbconfig.rb +0 -176
  49. data/ext/redcloth_scan/redcloth_attributes.c.rl +0 -55
  50. data/ext/redcloth_scan/redcloth_attributes.java.rl +0 -95
  51. data/ext/redcloth_scan/redcloth_attributes.rl +0 -33
  52. data/ext/redcloth_scan/redcloth_common.c.rl +0 -18
  53. data/ext/redcloth_scan/redcloth_common.java.rl +0 -18
  54. data/ext/redcloth_scan/redcloth_common.rl +0 -115
  55. data/ext/redcloth_scan/redcloth_inline.c.rl +0 -193
  56. data/ext/redcloth_scan/redcloth_inline.java.rl +0 -140
  57. data/ext/redcloth_scan/redcloth_inline.rl +0 -156
  58. data/ext/redcloth_scan/redcloth_scan.c.rl +0 -228
  59. data/ext/redcloth_scan/redcloth_scan.java.rl +0 -577
  60. data/ext/redcloth_scan/redcloth_scan.rl +0 -320
  61. data/extras/ragel_profiler.rb +0 -73
  62. data/test/helper.rb +0 -108
  63. data/test/test_custom_tags.rb +0 -58
  64. data/test/test_extensions.rb +0 -31
  65. data/test/test_formatters.rb +0 -24
  66. data/test/test_parser.rb +0 -73
  67. data/test/test_restrictions.rb +0 -41
  68. data/test/validate_fixtures.rb +0 -74
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), '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
-
47
- # We don't want to call just any String method!
48
- def test_does_not_call_standard_methods
49
- r = RedCloth.new "next. "
50
- r.extend FigureTag
51
- str = r.to_html
52
-
53
- html = "<p>next. </p>"
54
-
55
- assert_equal(html, str)
56
- end
57
-
58
- end
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), '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.unpack("c*").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
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), 'helper')
4
-
5
- class TestFormatters < Test::Unit::TestCase
6
-
7
- generate_formatter_tests('html') do |doc|
8
- RedCloth.new(doc['in']).to_html
9
- end
10
-
11
- def test_html_orphan_parenthesis_in_link_can_be_followed_by_punctuation_and_words
12
- assert_nothing_raised { RedCloth.new(%Q{Test "(read this":http://test.host), ok}).to_html }
13
- end
14
-
15
- generate_formatter_tests('latex') do |doc|
16
- RedCloth.new(doc['in']).to_latex
17
- end
18
-
19
- def test_latex_orphan_parenthesis_in_link_can_be_followed_by_punctuation_and_words
20
- assert_nothing_raised { RedCloth.new(%Q{Test "(read this":http://test.host), ok}).to_latex }
21
- end
22
-
23
-
24
- end
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), 'helper')
4
-
5
- class TestParser < Test::Unit::TestCase
6
-
7
- def test_parser_accepts_options
8
- assert_nothing_raised(ArgumentError) do
9
- RedCloth.new("test", [:hard_breaks])
10
- end
11
- end
12
-
13
- def test_redcloth_has_version
14
- assert RedCloth.const_defined?("VERSION")
15
- assert RedCloth::VERSION.const_defined?("STRING")
16
- end
17
-
18
- def test_redcloth_version_to_s
19
- assert_equal RedCloth::VERSION::STRING, RedCloth::VERSION.to_s
20
- assert RedCloth::VERSION == RedCloth::VERSION::STRING
21
- end
22
-
23
- def test_badly_formatted_table_does_not_segfault
24
- assert_match(/td/, RedCloth.new(%Q{| one | two |\nthree | four |}).to_html)
25
- end
26
-
27
- def test_table_without_block_end_does_not_segfault
28
- assert_match(/h3/, RedCloth.new("| a | b |\n| c | d |\nh3. foo").to_html)
29
- end
30
-
31
- def test_table_with_empty_cells_does_not_segfault
32
- assert_match(/td/, RedCloth.new(%Q{|one || |\nthree | four |}).to_html)
33
- end
34
-
35
- def test_unfinished_html_block_does_not_segfault_with_filter_html
36
- assert_nothing_raised { RedCloth.new(%Q{<hr> Some text}, [:filter_html]).to_html }
37
- end
38
-
39
- def test_redcloth_version_in_output
40
- assert_equal "<p>#{RedCloth::VERSION::STRING}</p>", RedCloth.new("RedCloth::VERSION").to_html
41
- end
42
-
43
- def test_redcloth_version_only_on_line_by_itself
44
- input = "RedCloth::VERSION won't output the RedCloth::VERSION unless it's on a line all by itself.\n\nRedCloth::VERSION"
45
- html = "<p>RedCloth::<span class=\"caps\">VERSION</span> won&#8217;t output the RedCloth::<span class=\"caps\">VERSION</span> unless it&#8217;s on a line all by itself.</p>\n<p>#{RedCloth::VERSION::STRING}</p>"
46
- assert_equal html, RedCloth.new(input).to_html
47
- end
48
-
49
- def test_redcloth_version_with_label
50
- input = "RedCloth::VERSION: RedCloth::VERSION"
51
- html = "<p>RedCloth::VERSION: #{RedCloth::VERSION::STRING}</p>"
52
- assert_equal html, RedCloth.new(input).to_html
53
- end
54
-
55
- def test_redcloth_version_with_label_2
56
- input = "RedCloth version RedCloth::VERSION"
57
- html = "<p>RedCloth version #{RedCloth::VERSION::STRING}</p>"
58
- assert_equal html, RedCloth.new(input).to_html
59
- end
60
-
61
- def test_inline_redcloth_version
62
- input = "The current RedCloth version is [RedCloth::VERSION]"
63
- html = "<p>The current RedCloth version is #{RedCloth::VERSION::STRING}</p>"
64
- assert_equal html, RedCloth.new(input).to_html
65
- end
66
-
67
- def test_parser_strips_carriage_returns
68
- input = "This is a paragraph\r\n\r\nThis is a\r\nline break.\r\n\r\n<div>\r\ntest\r\n\r\n</div>"
69
- html = "<p>This is a paragraph</p>\n<p>This is a<br />\nline break.</p>\n<div>\n<p>test</p>\n</div>"
70
- assert_equal html, RedCloth.new(input).to_html
71
- end
72
-
73
- end
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), 'helper')
4
-
5
- class TestRestrictions < Test::Unit::TestCase
6
-
7
- # security restrictions
8
- generate_formatter_tests('filtered_html') do |doc|
9
- RedCloth.new(doc['in'], [:filter_html]).to_html
10
- end
11
- generate_formatter_tests('sanitized_html') do |doc|
12
- RedCloth.new(doc['in'], [:sanitize_html]).to_html
13
- end
14
-
15
- # pba filters (style, class, id)
16
- generate_formatter_tests('style_filtered_html') do |doc|
17
- RedCloth.new(doc['in'], [:filter_styles]).to_html
18
- end
19
- generate_formatter_tests('class_filtered_html') do |doc|
20
- RedCloth.new(doc['in'], [:filter_classes]).to_html
21
- end
22
- generate_formatter_tests('id_filtered_html') do |doc|
23
- RedCloth.new(doc['in'], [:filter_ids]).to_html
24
- end
25
-
26
- # hard breaks - has been deprecated and will be removed in a future version
27
- generate_formatter_tests('html_no_breaks') do |doc|
28
- red = RedCloth.new(doc['in'])
29
- red.hard_breaks = false
30
- red.to_html
31
- end
32
-
33
- generate_formatter_tests('lite_mode_html') do |doc|
34
- RedCloth.new(doc['in'], [:lite_mode]).to_html
35
- end
36
-
37
- generate_formatter_tests('no_span_caps_html') do |doc|
38
- RedCloth.new(doc['in'], [:no_span_caps]).to_html
39
- end
40
-
41
- end
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), 'helper')
4
-
5
- require 'erb'
6
- require 'w3c_validators'
7
-
8
- class ValidateFixtures < Test::Unit::TestCase
9
- include W3CValidators
10
-
11
- def setup
12
- @v = MarkupValidator.new
13
- sleep 1 # delay per WC3 request
14
- end
15
-
16
- HTML_4_0_TEMPLATE = <<EOD
17
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
18
- <html>
19
- <head>
20
- <title><%= test_name %></title>
21
- </head>
22
- <body>
23
- <%= content %>
24
- </body>
25
- </html>
26
- EOD
27
- XHTML_1_0_TEMPLATE = <<EOD
28
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
29
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
30
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
31
- <head>
32
- <title><%= test_name %></title>
33
- </head>
34
- <body>
35
- <%= content %>
36
- </body>
37
- </html>
38
- EOD
39
-
40
- fixtures.each do |name, doc|
41
- if doc['html'] && (doc['valid_html'].nil? || doc['valid_html'])
42
- define_method("test_html_output_validity_of_#{name}") do
43
- assert_produces_valid_html(name, doc['html'])
44
- end
45
- define_method("test_xhtml_output_validity_of_#{name}") do
46
- assert_produces_valid_xhtml(name, doc['html'])
47
- end
48
- end
49
- end
50
-
51
- private
52
- def assert_produces_valid_html(test_name, content)
53
- body = ERB.new(HTML_4_0_TEMPLATE, nil,'-%').result(binding)
54
- assert_validates(body)
55
- end
56
-
57
- def assert_produces_valid_xhtml(test_name, content)
58
- body = ERB.new(XHTML_1_0_TEMPLATE, nil,'-%').result(binding)
59
- assert_validates(body)
60
- end
61
-
62
- def assert_validates(body)
63
- results = @v.validate_text(body)
64
- errors = results.errors
65
- warnings = results.warnings.reject {|w| w.message_id == "247" } # NET-enabling start-tag requires SHORTTAG YES.
66
-
67
- assert(errors.empty?, "Validator errors: \n" +
68
- errors.collect {|e| "'#{e.to_s}'"}.join("\n"))
69
-
70
- assert(warnings.empty?, "Validator warnings: \n" +
71
- warnings.collect {|w| "'#{w.to_s}'"}.join("\n"))
72
- end
73
-
74
- end