nathanhoad-moredown 1.0.0

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.
@@ -0,0 +1,136 @@
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 data=\"http://www.youtube.com/v/12345678\" type=\"application/x-shockwave-flash\" width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/12345678\" /></object></p>\n"
24
+ assert_equal html, Moredown.text_to_html(text)
25
+
26
+ text = <<TEXT
27
+ Here is a video:
28
+
29
+ ![Video](youtube:12345678)
30
+
31
+ That was _awesome_.
32
+ TEXT
33
+ html = <<TEXT
34
+ <p>Here is a video:</p>
35
+
36
+ <p><object data="http://www.youtube.com/v/12345678" type="application/x-shockwave-flash" width="425" height="350"><param name="movie" value="http://www.youtube.com/v/12345678" /></object></p>
37
+
38
+ <p>That was <em>awesome</em>.</p>
39
+ TEXT
40
+ assert_equal html, Moredown.text_to_html(text)
41
+ end
42
+
43
+ def test_youtube_images
44
+ text = "![Video](youtube:12345678)"
45
+ html = "<p><img src=\"http://img.youtube.com/vi/12345678/default.jpg\" alt=\"Video\" /></p>\n"
46
+ assert_equal html, Moredown.text_to_html(text, :youtube_as_images => true)
47
+ end
48
+
49
+ def test_image_alignments
50
+ text = "![Image](/image.jpg):left"
51
+ html = "<p><img style=\"float: left; margin: 0 10px 10px 0;\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
52
+ assert_equal html, Moredown.text_to_html(text)
53
+
54
+ text = "![Image](/image.jpg):left"
55
+ html = "<p><img class=\"left\" 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):right"
59
+ html = "<p><img style=\"float: right; margin: 0 0 10px 10px;\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
60
+ assert_equal html, Moredown.text_to_html(text)
61
+
62
+ text = "![Image](/image.jpg):right"
63
+ html = "<p><img class=\"right\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
64
+ assert_equal html, Moredown.text_to_html(text, :has_stylesheet => true)
65
+
66
+ text = "![Image](/image.jpg):center"
67
+ html = "<p><img style=\"display: block; margin: auto;\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
68
+ assert_equal html, Moredown.text_to_html(text)
69
+
70
+ text = "![Image](/image.jpg):center"
71
+ html = "<p><img class=\"center\" src=\"/image.jpg\" alt=\"Image\" /></p>\n"
72
+ assert_equal html, Moredown.text_to_html(text, :has_stylesheet => true)
73
+ end
74
+
75
+ def test_code
76
+ text = <<TEXT
77
+ Here is some code:
78
+
79
+ def test_code
80
+ puts 'test'
81
+ end
82
+
83
+ That is all.
84
+ TEXT
85
+ 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"
86
+ assert_equal html, Moredown.text_to_html(text)
87
+ end
88
+
89
+ def test_emotes
90
+ assert_equal "<p>:-)</p>\n", Moredown.text_to_html(':-)'), "Emotes are ignored when the switch is off"
91
+
92
+ text = ':-)'
93
+ html = "<p><img src=\"/images/emote-smile.png\" alt=\":-)\" width=\"16\" height=\"16\" /></p>\n"
94
+ assert_equal html, Moredown.text_to_html(text, :emotes => true)
95
+
96
+ text = ':-P'
97
+ html = "<p><img src=\"/images/emote-tongue.png\" alt=\":-P\" width=\"16\" height=\"16\" /></p>\n"
98
+ assert_equal html, Moredown.text_to_html(text, :emotes => true)
99
+
100
+ text = ':-D'
101
+ html = "<p><img src=\"/images/emote-grin.png\" alt=\":-D\" 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-sad.png\" alt=\":-(\" width=\"16\" height=\"16\" /></p>\n"
106
+ assert_equal html, Moredown.text_to_html(text, :emotes => true)
107
+
108
+ text = ':-@'
109
+ html = "<p><img src=\"/images/emote-angry.png\" alt=\":-@\" width=\"16\" height=\"16\" /></p>\n"
110
+ assert_equal html, Moredown.text_to_html(text, :emotes => true)
111
+
112
+ text = ';-)'
113
+ html = "<p><img src=\"/images/emote-wink.png\" alt=\";-)\" width=\"16\" height=\"16\" /></p>\n"
114
+ assert_equal html, Moredown.text_to_html(text, :emotes => true)
115
+ end
116
+
117
+ def test_base_url
118
+ text = "![Image](/images/test.jpg)"
119
+ html = "<p><img src=\"http://www.example.com/images/test.jpg\" alt=\"Image\" /></p>\n"
120
+ assert_equal html, Moredown.text_to_html(text, :base_url => 'http://www.example.com')
121
+ end
122
+
123
+ def test_remap_headings
124
+ text = "<h1>Heading</h1>\n<h2>Sub-heading</h2>"
125
+ html = "<h1>Heading</h1>\n\n\n<h2>Sub-heading</h2>\n\n"
126
+ assert_equal html, Moredown.text_to_html(text, :map_headings => 0)
127
+
128
+ text = "<h1>Heading</h1>\n<h2>Sub-heading</h2>"
129
+ html = "<h2>Heading</h2>\n\n\n<h3>Sub-heading</h3>\n\n"
130
+ assert_equal html, Moredown.text_to_html(text, :map_headings => 1)
131
+
132
+ text = "<h1>Heading</h1>\n<h2>Sub-heading</h2>"
133
+ html = "<h3>Heading</h3>\n\n\n<h4>Sub-heading</h4>\n\n"
134
+ assert_equal html, Moredown.text_to_html(text, :map_headings => 2)
135
+ end
136
+ 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>&ldquo;Quoted text&rdquo;</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>&ldquo;Quoted text&rdquo;</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>&ldquo;Quoted text&rdquo;</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,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nathanhoad-moredown
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Hoad
8
+ - Ryan Tomayko
9
+ - Andrew White
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2009-08-22 00:00:00 -07:00
15
+ default_executable:
16
+ dependencies: []
17
+
18
+ description:
19
+ email: nathan@nathanhoad.net
20
+ executables:
21
+ - rdiscount
22
+ extensions:
23
+ - ext/extconf.rb
24
+ extra_rdoc_files:
25
+ - COPYING
26
+ files:
27
+ - COPYING
28
+ - README.markdown
29
+ - Rakefile
30
+ - bin/rdiscount
31
+ - ext/Csio.c
32
+ - ext/amalloc.h
33
+ - ext/config.h
34
+ - ext/cstring.h
35
+ - ext/docheader.c
36
+ - ext/dumptree.c
37
+ - ext/extconf.rb
38
+ - ext/generate.c
39
+ - ext/markdown.c
40
+ - ext/markdown.h
41
+ - ext/mkdio.c
42
+ - ext/mkdio.h
43
+ - ext/rdiscount.c
44
+ - ext/resource.c
45
+ - ext/toc.c
46
+ - lib/moredown.rb
47
+ - lib/markdown.rb
48
+ - lib/rdiscount.rb
49
+ - rdiscount.gemspec
50
+ - test/benchmark.rb
51
+ - test/benchmark.txt
52
+ - test/moredown_test.rb
53
+ - test/markdown_test.rb
54
+ - test/rdiscount_test.rb
55
+ has_rdoc: true
56
+ homepage: http://github.com/nathanhoad/moredown
57
+ licenses:
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ requirements: []
76
+
77
+ rubyforge_project:
78
+ rubygems_version: 1.3.5
79
+ signing_key:
80
+ specification_version: 2
81
+ summary: Fast Implementation of Gruber's Markdown in C
82
+ test_files:
83
+ - test/moredown_test.rb
84
+ - test/markdown_test.rb
85
+ - test/rdiscount_test.rb