crasher 0.0.1
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.
- data/COPYING +52 -0
- data/README.markdown +58 -0
- data/Rakefile +199 -0
- data/bin/rdiscount +5 -0
- data/crasher.gemspec +41 -0
- data/ext/Csio.c +49 -0
- data/ext/amalloc.h +29 -0
- data/ext/config.h +9 -0
- data/ext/cstring.h +73 -0
- data/ext/docheader.c +43 -0
- data/ext/dumptree.c +147 -0
- data/ext/extconf.rb +8 -0
- data/ext/generate.c +1389 -0
- data/ext/markdown.c +962 -0
- data/ext/markdown.h +135 -0
- data/ext/mkdio.c +241 -0
- data/ext/mkdio.h +66 -0
- data/ext/rdiscount.c +95 -0
- data/ext/resource.c +169 -0
- data/ext/toc.c +86 -0
- data/lib/crasher.rb +72 -0
- data/lib/markdown.rb +1 -0
- data/test/benchmark.rb +56 -0
- data/test/benchmark.txt +306 -0
- data/test/markdown_test.rb +119 -0
- data/test/rdiscount_test.rb +43 -0
- metadata +81 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
rootdir = File.dirname(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift "#{rootdir}/lib"
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'markdown'
|
6
|
+
|
7
|
+
MARKDOWN_TEST_DIR = "#{rootdir}/test/MarkdownTest_1.0.3"
|
8
|
+
|
9
|
+
class MarkdownTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def test_that_extension_methods_are_present_on_markdown_class
|
12
|
+
assert Markdown.instance_methods.map{|m| m.to_s }.include?('to_html'),
|
13
|
+
"Markdown class should respond to #to_html"
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_that_simple_one_liner_goes_to_html
|
17
|
+
markdown = Markdown.new('Hello World.')
|
18
|
+
assert_respond_to markdown, :to_html
|
19
|
+
assert_equal "<p>Hello World.</p>", markdown.to_html.strip
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_that_inline_markdown_goes_to_html
|
23
|
+
markdown = Markdown.new('_Hello World_!')
|
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
|
+
|
32
|
+
markdown = Markdown.new("Run 'rake radiant:extensions:rbac_base:migrate'")
|
33
|
+
assert_equal "<p>Run 'rake radiant:extensions:rbac_base:migrate'</p>", markdown.to_html.strip
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_that_filter_html_works
|
37
|
+
markdown = Markdown.new('Through <em>NO</em> <script>DOUBLE NO</script>', :filter_html)
|
38
|
+
assert_equal "<p>Through <em>NO</em> <script>DOUBLE NO</script></p>", markdown.to_html.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_that_bluecloth_restrictions_are_supported
|
42
|
+
markdown = Markdown.new('Hello World.')
|
43
|
+
[:filter_html, :filter_styles].each do |restriction|
|
44
|
+
assert_respond_to markdown, restriction
|
45
|
+
assert_respond_to markdown, "#{restriction}="
|
46
|
+
end
|
47
|
+
assert_not_equal true, markdown.filter_html
|
48
|
+
assert_not_equal true, markdown.filter_styles
|
49
|
+
|
50
|
+
markdown = Markdown.new('Hello World.', :filter_html, :filter_styles)
|
51
|
+
assert_equal true, markdown.filter_html
|
52
|
+
assert_equal true, markdown.filter_styles
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_that_redcloth_attributes_are_supported
|
56
|
+
markdown = Markdown.new('Hello World.')
|
57
|
+
assert_respond_to markdown, :fold_lines
|
58
|
+
assert_respond_to markdown, :fold_lines=
|
59
|
+
assert_not_equal true, markdown.fold_lines
|
60
|
+
|
61
|
+
markdown = Markdown.new('Hello World.', :fold_lines)
|
62
|
+
assert_equal true, markdown.fold_lines
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_that_redcloth_to_html_with_single_arg_is_supported
|
66
|
+
markdown = Markdown.new('Hello World.')
|
67
|
+
assert_nothing_raised(ArgumentError) { markdown.to_html(true) }
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_that_smart_converts_single_quotes_in_words_that_end_in_re
|
71
|
+
markdown = Markdown.new("They're not for sale.", :smart)
|
72
|
+
assert_equal "<p>They’re not for sale.</p>\n", markdown.to_html
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_that_smart_converts_single_quotes_in_words_that_end_in_ll
|
76
|
+
markdown = Markdown.new("Well that'll be the day", :smart)
|
77
|
+
assert_equal "<p>Well that’ll be the day</p>\n", markdown.to_html
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_that_urls_are_not_doubly_escaped
|
81
|
+
markdown = Markdown.new('[Page 2](/search?query=Markdown+Test&page=2)')
|
82
|
+
assert_equal "<p><a href=\"/search?query=Markdown+Test&page=2\">Page 2</a></p>\n", markdown.to_html
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_simple_inline_html
|
86
|
+
markdown = Markdown.new("before\n\n<div>\n foo\n</div>\nafter")
|
87
|
+
assert_equal "<p>before</p>\n\n<div>\n foo\n</div>\n\n\n<p>after</p>\n",
|
88
|
+
markdown.to_html
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_that_html_blocks_do_not_require_their_own_end_tag_line
|
92
|
+
markdown = Markdown.new("Para 1\n\n<div><pre>HTML block\n</pre></div>\n\nPara 2 [Link](#anchor)")
|
93
|
+
assert_equal "<p>Para 1</p>\n\n<div><pre>HTML block\n</pre></div>\n\n\n<p>Para 2 <a href=\"#anchor\">Link</a></p>\n",
|
94
|
+
markdown.to_html
|
95
|
+
end
|
96
|
+
|
97
|
+
# Build tests for each file in the MarkdownTest test suite
|
98
|
+
|
99
|
+
Dir["#{MARKDOWN_TEST_DIR}/Tests/*.text"].each do |text_file|
|
100
|
+
|
101
|
+
basename = File.basename(text_file).sub(/\.text$/, '')
|
102
|
+
html_file = text_file.sub(/text$/, 'html')
|
103
|
+
method_name = basename.gsub(/[-,]/, '').gsub(/\s+/, '_').downcase
|
104
|
+
|
105
|
+
define_method "test_#{method_name}" do
|
106
|
+
markdown = Markdown.new(File.read(text_file))
|
107
|
+
actual_html = markdown.to_html
|
108
|
+
assert_not_nil actual_html
|
109
|
+
end
|
110
|
+
|
111
|
+
define_method "test_#{method_name}_with_smarty_enabled" do
|
112
|
+
markdown = Markdown.new(File.read(text_file), :smart)
|
113
|
+
actual_html = markdown.to_html
|
114
|
+
assert_not_nil actual_html
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
rootdir = File.dirname(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift "#{rootdir}/lib"
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rdiscount'
|
6
|
+
|
7
|
+
class RDiscountTest < Test::Unit::TestCase
|
8
|
+
def test_that_discount_does_not_blow_up_with_weird_formatting_case
|
9
|
+
text = (<<-TEXT).gsub(/^ {4}/, '').rstrip
|
10
|
+
1. some text
|
11
|
+
|
12
|
+
1.
|
13
|
+
TEXT
|
14
|
+
RDiscount.new(text).to_html
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_that_smart_converts_double_quotes_to_curly_quotes
|
18
|
+
rd = RDiscount.new(%("Quoted text"), :smart)
|
19
|
+
assert_equal %(<p>“Quoted text”</p>\n), rd.to_html
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_that_smart_converts_double_quotes_to_curly_quotes_before_a_heading
|
23
|
+
rd = RDiscount.new(%("Quoted text"\n\n# Heading), :smart)
|
24
|
+
assert_equal %(<p>“Quoted text”</p>\n\n<h1>Heading</h1>\n), rd.to_html
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_that_smart_converts_double_quotes_to_curly_quotes_after_a_heading
|
28
|
+
rd = RDiscount.new(%(# Heading\n\n"Quoted text"), :smart)
|
29
|
+
assert_equal %(<h1>Heading</h1>\n\n<p>“Quoted text”</p>\n), rd.to_html
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_that_generate_toc_sets_toc_ids
|
33
|
+
rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
|
34
|
+
assert rd.generate_toc
|
35
|
+
assert_equal %(<h1 id="Level+1\">Level 1</h1>\n\n<h2 id="Level+2\">Level 2</h2>\n), rd.to_html
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_get_the_generated_toc
|
39
|
+
rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
|
40
|
+
exp = %(<ul>\n <li><a href="#Level+1">Level 1</a>\n <ul>\n <li><a href="#Level+2">Level 2</a> </li>\n </ul>\n </li>\n </ul>)
|
41
|
+
assert_equal exp, rd.toc_content.strip
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crasher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors: []
|
7
|
+
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-20 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email:
|
18
|
+
executables:
|
19
|
+
- rdiscount
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- COPYING
|
24
|
+
files:
|
25
|
+
- COPYING
|
26
|
+
- README.markdown
|
27
|
+
- Rakefile
|
28
|
+
- bin/rdiscount
|
29
|
+
- crasher.gemspec
|
30
|
+
- ext/Csio.c
|
31
|
+
- ext/amalloc.h
|
32
|
+
- ext/config.h
|
33
|
+
- ext/cstring.h
|
34
|
+
- ext/docheader.c
|
35
|
+
- ext/dumptree.c
|
36
|
+
- ext/extconf.rb
|
37
|
+
- ext/generate.c
|
38
|
+
- ext/markdown.c
|
39
|
+
- ext/markdown.h
|
40
|
+
- ext/mkdio.c
|
41
|
+
- ext/mkdio.h
|
42
|
+
- ext/rdiscount.c
|
43
|
+
- ext/resource.c
|
44
|
+
- ext/toc.c
|
45
|
+
- lib/crasher.rb
|
46
|
+
- lib/markdown.rb
|
47
|
+
- test/benchmark.rb
|
48
|
+
- test/benchmark.txt
|
49
|
+
- test/markdown_test.rb
|
50
|
+
- test/rdiscount_test.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage:
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project: wink
|
75
|
+
rubygems_version: 1.3.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: x
|
79
|
+
test_files:
|
80
|
+
- test/markdown_test.rb
|
81
|
+
- test/rdiscount_test.rb
|