rdiscount-dsc 1.6.9
Sign up to get free protection for your applications and to get access to all the features.
- data/BUILDING +34 -0
- data/COPYING +52 -0
- data/README.markdown +71 -0
- data/Rakefile +182 -0
- data/bin/rdiscount +19 -0
- data/ext/Csio.c +61 -0
- data/ext/amalloc.h +29 -0
- data/ext/basename.c +43 -0
- data/ext/config.h +23 -0
- data/ext/css.c +85 -0
- data/ext/cstring.h +77 -0
- data/ext/docheader.c +49 -0
- data/ext/dumptree.c +152 -0
- data/ext/emmatch.c +188 -0
- data/ext/extconf.rb +18 -0
- data/ext/generate.c +1642 -0
- data/ext/html5.c +24 -0
- data/ext/markdown.c +1215 -0
- data/ext/markdown.h +169 -0
- data/ext/mkdio.c +344 -0
- data/ext/mkdio.h +100 -0
- data/ext/rdiscount.c +106 -0
- data/ext/resource.c +157 -0
- data/ext/tags.c +123 -0
- data/ext/tags.h +19 -0
- data/ext/toc.c +101 -0
- data/ext/xml.c +82 -0
- data/lib/markdown.rb +1 -0
- data/lib/rdiscount.rb +87 -0
- data/man/markdown.7 +1020 -0
- data/man/rdiscount.1 +119 -0
- data/man/rdiscount.1.ronn +98 -0
- data/rdiscount-dsc.gemspec +57 -0
- data/test/benchmark.rb +56 -0
- data/test/benchmark.txt +306 -0
- data/test/markdown_test.rb +159 -0
- data/test/rdiscount_test.rb +111 -0
- metadata +88 -0
@@ -0,0 +1,159 @@
|
|
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.', :MKD_NOPANTS)
|
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_!', :MKD_NOPANTS)
|
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>', :MKD_NOPANTS)
|
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'", :MKD_NOPANTS)
|
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>', :MKD_NOPANTS, :MKD_NOHTML)
|
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.', :MKD_NOPANTS)
|
43
|
+
[:filter_styles].each do |restriction|
|
44
|
+
assert_respond_to markdown, restriction
|
45
|
+
assert_respond_to markdown, "#{restriction}="
|
46
|
+
end
|
47
|
+
assert_not_equal RDiscount::MKD_NOHTML, markdown.flags & RDiscount::MKD_NOHTML
|
48
|
+
assert_not_equal true, markdown.filter_styles
|
49
|
+
|
50
|
+
markdown = Markdown.new('Hello World.', :MKD_NOPANTS, :MKD_NOHTML, :filter_styles)
|
51
|
+
assert_equal RDiscount::MKD_NOHTML, markdown.flags & RDiscount::MKD_NOHTML
|
52
|
+
assert_equal true, markdown.filter_styles
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_that_redcloth_attributes_are_supported
|
56
|
+
markdown = Markdown.new('Hello World.', :MKD_NOPANTS)
|
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.', :MKD_NOPANTS, :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.', :MKD_NOPANTS)
|
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.")
|
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")
|
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)', :MKD_NOPANTS)
|
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", :MKD_NOPANTS)
|
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)", :MKD_NOPANTS)
|
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
|
+
def test_filter_html_doesnt_break_two_space_hard_break
|
98
|
+
markdown = Markdown.new("Lorem, \nipsum\n", :MKD_NOPANTS, :MKD_NOHTML)
|
99
|
+
assert_equal "<p>Lorem,<br/>\nipsum</p>\n",
|
100
|
+
markdown.to_html
|
101
|
+
end
|
102
|
+
|
103
|
+
# This isn't in the spec but is Markdown.pl behavior.
|
104
|
+
def test_block_quotes_preceded_by_spaces
|
105
|
+
markdown = Markdown.new(
|
106
|
+
"A wise man once said:\n\n" +
|
107
|
+
" > Isn't it wonderful just to be alive.\n",
|
108
|
+
:MKD_NOPANTS
|
109
|
+
)
|
110
|
+
assert_equal "<p>A wise man once said:</p>\n\n" +
|
111
|
+
"<blockquote><p>Isn't it wonderful just to be alive.</p></blockquote>\n",
|
112
|
+
markdown.to_html
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_ul_with_zero_space_indent
|
116
|
+
markdown = Markdown.new("- foo\n\n- bar\n\n baz\n", :MKD_NOPANTS)
|
117
|
+
assert_equal "<ul><li><p>foo</p></li><li><p>bar</p><p>baz</p></li></ul>",
|
118
|
+
markdown.to_html.gsub("\n", "")
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_ul_with_single_space_indent
|
122
|
+
markdown = Markdown.new(" - foo\n\n - bar\n\n baz\n", :MKD_NOPANTS)
|
123
|
+
assert_equal "<ul><li><p>foo</p></li><li><p>bar</p><p>baz</p></li></ul>",
|
124
|
+
markdown.to_html.gsub("\n", "")
|
125
|
+
end
|
126
|
+
|
127
|
+
# http://github.com/rtomayko/rdiscount/issues/#issue/13
|
128
|
+
def test_headings_with_trailing_space
|
129
|
+
text = "The Ant-Sugar Tales \n" +
|
130
|
+
"=================== \n\n" +
|
131
|
+
"By Candice Yellowflower \n"
|
132
|
+
markdown = Markdown.new(text, :MKD_NOPANTS)
|
133
|
+
assert_equal "<h1>The Ant-Sugar Tales </h1>\n\n<p>By Candice Yellowflower</p>\n",
|
134
|
+
markdown.to_html
|
135
|
+
end
|
136
|
+
|
137
|
+
# Build tests for each file in the MarkdownTest test suite
|
138
|
+
|
139
|
+
Dir["#{MARKDOWN_TEST_DIR}/Tests/*.text"].each do |text_file|
|
140
|
+
|
141
|
+
basename = File.basename(text_file).sub(/\.text$/, '')
|
142
|
+
html_file = text_file.sub(/text$/, 'html')
|
143
|
+
method_name = basename.gsub(/[-,()]/, '').gsub(/\s+/, '_').downcase
|
144
|
+
|
145
|
+
define_method "test_#{method_name}" do
|
146
|
+
markdown = Markdown.new(File.read(text_file), :MKD_NOPANTS)
|
147
|
+
actual_html = markdown.to_html
|
148
|
+
assert_not_nil actual_html
|
149
|
+
end
|
150
|
+
|
151
|
+
define_method "test_#{method_name}_smart" do
|
152
|
+
markdown = Markdown.new(File.read(text_file))
|
153
|
+
actual_html = markdown.to_html
|
154
|
+
assert_not_nil actual_html
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
rootdir = File.dirname(File.dirname(__FILE__))
|
3
|
+
$LOAD_PATH.unshift "#{rootdir}/lib"
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'rdiscount'
|
7
|
+
|
8
|
+
class RDiscountTest < Test::Unit::TestCase
|
9
|
+
def test_that_discount_does_not_blow_up_with_weird_formatting_case
|
10
|
+
text = (<<-TEXT).gsub(/^ {4}/, '').rstrip
|
11
|
+
1. some text
|
12
|
+
|
13
|
+
1.
|
14
|
+
TEXT
|
15
|
+
RDiscount.new(text, :MKD_NOPANTS).to_html
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_that_smart_converts_double_quotes_to_curly_quotes
|
19
|
+
rd = RDiscount.new(%("Quoted text"))
|
20
|
+
assert_equal %(<p>“Quoted text”</p>\n), rd.to_html
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_that_smart_converts_double_quotes_to_curly_quotes_before_a_heading
|
24
|
+
rd = RDiscount.new(%("Quoted text"\n\n# Heading))
|
25
|
+
assert_equal %(<p>“Quoted text”</p>\n\n<h1>Heading</h1>\n), rd.to_html
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_that_smart_converts_double_quotes_to_curly_quotes_after_a_heading
|
29
|
+
rd = RDiscount.new(%(# Heading\n\n"Quoted text"))
|
30
|
+
assert_equal %(<h1>Heading</h1>\n\n<p>“Quoted text”</p>\n), rd.to_html
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_that_smart_gives_ve_suffix_a_rsquo
|
34
|
+
rd = RDiscount.new("I've been meaning to tell you ..")
|
35
|
+
assert_equal "<p>I’ve been meaning to tell you ..</p>\n", rd.to_html
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_that_smart_gives_m_suffix_a_rsquo
|
39
|
+
rd = RDiscount.new("I'm not kidding")
|
40
|
+
assert_equal "<p>I’m not kidding</p>\n", rd.to_html
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_that_smart_gives_d_suffix_a_rsquo
|
44
|
+
rd = RDiscount.new("what'd you say?")
|
45
|
+
assert_equal "<p>what’d you say?</p>\n", rd.to_html
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_that_generate_toc_sets_toc_ids
|
49
|
+
rd = RDiscount.new("# Level 1\n\n## Level 2", :MKD_NOPANTS, :MKD_TOC)
|
50
|
+
assert_equal RDiscount::MKD_TOC, rd.flags & RDiscount::MKD_TOC
|
51
|
+
assert_equal %(<a name="Level.1"></a>\n<h1>Level 1</h1>\n\n<a name="Level.2"></a>\n<h2>Level 2</h2>\n), rd.to_html
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_should_get_the_generated_toc
|
55
|
+
rd = RDiscount.new("# Level 1\n\n## Level 2", :MKD_NOPANTS, :MKD_TOC)
|
56
|
+
exp = %(<ul>\n <li><a href="#Level.1">Level 1</a></li>\n <li><ul>\n <li><a href="#Level.2">Level 2</a></li>\n </ul></li>\n</ul>)
|
57
|
+
assert_equal exp, rd.toc_content.strip
|
58
|
+
end
|
59
|
+
|
60
|
+
if "".respond_to?(:encoding)
|
61
|
+
def test_should_return_string_in_same_encoding_as_input
|
62
|
+
input = "Yogācāra"
|
63
|
+
output = RDiscount.new(input).to_html
|
64
|
+
assert_equal input.encoding.name, output.encoding.name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_that_no_image_flag_works
|
69
|
+
rd = RDiscount.new(%( <img src="image.png" />), :MKD_NOPANTS, :MKD_NOIMAGE)
|
70
|
+
assert rd.to_html !~ /<img/
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_that_no_links_flag_works
|
74
|
+
rd = RDiscount.new(%([This link](http://example.net/) <a href="links.html">links</a>), :MKD_NOPANTS, :MKD_NOLINKS)
|
75
|
+
assert rd.to_html !~ /<a /
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_that_no_tables_flag_works
|
79
|
+
rd = RDiscount.new(<<EOS, :MKD_NOPANTS, :MKD_NOTABLES)
|
80
|
+
aaa | bbbb
|
81
|
+
-----|------
|
82
|
+
hello|sailor
|
83
|
+
EOS
|
84
|
+
assert rd.to_html !~ /<table/
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_that_strict_flag_works
|
88
|
+
rd = RDiscount.new("foo_bar_baz", :MKD_NOPANTS, :MKD_STRICT)
|
89
|
+
assert_equal "<p>foo<em>bar</em>baz</p>\n", rd.to_html
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_that_autolink_flag_works
|
93
|
+
rd = RDiscount.new("http://github.com/rtomayko/rdiscount", :MKD_NOPANTS, :MKD_AUTOLINK)
|
94
|
+
assert_equal "<p><a href=\"http://github.com/rtomayko/rdiscount\">http://github.com/rtomayko/rdiscount</a></p>\n", rd.to_html
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_that_safelink_flag_works
|
98
|
+
rd = RDiscount.new("[IRC](irc://chat.freenode.org/#freenode)", :MKD_NOPANTS, :MKD_SAFELINK)
|
99
|
+
assert_equal "<p>[IRC](irc://chat.freenode.org/#freenode)</p>\n", rd.to_html
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_that_no_pseudo_protocols_flag_works
|
103
|
+
rd = RDiscount.new("[foo](id:bar)", :MKD_NOPANTS, :MKD_NO_EXT)
|
104
|
+
assert_equal "<p>[foo](id:bar)</p>\n", rd.to_html
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_that_tags_can_have_dashes_and_underscores
|
108
|
+
rd = RDiscount.new("foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b>", :MKD_NOPANTS)
|
109
|
+
assert_equal "<p>foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b></p>\n", rd.to_html
|
110
|
+
end
|
111
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdiscount-dsc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.9
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan Tomayko
|
9
|
+
- David Loren Parsons
|
10
|
+
- Andrew White
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2011-01-25 00:00:00.000000000 Z
|
15
|
+
dependencies: []
|
16
|
+
description:
|
17
|
+
email: rtomayko@gmail.com
|
18
|
+
executables:
|
19
|
+
- rdiscount
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- COPYING
|
24
|
+
files:
|
25
|
+
- BUILDING
|
26
|
+
- COPYING
|
27
|
+
- README.markdown
|
28
|
+
- Rakefile
|
29
|
+
- bin/rdiscount
|
30
|
+
- ext/Csio.c
|
31
|
+
- ext/amalloc.h
|
32
|
+
- ext/basename.c
|
33
|
+
- ext/config.h
|
34
|
+
- ext/css.c
|
35
|
+
- ext/cstring.h
|
36
|
+
- ext/docheader.c
|
37
|
+
- ext/dumptree.c
|
38
|
+
- ext/emmatch.c
|
39
|
+
- ext/extconf.rb
|
40
|
+
- ext/generate.c
|
41
|
+
- ext/html5.c
|
42
|
+
- ext/markdown.c
|
43
|
+
- ext/markdown.h
|
44
|
+
- ext/mkdio.c
|
45
|
+
- ext/mkdio.h
|
46
|
+
- ext/rdiscount.c
|
47
|
+
- ext/resource.c
|
48
|
+
- ext/tags.c
|
49
|
+
- ext/tags.h
|
50
|
+
- ext/toc.c
|
51
|
+
- ext/xml.c
|
52
|
+
- lib/markdown.rb
|
53
|
+
- lib/rdiscount.rb
|
54
|
+
- man/markdown.7
|
55
|
+
- man/rdiscount.1
|
56
|
+
- man/rdiscount.1.ronn
|
57
|
+
- rdiscount-dsc.gemspec
|
58
|
+
- test/benchmark.rb
|
59
|
+
- test/benchmark.txt
|
60
|
+
- test/markdown_test.rb
|
61
|
+
- test/rdiscount_test.rb
|
62
|
+
homepage: http://github.com/rtomayko/rdiscount
|
63
|
+
licenses: []
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project: wink
|
82
|
+
rubygems_version: 1.8.24
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Fast Implementation of Gruber's Markdown in C
|
86
|
+
test_files:
|
87
|
+
- test/markdown_test.rb
|
88
|
+
- test/rdiscount_test.rb
|