patcito-rdiscount 1.6.8
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 +13 -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 +23 -0
- data/ext/generate.c +1708 -0
- data/ext/html5.c +24 -0
- data/ext/markdown.c +1215 -0
- data/ext/markdown.h +171 -0
- data/ext/mkdio.c +344 -0
- data/ext/mkdio.h +101 -0
- data/ext/rdiscount.c +132 -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 +101 -0
- data/man/markdown.7 +1020 -0
- data/man/rdiscount.1 +22 -0
- data/man/rdiscount.1.ronn +24 -0
- data/rdiscount.gemspec +57 -0
- data/test/benchmark.rb +56 -0
- data/test/benchmark.txt +306 -0
- data/test/markdown_test.rb +158 -0
- data/test/rdiscount_test.rb +111 -0
- metadata +88 -0
@@ -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).to_html
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_that_smart_converts_double_quotes_to_curly_quotes
|
19
|
+
rd = RDiscount.new(%("Quoted text"), :smart)
|
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), :smart)
|
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"), :smart)
|
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 ..", :smart)
|
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", :smart)
|
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?", :smart)
|
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", :generate_toc)
|
50
|
+
assert rd.generate_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", :generate_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(%(![dust mite](http://dust.mite/image.png) <img src="image.png" />), :no_image)
|
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>), :no_links)
|
75
|
+
assert rd.to_html !~ /<a /
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_that_no_tables_flag_works
|
79
|
+
rd = RDiscount.new(<<EOS, :no_tables)
|
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", :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", :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)", :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)", :no_pseudo_protocols)
|
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>")
|
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: patcito-rdiscount
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.8
|
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.000000000Z
|
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.gemspec
|
58
|
+
- test/benchmark.rb
|
59
|
+
- test/benchmark.txt
|
60
|
+
- test/markdown_test.rb
|
61
|
+
- test/rdiscount_test.rb
|
62
|
+
homepage: http://github.com/patcito/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.10
|
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
|