radiant-smarty_pants_filter-extension 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,162 @@
1
+ require 'test/unit'
2
+ require 'rubypants'
3
+
4
+ # Test EVERYTHING against SmartyPants.pl output!
5
+
6
+
7
+ class TestRubyPants < Test::Unit::TestCase
8
+ def assert_rp_equal(str, orig, options=[2])
9
+ assert_equal orig, RubyPants.new(str, options).to_html
10
+ end
11
+
12
+ def assert_verbatim(str)
13
+ assert_rp_equal str, str
14
+ end
15
+
16
+ def test_verbatim
17
+ assert_verbatim "foo!"
18
+ assert_verbatim "<div>This is HTML</div>"
19
+ assert_verbatim "<div>This is HTML with <crap </div> tags>"
20
+ assert_verbatim <<EOF
21
+ multiline
22
+
23
+ <b>html</b>
24
+
25
+ code
26
+
27
+ EOF
28
+ end
29
+
30
+ def test_quotes
31
+ assert_rp_equal '"A first example"', '&#8220;A first example&#8221;'
32
+ assert_rp_equal '"A first "nested" example"',
33
+ '&#8220;A first &#8220;nested&#8221; example&#8221;'
34
+
35
+ assert_rp_equal '".', '&#8221;.'
36
+ assert_rp_equal '"a', '&#8220;a'
37
+
38
+ assert_rp_equal "'.", '&#8217;.'
39
+ assert_rp_equal "'a", '&#8216;a'
40
+
41
+ assert_rp_equal %{<p>He said, "'Quoted' words in a larger quote."</p>},
42
+ "<p>He said, &#8220;&#8216;Quoted&#8217; words in a larger quote.&#8221;</p>"
43
+
44
+ assert_rp_equal %{"I like the 70's"}, '&#8220;I like the 70&#8217;s&#8221;'
45
+ assert_rp_equal %{"I like the '70s"}, '&#8220;I like the &#8217;70s&#8221;'
46
+ assert_rp_equal %{"I like the '70!"}, '&#8220;I like the &#8216;70!&#8221;'
47
+
48
+ assert_rp_equal 'pre"post', 'pre&#8221;post'
49
+ assert_rp_equal 'pre "post', 'pre &#8220;post'
50
+ assert_rp_equal 'pre&nbsp;"post', 'pre&nbsp;&#8220;post'
51
+ assert_rp_equal 'pre--"post', 'pre&#8211;&#8220;post'
52
+ assert_rp_equal 'pre--"!', 'pre&#8211;&#8221;!'
53
+
54
+ assert_rp_equal "pre'post", 'pre&#8217;post'
55
+ assert_rp_equal "pre 'post", 'pre &#8216;post'
56
+ assert_rp_equal "pre&nbsp;'post", 'pre&nbsp;&#8216;post'
57
+ assert_rp_equal "pre--'post", 'pre&#8211;&#8216;post'
58
+ assert_rp_equal "pre--'!", 'pre&#8211;&#8217;!'
59
+
60
+ assert_rp_equal "<b>'</b>", "<b>&#8216;</b>"
61
+ assert_rp_equal "foo<b>'</b>", "foo<b>&#8217;</b>"
62
+
63
+ assert_rp_equal '<b>"</b>', "<b>&#8220;</b>"
64
+ assert_rp_equal 'foo<b>"</b>', "foo<b>&#8221;</b>"
65
+ end
66
+
67
+ def test_dashes
68
+ assert_rp_equal "foo--bar", 'foo&#8212;bar', 1
69
+ assert_rp_equal "foo---bar", 'foo&#8212;-bar', 1
70
+ assert_rp_equal "foo----bar", 'foo&#8212;&#8212;bar', 1
71
+ assert_rp_equal "foo-----bar", 'foo&#8212;&#8212;-bar', 1
72
+ assert_rp_equal "--foo--bar--quux--",
73
+ '&#8212;foo&#8212;bar&#8212;quux&#8212;', 1
74
+
75
+ assert_rp_equal "foo--bar", 'foo&#8211;bar', 2
76
+ assert_rp_equal "foo---bar", 'foo&#8212;bar', 2
77
+ assert_rp_equal "foo----bar", 'foo&#8212;-bar', 2
78
+ assert_rp_equal "foo-----bar", 'foo&#8212;&#8211;bar', 2
79
+ assert_rp_equal "--foo--bar--quux--",
80
+ '&#8211;foo&#8211;bar&#8211;quux&#8211;', 2
81
+
82
+ assert_rp_equal "foo--bar", 'foo&#8212;bar', 3
83
+ assert_rp_equal "foo---bar", 'foo&#8211;bar', 3
84
+ assert_rp_equal "foo----bar", 'foo&#8211;-bar', 3
85
+ assert_rp_equal "foo-----bar", 'foo&#8211;&#8212;bar', 3
86
+ assert_rp_equal "--foo--bar--quux--",
87
+ '&#8212;foo&#8212;bar&#8212;quux&#8212;', 3
88
+ end
89
+
90
+ def test_ellipses
91
+ assert_rp_equal "foo..bar", 'foo..bar'
92
+ assert_rp_equal "foo...bar", 'foo&#8230;bar'
93
+ assert_rp_equal "foo....bar", 'foo&#8230;.bar'
94
+
95
+ # Nasty ones
96
+ assert_rp_equal "foo. . ..bar", 'foo&#8230;.bar'
97
+ assert_rp_equal "foo. . ...bar", 'foo. . &#8230;bar'
98
+ assert_rp_equal "foo. . ....bar", 'foo. . &#8230;.bar'
99
+ end
100
+
101
+ def test_backticks
102
+ assert_rp_equal "pre``post", 'pre&#8220;post'
103
+ assert_rp_equal "pre ``post", 'pre &#8220;post'
104
+ assert_rp_equal "pre&nbsp;``post", 'pre&nbsp;&#8220;post'
105
+ assert_rp_equal "pre--``post", 'pre&#8211;&#8220;post'
106
+ assert_rp_equal "pre--``!", 'pre&#8211;&#8220;!'
107
+
108
+ assert_rp_equal "pre''post", 'pre&#8221;post'
109
+ assert_rp_equal "pre ''post", 'pre &#8221;post'
110
+ assert_rp_equal "pre&nbsp;''post", 'pre&nbsp;&#8221;post'
111
+ assert_rp_equal "pre--''post", 'pre&#8211;&#8221;post'
112
+ assert_rp_equal "pre--''!", 'pre&#8211;&#8221;!'
113
+ end
114
+
115
+ def test_single_backticks
116
+ o = [:oldschool, :allbackticks]
117
+
118
+ assert_rp_equal "`foo'", "&#8216;foo&#8217;", o
119
+
120
+ assert_rp_equal "pre`post", 'pre&#8216;post', o
121
+ assert_rp_equal "pre `post", 'pre &#8216;post', o
122
+ assert_rp_equal "pre&nbsp;`post", 'pre&nbsp;&#8216;post', o
123
+ assert_rp_equal "pre--`post", 'pre&#8211;&#8216;post', o
124
+ assert_rp_equal "pre--`!", 'pre&#8211;&#8216;!', o
125
+
126
+ assert_rp_equal "pre'post", 'pre&#8217;post', o
127
+ assert_rp_equal "pre 'post", 'pre &#8217;post', o
128
+ assert_rp_equal "pre&nbsp;'post", 'pre&nbsp;&#8217;post', o
129
+ assert_rp_equal "pre--'post", 'pre&#8211;&#8217;post', o
130
+ assert_rp_equal "pre--'!", 'pre&#8211;&#8217;!', o
131
+ end
132
+
133
+ def test_stupefy
134
+ o = [:stupefy]
135
+
136
+ assert_rp_equal "<p>He said, &#8220;&#8216;Quoted&#8217; words " +
137
+ "in a larger quote.&#8221;</p>",
138
+ %{<p>He said, "'Quoted' words in a larger quote."</p>}, o
139
+
140
+ assert_rp_equal "&#8211; &#8212; &#8216;&#8217; &#8220;&#8221; &#8230;",
141
+ %{- -- '' "" ...}, o
142
+
143
+ assert_rp_equal %{- -- '' "" ...}, %{- -- '' "" ...}, o
144
+ end
145
+
146
+ def test_process_escapes
147
+ assert_rp_equal %q{foo\bar}, "foo\\bar"
148
+ assert_rp_equal %q{foo\\\bar}, "foo&#92;bar"
149
+ assert_rp_equal %q{foo\\\\\bar}, "foo&#92;\\bar"
150
+ assert_rp_equal %q{foo\...bar}, "foo&#46;..bar"
151
+ assert_rp_equal %q{foo\.\.\.bar}, "foo&#46;&#46;&#46;bar"
152
+
153
+ assert_rp_equal %q{foo\'bar}, "foo&#39;bar"
154
+ assert_rp_equal %q{foo\"bar}, "foo&#34;bar"
155
+ assert_rp_equal %q{foo\-bar}, "foo&#45;bar"
156
+ assert_rp_equal %q{foo\`bar}, "foo&#96;bar"
157
+
158
+ assert_rp_equal %q{foo\#bar}, "foo\\#bar"
159
+ assert_rp_equal %q{foo\*bar}, "foo\\*bar"
160
+ assert_rp_equal %q{foo\&bar}, "foo\\&bar"
161
+ end
162
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-smarty_pants_filter-extension
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Radiant CMS Dev Team
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-12 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rubypants
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 0
34
+ version: 0.2.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Allows you to compose page parts or snippets using the Markdown text filter.
38
+ email:
39
+ - radiant@radiantcms.org
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - lib/radiant-smarty_pants_filter-extension/version.rb
48
+ - lib/radiant-smarty_pants_filter-extension.rb
49
+ - lib/smarty_pants_filter.rb
50
+ - lib/smarty_pants_tags.rb
51
+ - lib/tasks/smarty_pants_filter_extension_tasks.rake
52
+ - radiant-smarty_pants_filter-extension.gemspec
53
+ - Rakefile
54
+ - README
55
+ - smarty_pants_filter_extension.rb
56
+ - smartypants.html
57
+ - spec/models/smarty_pants_filter_spec.rb
58
+ - spec/spec.opts
59
+ - spec/spec_helper.rb
60
+ - test/test_helper.rb
61
+ - test/unit/smarty_pants_filter_test.rb
62
+ - vendor/rubypants/install.rb
63
+ - vendor/rubypants/Rakefile
64
+ - vendor/rubypants/README
65
+ - vendor/rubypants/rubypants.rb
66
+ - vendor/rubypants/test_rubypants.rb
67
+ has_rdoc: true
68
+ homepage: http://radiantcms.org/
69
+ licenses: []
70
+
71
+ post_install_message: "\n Add this to your radiant project with:\n config.gem \"radiant-smarty_pants_filter-extension\", :version => \"~> 1.0.0\"\n "
72
+ rdoc_options: []
73
+
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.6.2
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Markdown Filter for Radiant CMS
101
+ test_files:
102
+ - test/test_helper.rb
103
+ - test/unit/smarty_pants_filter_test.rb
104
+ - spec/models/smarty_pants_filter_spec.rb
105
+ - spec/spec.opts
106
+ - spec/spec_helper.rb