pixeltrix-rdiscount 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,104 @@
1
+ $: << File.join(File.dirname(__FILE__), "../lib")
2
+
3
+ require 'test/unit'
4
+ require 'markdown'
5
+
6
+ MARKDOWN_TEST_DIR = "#{File.dirname(__FILE__)}/MarkdownTest_1.0.3"
7
+
8
+ class MarkdownTest < Test::Unit::TestCase
9
+
10
+ def test_that_extension_methods_are_present_on_markdown_class
11
+ assert Markdown.instance_methods.include?('to_html'),
12
+ "Markdown class should respond to #to_html"
13
+ end
14
+
15
+ def test_that_simple_one_liner_goes_to_html
16
+ markdown = Markdown.new('Hello World.')
17
+ assert_respond_to markdown, :to_html
18
+ assert_equal "<p>Hello World.</p>", markdown.to_html.strip
19
+ end
20
+
21
+ def test_that_inline_markdown_goes_to_html
22
+ markdown = Markdown.new('_Hello World_!')
23
+ assert_respond_to markdown, :to_html
24
+ assert_equal "<p><em>Hello World</em>!</p>", markdown.to_html.strip
25
+ end
26
+
27
+ def test_that_inline_markdown_starts_and_ends_correctly
28
+ markdown = Markdown.new('_start _ foo_bar bar_baz _ end_ *italic* **bold** <a>_blah_</a>')
29
+ assert_respond_to markdown, :to_html
30
+ assert_equal "<p><em>start _ foo_bar bar_baz _ end</em> <em>italic</em> <strong>bold</strong> <a><em>blah</em></a></p>", markdown.to_html.strip
31
+ end
32
+
33
+ def test_that_filter_html_works
34
+ markdown = Markdown.new('Through <em>NO</em> <script>DOUBLE NO</script>', :filter_html)
35
+ assert_equal "<p>Through &lt;em>NO&lt;/em> &lt;script>DOUBLE NO&lt;/script></p>", markdown.to_html.strip
36
+ end
37
+
38
+ def test_that_bluecloth_restrictions_are_supported
39
+ markdown = Markdown.new('Hello World.')
40
+ [:filter_html, :filter_styles].each do |restriction|
41
+ assert_respond_to markdown, restriction
42
+ assert_respond_to markdown, "#{restriction}="
43
+ end
44
+ assert_not_equal true, markdown.filter_html
45
+ assert_not_equal true, markdown.filter_styles
46
+
47
+ markdown = Markdown.new('Hello World.', :filter_html, :filter_styles)
48
+ assert_equal true, markdown.filter_html
49
+ assert_equal true, markdown.filter_styles
50
+ end
51
+
52
+ def test_that_redcloth_attributes_are_supported
53
+ markdown = Markdown.new('Hello World.')
54
+ assert_respond_to markdown, :fold_lines
55
+ assert_respond_to markdown, :fold_lines=
56
+ assert_not_equal true, markdown.fold_lines
57
+
58
+ markdown = Markdown.new('Hello World.', :fold_lines)
59
+ assert_equal true, markdown.fold_lines
60
+ end
61
+
62
+ def test_that_redcloth_to_html_with_single_arg_is_supported
63
+ markdown = Markdown.new('Hello World.')
64
+ assert_nothing_raised(ArgumentError) { markdown.to_html(true) }
65
+ end
66
+
67
+ def test_that_smart_converts_single_quotes_in_words_that_end_in_re
68
+ markdown = Markdown.new("They're not for sale.", :smart)
69
+ assert_equal "<p>They&rsquo;re not for sale.</p>\n", markdown.to_html
70
+ end
71
+
72
+ def test_that_smart_converts_single_quotes_in_words_that_end_in_ll
73
+ markdown = Markdown.new("Well that'll be the day", :smart)
74
+ assert_equal "<p>Well that&rsquo;ll be the day</p>\n", markdown.to_html
75
+ end
76
+
77
+ def test_that_urls_are_not_doubly_escaped
78
+ markdown = Markdown.new('[Page 2](/search?query=Markdown+Test&page=2)')
79
+ assert_equal "<p><a href=\"/search?query=Markdown+Test&amp;page=2\">Page 2</a></p>\n", markdown.to_html
80
+ end
81
+
82
+ # Build tests for each file in the MarkdownTest test suite
83
+
84
+ Dir["#{MARKDOWN_TEST_DIR}/Tests/*.text"].each do |text_file|
85
+
86
+ basename = File.basename(text_file).sub(/\.text$/, '')
87
+ html_file = text_file.sub(/text$/, 'html')
88
+ method_name = basename.gsub(/[-,]/, '').gsub(/\s+/, '_').downcase
89
+
90
+ define_method "test_#{method_name}" do
91
+ markdown = Markdown.new(File.read(text_file))
92
+ actual_html = markdown.to_html
93
+ assert_not_nil actual_html
94
+ end
95
+
96
+ define_method "test_#{method_name}_with_smarty_enabled" do
97
+ markdown = Markdown.new(File.read(text_file), :smart)
98
+ actual_html = markdown.to_html
99
+ assert_not_nil actual_html
100
+ end
101
+
102
+ end
103
+
104
+ end
@@ -0,0 +1,15 @@
1
+ $: << File.join(File.dirname(__FILE__), "../lib")
2
+
3
+ require 'test/unit'
4
+ require 'rdiscount'
5
+
6
+ class RDiscountTest < Test::Unit::TestCase
7
+ def test_that_discount_does_not_blow_up_with_weird_formatting_case
8
+ text = (<<-TEXT).gsub(/^ {4}/, '').rstrip
9
+ 1. some text
10
+
11
+ 1.
12
+ TEXT
13
+ RDiscount.new(text).to_html
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pixeltrix-rdiscount
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.11
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Tomayko
8
+ - Andrew White
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-01-03 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email: andyw@pixeltrix.co.uk
19
+ executables: []
20
+
21
+ extensions:
22
+ - ext/extconf.rb
23
+ extra_rdoc_files:
24
+ - COPYING
25
+ files:
26
+ - bin/rdiscount
27
+ - COPYING
28
+ - ext/amalloc.h
29
+ - ext/config.h
30
+ - ext/cstring.h
31
+ - ext/docheader.c
32
+ - ext/dumptree.c
33
+ - ext/extconf.rb
34
+ - ext/generate.c
35
+ - ext/markdown.c
36
+ - ext/markdown.h
37
+ - ext/mkdio.c
38
+ - ext/mkdio.h
39
+ - ext/rbstrio.c
40
+ - ext/rbstrio.h
41
+ - ext/rdiscount.c
42
+ - ext/resource.c
43
+ - lib/markdown.rb
44
+ - lib/rdiscount.rb
45
+ - Rakefile
46
+ - rdiscount.gemspec
47
+ - README.markdown
48
+ - test/benchmark.rb
49
+ - test/benchmark.txt
50
+ - test/markdown_test.rb
51
+ - test/MarkdownTest_1.0
52
+ - test/MarkdownTest_1.0.3
53
+ - test/rdiscount_test.rb
54
+ has_rdoc: true
55
+ homepage: http://github.com/pixeltrix/rdiscount
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ requirements: []
74
+
75
+ rubyforge_project:
76
+ rubygems_version: 1.2.0
77
+ signing_key:
78
+ specification_version: 2
79
+ summary: Fast Implementation of Gruber's Markdown in C
80
+ test_files:
81
+ - test/markdown_test.rb
82
+ - test/rdiscount_test.rb