rtomayko-rdiscount 1.3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +52 -0
- data/README.markdown +58 -0
- data/Rakefile +198 -0
- data/bin/rdiscount +5 -0
- data/ext/amalloc.h +29 -0
- data/ext/config.h +9 -0
- data/ext/cstring.h +68 -0
- data/ext/docheader.c +43 -0
- data/ext/dumptree.c +147 -0
- data/ext/extconf.rb +14 -0
- data/ext/generate.c +1379 -0
- data/ext/markdown.c +928 -0
- data/ext/markdown.h +131 -0
- data/ext/mkdio.c +241 -0
- data/ext/mkdio.h +65 -0
- data/ext/rbstrio.c +48 -0
- data/ext/rbstrio.h +4 -0
- data/ext/rdiscount.c +79 -0
- data/ext/resource.c +169 -0
- data/ext/toc.c +62 -0
- data/lib/markdown.rb +1 -0
- data/lib/rdiscount.rb +72 -0
- data/rdiscount.gemspec +47 -0
- data/test/benchmark.rb +56 -0
- data/test/benchmark.txt +306 -0
- data/test/markdown_test.rb +107 -0
- data/test/rdiscount_test.rb +43 -0
- metadata +81 -0
@@ -0,0 +1,107 @@
|
|
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
|
+
# Build tests for each file in the MarkdownTest test suite
|
86
|
+
|
87
|
+
Dir["#{MARKDOWN_TEST_DIR}/Tests/*.text"].each do |text_file|
|
88
|
+
|
89
|
+
basename = File.basename(text_file).sub(/\.text$/, '')
|
90
|
+
html_file = text_file.sub(/text$/, 'html')
|
91
|
+
method_name = basename.gsub(/[-,]/, '').gsub(/\s+/, '_').downcase
|
92
|
+
|
93
|
+
define_method "test_#{method_name}" do
|
94
|
+
markdown = Markdown.new(File.read(text_file))
|
95
|
+
actual_html = markdown.to_html
|
96
|
+
assert_not_nil actual_html
|
97
|
+
end
|
98
|
+
|
99
|
+
define_method "test_#{method_name}_with_smarty_enabled" do
|
100
|
+
markdown = Markdown.new(File.read(text_file), :smart)
|
101
|
+
actual_html = markdown.to_html
|
102
|
+
assert_not_nil actual_html
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
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: rtomayko-rdiscount
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Tomayko
|
8
|
+
- Andrew White
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-01-31 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description:
|
18
|
+
email: r@tomayko.com
|
19
|
+
executables:
|
20
|
+
- rdiscount
|
21
|
+
extensions:
|
22
|
+
- ext/extconf.rb
|
23
|
+
extra_rdoc_files:
|
24
|
+
- COPYING
|
25
|
+
files:
|
26
|
+
- COPYING
|
27
|
+
- README.markdown
|
28
|
+
- Rakefile
|
29
|
+
- bin/rdiscount
|
30
|
+
- ext/amalloc.h
|
31
|
+
- ext/config.h
|
32
|
+
- ext/cstring.h
|
33
|
+
- ext/docheader.c
|
34
|
+
- ext/dumptree.c
|
35
|
+
- ext/extconf.rb
|
36
|
+
- ext/generate.c
|
37
|
+
- ext/markdown.c
|
38
|
+
- ext/markdown.h
|
39
|
+
- ext/mkdio.c
|
40
|
+
- ext/mkdio.h
|
41
|
+
- ext/rbstrio.c
|
42
|
+
- ext/rbstrio.h
|
43
|
+
- ext/rdiscount.c
|
44
|
+
- ext/resource.c
|
45
|
+
- ext/toc.c
|
46
|
+
- lib/markdown.rb
|
47
|
+
- lib/rdiscount.rb
|
48
|
+
- rdiscount.gemspec
|
49
|
+
- test/benchmark.rb
|
50
|
+
- test/benchmark.txt
|
51
|
+
- test/markdown_test.rb
|
52
|
+
- test/rdiscount_test.rb
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/rtomayko/rdiscount
|
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.2.0
|
76
|
+
signing_key:
|
77
|
+
specification_version: 2
|
78
|
+
summary: Fast Implementation of Gruber's Markdown in C
|
79
|
+
test_files:
|
80
|
+
- test/markdown_test.rb
|
81
|
+
- test/rdiscount_test.rb
|