moredown 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +52 -0
- data/README.markdown +109 -0
- data/Rakefile +121 -0
- data/VERSION +1 -0
- data/bin/rdiscount +5 -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 +92 -0
- data/ext/resource.c +169 -0
- data/ext/toc.c +86 -0
- data/lib/markdown.rb +1 -0
- data/lib/moredown.rb +153 -0
- data/lib/rdiscount.rb +72 -0
- data/moredown.gemspec +73 -0
- data/test/benchmark.rb +56 -0
- data/test/benchmark.txt +306 -0
- data/test/markdown_test.rb +119 -0
- data/test/moredown_test.rb +172 -0
- data/test/rdiscount_test.rb +43 -0
- metadata +88 -0
@@ -0,0 +1,172 @@
|
|
1
|
+
rootdir = File.dirname(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift "#{rootdir}/lib"
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'moredown'
|
6
|
+
|
7
|
+
class MoredownTest < Test::Unit::TestCase
|
8
|
+
def test_that_base_markdown_is_working
|
9
|
+
text = "Hello. This is **bold**."
|
10
|
+
html = "<p>Hello. This is <strong>bold</strong>.</p>\n"
|
11
|
+
assert_equal html, Moredown.text_to_html(text)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_moredown
|
15
|
+
text = "Hello. This is **bold**."
|
16
|
+
html = "<p>Hello. This is <strong>bold</strong>.</p>\n"
|
17
|
+
assert_equal html, Moredown.new(text).to_html
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def test_youtube_videos
|
22
|
+
text = "![Video](youtube:12345678)"
|
23
|
+
html = "<p><object id=\"swf-1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/12345678\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/v/12345678\" width=\"425\" height=\"350\"><!--<![endif]--><a href=\"http://www.youtube.com/v/12345678\"><img src=\"http://img.youtube.com/vi/12345678/default.jpg\" alt=\"\" /></a><!--[if !IE]>--></object><!--<![endif]--></object></p>\n"
|
24
|
+
assert_equal html, Moredown.text_to_html(text)
|
25
|
+
|
26
|
+
text = "![Video](youtube:12345678 \"200 100\")"
|
27
|
+
html = 'width="200" height="100"'
|
28
|
+
assert Moredown.text_to_html(text).include?(html), "Width should be 200 and height should be 100"
|
29
|
+
|
30
|
+
text = <<TEXT
|
31
|
+
Here is a video:
|
32
|
+
|
33
|
+
![Video](youtube:12345678)
|
34
|
+
|
35
|
+
That was _awesome_.
|
36
|
+
TEXT
|
37
|
+
html = "<p>Here is a video:</p>\n\n<p><object id=\"swf-1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/12345678\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/v/12345678\" width=\"425\" height=\"350\"><!--<![endif]--><a href=\"http://www.youtube.com/v/12345678\"><img src=\"http://img.youtube.com/vi/12345678/default.jpg\" alt=\"\" /></a><!--[if !IE]>--></object><!--<![endif]--></object></p>\n\n<p>That was <em>awesome</em>.</p>\n"
|
38
|
+
assert_equal html, Moredown.text_to_html(text)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_image_alignments
|
42
|
+
text = "![Image](/image.jpg):left"
|
43
|
+
html = "<p><img style=\"float: left; margin: 0 10px 10px 0;\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
|
44
|
+
assert_equal html, Moredown.text_to_html(text)
|
45
|
+
|
46
|
+
text = "![Image](/image.jpg):left"
|
47
|
+
html = "<p><img class=\"left\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
|
48
|
+
assert_equal html, Moredown.text_to_html(text, :has_stylesheet => true)
|
49
|
+
|
50
|
+
text = "![Image](/image.jpg):right"
|
51
|
+
html = "<p><img style=\"float: right; margin: 0 0 10px 10px;\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
|
52
|
+
assert_equal html, Moredown.text_to_html(text)
|
53
|
+
|
54
|
+
text = "![Image](/image.jpg):right"
|
55
|
+
html = "<p><img class=\"right\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
|
56
|
+
assert_equal html, Moredown.text_to_html(text, :has_stylesheet => true)
|
57
|
+
|
58
|
+
text = "![Image](/image.jpg):center"
|
59
|
+
html = "<p><img style=\"display: block; margin: auto;\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
|
60
|
+
assert_equal html, Moredown.text_to_html(text)
|
61
|
+
|
62
|
+
text = "![Image](/image.jpg):center"
|
63
|
+
html = "<p><img class=\"center\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
|
64
|
+
assert_equal html, Moredown.text_to_html(text, :has_stylesheet => true)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_code
|
68
|
+
text = <<TEXT
|
69
|
+
Here is some code:
|
70
|
+
|
71
|
+
def test_code
|
72
|
+
puts 'test'
|
73
|
+
end
|
74
|
+
|
75
|
+
That is all.
|
76
|
+
TEXT
|
77
|
+
html = "<p>Here is some code:</p>\n\n<pre class=\"prettyprint\"><code>def test_code\n puts 'test'\nend\n</code></pre>\n\n<p>That is all.</p>\n"
|
78
|
+
assert_equal html, Moredown.text_to_html(text)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_emotes
|
82
|
+
assert_equal "<p>:-)</p>\n", Moredown.text_to_html(':-)'), "Emotes are ignored when the switch is off"
|
83
|
+
|
84
|
+
text = ':-)'
|
85
|
+
html = "<p><img src=\"/images/emote-smile.png\" alt=\":-)\" width=\"16\" height=\"16\" /></p>\n"
|
86
|
+
assert_equal html, Moredown.text_to_html(text, :emotes => true)
|
87
|
+
|
88
|
+
text = ':-P'
|
89
|
+
html = "<p><img src=\"/images/emote-tongue.png\" alt=\":-P\" width=\"16\" height=\"16\" /></p>\n"
|
90
|
+
assert_equal html, Moredown.text_to_html(text, :emotes => true)
|
91
|
+
|
92
|
+
text = ':-D'
|
93
|
+
html = "<p><img src=\"/images/emote-grin.png\" alt=\":-D\" width=\"16\" height=\"16\" /></p>\n"
|
94
|
+
assert_equal html, Moredown.text_to_html(text, :emotes => true)
|
95
|
+
|
96
|
+
text = ':-('
|
97
|
+
html = "<p><img src=\"/images/emote-sad.png\" alt=\":-(\" width=\"16\" height=\"16\" /></p>\n"
|
98
|
+
assert_equal html, Moredown.text_to_html(text, :emotes => true)
|
99
|
+
|
100
|
+
text = ':-@'
|
101
|
+
html = "<p><img src=\"/images/emote-angry.png\" alt=\":-@\" width=\"16\" height=\"16\" /></p>\n"
|
102
|
+
assert_equal html, Moredown.text_to_html(text, :emotes => true)
|
103
|
+
|
104
|
+
text = ';-)'
|
105
|
+
html = "<p><img src=\"/images/emote-wink.png\" alt=\";-)\" width=\"16\" height=\"16\" /></p>\n"
|
106
|
+
assert_equal html, Moredown.text_to_html(text, :emotes => true)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_base_url
|
110
|
+
text = "![Image](/images/test.jpg)"
|
111
|
+
html = "<p><img src=\"http://www.example.com/images/test.jpg\" alt=\"Image\" /></p>\n"
|
112
|
+
assert_equal html, Moredown.text_to_html(text, :base_url => 'http://www.example.com')
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_remap_headings
|
116
|
+
text = "<h1>Heading</h1>\n<h2>Sub-heading</h2>"
|
117
|
+
html = "<h1>Heading</h1>\n\n\n<h2>Sub-heading</h2>\n\n"
|
118
|
+
assert_equal html, Moredown.text_to_html(text, :map_headings => 0)
|
119
|
+
|
120
|
+
text = "<h1>Heading</h1>\n<h2>Sub-heading</h2>"
|
121
|
+
html = "<h2>Heading</h2>\n\n\n<h3>Sub-heading</h3>\n\n"
|
122
|
+
assert_equal html, Moredown.text_to_html(text, :map_headings => 1)
|
123
|
+
|
124
|
+
text = "<h1>Heading</h1>\n<h2>Sub-heading</h2>"
|
125
|
+
html = "<h3>Heading</h3>\n\n\n<h4>Sub-heading</h4>\n\n"
|
126
|
+
assert_equal html, Moredown.text_to_html(text, :map_headings => 2)
|
127
|
+
|
128
|
+
text = <<TEXT
|
129
|
+
Heading
|
130
|
+
=======
|
131
|
+
|
132
|
+
Sub-heading
|
133
|
+
-----------
|
134
|
+
TEXT
|
135
|
+
html = "<h3>Heading</h3>\n\n<h4>Sub-heading</h4>\n"
|
136
|
+
assert_equal html, Moredown.text_to_html(text, :map_headings => 2)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_flash_movies
|
140
|
+
text = '![Flash](flash:movieclip.swf)'
|
141
|
+
html = "<p><object id=\"swf-1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"400\" height=\"300\"><param name=\"movie\" value=\"movieclip.swf\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"movieclip.swf\" width=\"400\" height=\"300\"><!--<![endif]-->Flash is not available.<!--[if !IE]>--></object><!--<![endif]--></object></p>\n"
|
142
|
+
assert_equal html, Moredown.text_to_html(text)
|
143
|
+
|
144
|
+
text = '![Flash](flash:movieclip.swf "800 600")'
|
145
|
+
html = 'width="800" height="600"'
|
146
|
+
assert Moredown.text_to_html(text).include?(html), "Width should be 800 and height should be 600"
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_swfobject
|
150
|
+
text = "Here is some flash:
|
151
|
+
|
152
|
+
![Flash](flash:movieclip.swf)
|
153
|
+
|
154
|
+
![Flash](flash:movieclip.swf)
|
155
|
+
|
156
|
+
And that's all."
|
157
|
+
html = "<script type=\"text/javascript\" src=\"./swfobject.js\"></script><script type=\"text/javascript\">
|
158
|
+
/*<![CDATA[*/
|
159
|
+
swfobject.registerObject(\"swf-1\", \"10\");
|
160
|
+
swfobject.registerObject(\"swf-2\", \"10\");
|
161
|
+
/*]]>*/
|
162
|
+
</script>
|
163
|
+
<p>Here is some flash:</p>
|
164
|
+
|
165
|
+
<p><object id=\"swf-1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"400\" height=\"300\"><param name=\"movie\" value=\"movieclip.swf\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"movieclip.swf\" width=\"400\" height=\"300\"><!--<![endif]-->No Flash<!--[if !IE]>--></object><!--<![endif]--></object></p>
|
166
|
+
|
167
|
+
<p><object id=\"swf-2\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"400\" height=\"300\"><param name=\"movie\" value=\"movieclip.swf\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"movieclip.swf\" width=\"400\" height=\"300\"><!--<![endif]-->No Flash<!--[if !IE]>--></object><!--<![endif]--></object></p>
|
168
|
+
|
169
|
+
<p>And that's all.</p>\n"
|
170
|
+
assert_equal html, Moredown.text_to_html(text, :swfobject => { :src => './swfobject.js', :version => '10', :fallback => 'No Flash' })
|
171
|
+
end
|
172
|
+
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,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moredown
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Hoad
|
8
|
+
- Ryan Tomayko
|
9
|
+
- David Loren Parsons
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2009-10-23 00:00:00 +10:00
|
15
|
+
default_executable: rdiscount
|
16
|
+
dependencies: []
|
17
|
+
|
18
|
+
description: An extension to the RDiscount Markdown formatter
|
19
|
+
email: nathan@nathanhoad.net
|
20
|
+
executables:
|
21
|
+
- rdiscount
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files:
|
25
|
+
- README.markdown
|
26
|
+
files:
|
27
|
+
- COPYING
|
28
|
+
- README.markdown
|
29
|
+
- Rakefile
|
30
|
+
- VERSION
|
31
|
+
- bin/rdiscount
|
32
|
+
- ext/Csio.c
|
33
|
+
- ext/amalloc.h
|
34
|
+
- ext/config.h
|
35
|
+
- ext/cstring.h
|
36
|
+
- ext/docheader.c
|
37
|
+
- ext/dumptree.c
|
38
|
+
- ext/extconf.rb
|
39
|
+
- ext/generate.c
|
40
|
+
- ext/markdown.c
|
41
|
+
- ext/markdown.h
|
42
|
+
- ext/mkdio.c
|
43
|
+
- ext/mkdio.h
|
44
|
+
- ext/rdiscount.c
|
45
|
+
- ext/resource.c
|
46
|
+
- ext/toc.c
|
47
|
+
- lib/markdown.rb
|
48
|
+
- lib/moredown.rb
|
49
|
+
- lib/rdiscount.rb
|
50
|
+
- moredown.gemspec
|
51
|
+
- test/benchmark.rb
|
52
|
+
- test/benchmark.txt
|
53
|
+
- test/markdown_test.rb
|
54
|
+
- test/moredown_test.rb
|
55
|
+
- test/rdiscount_test.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://nathanhoad.net/projects/moredown
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options:
|
62
|
+
- --charset=UTF-8
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.3.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Markdown plus more!
|
84
|
+
test_files:
|
85
|
+
- test/benchmark.rb
|
86
|
+
- test/markdown_test.rb
|
87
|
+
- test/moredown_test.rb
|
88
|
+
- test/rdiscount_test.rb
|