bluecloth 2.0.5-x86-mingw32

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.
Files changed (109) hide show
  1. data/ChangeLog +784 -0
  2. data/LICENSE +27 -0
  3. data/LICENSE.discount +47 -0
  4. data/README +81 -0
  5. data/Rakefile +346 -0
  6. data/Rakefile.local +63 -0
  7. data/bin/bluecloth +84 -0
  8. data/ext/Csio.c +61 -0
  9. data/ext/VERSION +1 -0
  10. data/ext/amalloc.h +29 -0
  11. data/ext/bluecloth.c +377 -0
  12. data/ext/config.h +51 -0
  13. data/ext/css.c +76 -0
  14. data/ext/cstring.h +74 -0
  15. data/ext/docheader.c +43 -0
  16. data/ext/extconf.rb +48 -0
  17. data/ext/generate.c +1481 -0
  18. data/ext/markdown.c +970 -0
  19. data/ext/markdown.h +145 -0
  20. data/ext/mkdio.c +303 -0
  21. data/ext/mkdio.h +78 -0
  22. data/ext/resource.c +155 -0
  23. data/ext/version.c +28 -0
  24. data/ext/xml.c +82 -0
  25. data/ext/xmlpage.c +48 -0
  26. data/lib/bluecloth.rb +161 -0
  27. data/rake/191_compat.rb +26 -0
  28. data/rake/dependencies.rb +76 -0
  29. data/rake/helpers.rb +412 -0
  30. data/rake/hg.rb +214 -0
  31. data/rake/manual.rb +782 -0
  32. data/rake/packaging.rb +135 -0
  33. data/rake/publishing.rb +321 -0
  34. data/rake/rdoc.rb +30 -0
  35. data/rake/style.rb +62 -0
  36. data/rake/svn.rb +668 -0
  37. data/rake/testing.rb +187 -0
  38. data/rake/verifytask.rb +64 -0
  39. data/rake/win32.rb +190 -0
  40. data/spec/bluecloth/101_changes_spec.rb +141 -0
  41. data/spec/bluecloth/autolinks_spec.rb +49 -0
  42. data/spec/bluecloth/blockquotes_spec.rb +143 -0
  43. data/spec/bluecloth/code_spans_spec.rb +164 -0
  44. data/spec/bluecloth/emphasis_spec.rb +164 -0
  45. data/spec/bluecloth/entities_spec.rb +65 -0
  46. data/spec/bluecloth/hrules_spec.rb +90 -0
  47. data/spec/bluecloth/images_spec.rb +92 -0
  48. data/spec/bluecloth/inline_html_spec.rb +238 -0
  49. data/spec/bluecloth/links_spec.rb +171 -0
  50. data/spec/bluecloth/lists_spec.rb +294 -0
  51. data/spec/bluecloth/paragraphs_spec.rb +75 -0
  52. data/spec/bluecloth/titles_spec.rb +305 -0
  53. data/spec/bluecloth_spec.rb +250 -0
  54. data/spec/bugfix_spec.rb +136 -0
  55. data/spec/contributions_spec.rb +85 -0
  56. data/spec/data/antsugar.txt +34 -0
  57. data/spec/data/markdowntest/Amps and angle encoding.html +17 -0
  58. data/spec/data/markdowntest/Amps and angle encoding.text +21 -0
  59. data/spec/data/markdowntest/Auto links.html +18 -0
  60. data/spec/data/markdowntest/Auto links.text +13 -0
  61. data/spec/data/markdowntest/Backslash escapes.html +118 -0
  62. data/spec/data/markdowntest/Backslash escapes.text +120 -0
  63. data/spec/data/markdowntest/Blockquotes with code blocks.html +15 -0
  64. data/spec/data/markdowntest/Blockquotes with code blocks.text +11 -0
  65. data/spec/data/markdowntest/Code Blocks.html +18 -0
  66. data/spec/data/markdowntest/Code Blocks.text +14 -0
  67. data/spec/data/markdowntest/Code Spans.html +5 -0
  68. data/spec/data/markdowntest/Code Spans.text +5 -0
  69. data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.html +8 -0
  70. data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.text +8 -0
  71. data/spec/data/markdowntest/Horizontal rules.html +71 -0
  72. data/spec/data/markdowntest/Horizontal rules.text +67 -0
  73. data/spec/data/markdowntest/Inline HTML (Advanced).html +15 -0
  74. data/spec/data/markdowntest/Inline HTML (Advanced).text +15 -0
  75. data/spec/data/markdowntest/Inline HTML (Simple).html +72 -0
  76. data/spec/data/markdowntest/Inline HTML (Simple).text +69 -0
  77. data/spec/data/markdowntest/Inline HTML comments.html +13 -0
  78. data/spec/data/markdowntest/Inline HTML comments.text +13 -0
  79. data/spec/data/markdowntest/Links, inline style.html +11 -0
  80. data/spec/data/markdowntest/Links, inline style.text +12 -0
  81. data/spec/data/markdowntest/Links, reference style.html +52 -0
  82. data/spec/data/markdowntest/Links, reference style.text +71 -0
  83. data/spec/data/markdowntest/Links, shortcut references.html +9 -0
  84. data/spec/data/markdowntest/Links, shortcut references.text +20 -0
  85. data/spec/data/markdowntest/Literal quotes in titles.html +3 -0
  86. data/spec/data/markdowntest/Literal quotes in titles.text +7 -0
  87. data/spec/data/markdowntest/Markdown Documentation - Basics.html +314 -0
  88. data/spec/data/markdowntest/Markdown Documentation - Basics.text +306 -0
  89. data/spec/data/markdowntest/Markdown Documentation - Syntax.html +942 -0
  90. data/spec/data/markdowntest/Markdown Documentation - Syntax.text +888 -0
  91. data/spec/data/markdowntest/Nested blockquotes.html +9 -0
  92. data/spec/data/markdowntest/Nested blockquotes.text +5 -0
  93. data/spec/data/markdowntest/Ordered and unordered lists.html +148 -0
  94. data/spec/data/markdowntest/Ordered and unordered lists.text +131 -0
  95. data/spec/data/markdowntest/Strong and em together.html +7 -0
  96. data/spec/data/markdowntest/Strong and em together.text +7 -0
  97. data/spec/data/markdowntest/Tabs.html +25 -0
  98. data/spec/data/markdowntest/Tabs.text +21 -0
  99. data/spec/data/markdowntest/Tidyness.html +8 -0
  100. data/spec/data/markdowntest/Tidyness.text +5 -0
  101. data/spec/data/ml-announce.txt +17 -0
  102. data/spec/data/re-overflow.txt +67 -0
  103. data/spec/data/re-overflow2.txt +281 -0
  104. data/spec/discount_spec.rb +67 -0
  105. data/spec/lib/constants.rb +5 -0
  106. data/spec/lib/helpers.rb +137 -0
  107. data/spec/lib/matchers.rb +235 -0
  108. data/spec/markdowntest_spec.rb +79 -0
  109. metadata +329 -0
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ BEGIN {
5
+ require 'pathname'
6
+ basedir = Pathname.new( __FILE__ ).dirname.parent.parent
7
+
8
+ libdir = basedir + 'lib'
9
+ extdir = basedir + 'ext'
10
+
11
+ $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
+ $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
+ }
14
+
15
+ require 'spec'
16
+ require 'bluecloth'
17
+
18
+ require 'spec/lib/helpers'
19
+ require 'spec/lib/constants'
20
+ require 'spec/lib/matchers'
21
+
22
+
23
+ #####################################################################
24
+ ### C O N T E X T S
25
+ #####################################################################
26
+
27
+ describe BlueCloth, "document with paragraphs" do
28
+ include BlueCloth::TestConstants,
29
+ BlueCloth::Matchers
30
+
31
+ it "wraps them in P tags" do
32
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
33
+ This is some stuff that should all be
34
+ put in one paragraph
35
+ even though
36
+ it occurs over several lines.
37
+
38
+ And this is a another
39
+ one.
40
+ ---
41
+ <p>This is some stuff that should all be
42
+ put in one paragraph
43
+ even though
44
+ it occurs over several lines.</p>
45
+
46
+ <p>And this is a another
47
+ one.</p>
48
+ ---
49
+ end
50
+
51
+ it "transforms trailing double spaces to line breaks" do
52
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
53
+ Mostly the same kind of thing
54
+ with two spaces at the end
55
+ of each line
56
+ should result in
57
+ line breaks, though.
58
+
59
+ And this is a another
60
+ one.
61
+ ---
62
+ <p>Mostly the same kind of thing<br/>
63
+ with two spaces at the end<br/>
64
+ of each line<br/>
65
+ should result in<br/>
66
+ line breaks, though.</p>
67
+
68
+ <p>And this is a another<br/>
69
+ one.</p>
70
+ ---
71
+ end
72
+
73
+ end
74
+
75
+
@@ -0,0 +1,305 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ BEGIN {
5
+ require 'pathname'
6
+ basedir = Pathname.new( __FILE__ ).dirname.parent.parent
7
+
8
+ libdir = basedir + 'lib'
9
+ extdir = basedir + 'ext'
10
+
11
+ $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
+ $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
+ }
14
+
15
+ require 'spec'
16
+ require 'bluecloth'
17
+
18
+ require 'spec/lib/helpers'
19
+ require 'spec/lib/constants'
20
+ require 'spec/lib/matchers'
21
+
22
+
23
+ #####################################################################
24
+ ### C O N T E X T S
25
+ #####################################################################
26
+
27
+ describe BlueCloth, "titles" do
28
+ include BlueCloth::TestConstants,
29
+ BlueCloth::Matchers
30
+
31
+ # setext-style h1 -- three characters
32
+ it "transforms Setext-style level-one headers (three equals) into an H1" do
33
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
34
+ Title Text
35
+ ===
36
+ ---
37
+ <h1>Title Text</h1>
38
+ ---
39
+ end
40
+
41
+ # setext-style h1 -- match title width
42
+ it "transforms Setext-style level-one headers (more than three equals) into an H1" do
43
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
44
+ Title Text
45
+ ==========
46
+ ---
47
+ <h1>Title Text</h1>
48
+ ---
49
+ end
50
+
51
+
52
+ # setext-style h2 -- one character
53
+ it "transforms Setext-style level-two headers (one dash) into an H2" do
54
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
55
+ Title Text
56
+ -
57
+ ---
58
+ <h2>Title Text</h2>
59
+ ---
60
+ end
61
+
62
+ # setext-style h2 -- three characters
63
+ it "transforms Setext-style level-two headers (three dashes) into an H2" do
64
+ the_indented_markdown( <<-"..." ).should be_transformed_into(<<-"...").without_indentation
65
+ Title Text
66
+ ---
67
+ ...
68
+ <h2>Title Text</h2>
69
+ ...
70
+ end
71
+
72
+ # setext-style h2 -- match title width
73
+ it "transforms Setext-style level-two headers (more than three dashes) into an H2" do
74
+ the_indented_markdown( <<-"..." ).should be_transformed_into(<<-"...").without_indentation
75
+ Title Text
76
+ ----------
77
+ ...
78
+ <h2>Title Text</h2>
79
+ ...
80
+ end
81
+
82
+ # ATX-style h1 -- Left side only
83
+ it "makes a header out of an ATX-style h1 -- Left side only" do
84
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
85
+ # Title Text
86
+ ---
87
+ <h1>Title Text</h1>
88
+ ---
89
+ end
90
+
91
+ # ATX-style h1 -- both sides
92
+ it "makes a header out of an ATX-style h1 -- both sides" do
93
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
94
+ # Title Text #
95
+ ---
96
+ <h1>Title Text</h1>
97
+ ---
98
+ end
99
+
100
+ # ATX-style h1 -- both sides, right side with three characters
101
+ it "makes a header out of an ATX-style h1 -- both sides, right side with three characters" do
102
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
103
+ # Title Text ###
104
+ ---
105
+ <h1>Title Text</h1>
106
+ ---
107
+ end
108
+
109
+ # ATX-style h1 -- both sides, right side with five characters
110
+ it "makes a header out of an ATX-style h1 -- both sides, right side with five characters" do
111
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
112
+ # Title Text #####
113
+ ---
114
+ <h1>Title Text</h1>
115
+ ---
116
+ end
117
+
118
+
119
+ # ATX-style h2 -- left side only
120
+ it "makes a header out of an ATX-style h2 -- left side only" do
121
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
122
+ ## Title Text
123
+ ---
124
+ <h2>Title Text</h2>
125
+ ---
126
+ end
127
+
128
+ # ATX-style h2 -- both sides
129
+ it "makes a header out of an ATX-style h2 -- both sides" do
130
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
131
+ ## Title Text #
132
+ ---
133
+ <h2>Title Text</h2>
134
+ ---
135
+ end
136
+
137
+ # ATX-style h2 -- both sides, right side with three characters
138
+ it "makes a header out of an ATX-style h2 -- both sides, right side with three characters" do
139
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
140
+ ## Title Text ###
141
+ ---
142
+ <h2>Title Text</h2>
143
+ ---
144
+ end
145
+
146
+ # ATX-style h2 -- both sides, right side with five characters
147
+ it "makes a header out of an ATX-style h2 -- both sides, right side with five characters" do
148
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
149
+ ## Title Text #####
150
+ ---
151
+ <h2>Title Text</h2>
152
+ ---
153
+ end
154
+
155
+
156
+ # ATX-style h3 -- left side only
157
+ it "makes a header out of an ATX-style h3 -- left side only" do
158
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
159
+ ### Title Text
160
+ ---
161
+ <h3>Title Text</h3>
162
+ ---
163
+ end
164
+
165
+ # ATX-style h3 -- both sides, right side with one character
166
+ it "makes a header out of an ATX-style h3 -- both sides, right side with one character" do
167
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
168
+ ### Title Text #
169
+ ---
170
+ <h3>Title Text</h3>
171
+ ---
172
+ end
173
+
174
+ # ATX-style h3 -- both sides, right side with three characters
175
+ it "makes a header out of an ATX-style h3 -- both sides, right side with three characters" do
176
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
177
+ ### Title Text ###
178
+ ---
179
+ <h3>Title Text</h3>
180
+ ---
181
+ end
182
+
183
+ # ATX-style h3 -- both sides, right side with five characters
184
+ it "makes a header out of an ATX-style h3 -- both sides, right side with five characters" do
185
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
186
+ ### Title Text #####
187
+ ---
188
+ <h3>Title Text</h3>
189
+ ---
190
+ end
191
+
192
+
193
+ # ATX-style h4 -- left side only
194
+ it "makes a header out of an ATX-style h4 -- left side only" do
195
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
196
+ #### Title Text
197
+ ---
198
+ <h4>Title Text</h4>
199
+ ---
200
+ end
201
+
202
+ # ATX-style h4 -- both sides, right side with one character
203
+ it "makes a header out of an ATX-style h4 -- both sides, right side with one character" do
204
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
205
+ #### Title Text #
206
+ ---
207
+ <h4>Title Text</h4>
208
+ ---
209
+ end
210
+
211
+ # ATX-style h4 -- both sides, right side with three characters
212
+ it "makes a header out of an ATX-style h4 -- both sides, right side with three characters" do
213
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
214
+ #### Title Text ###
215
+ ---
216
+ <h4>Title Text</h4>
217
+ ---
218
+ end
219
+
220
+ # ATX-style h4 -- both sides, right side with five characters
221
+ it "makes a header out of an ATX-style h4 -- both sides, right side with five characters" do
222
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
223
+ #### Title Text #####
224
+ ---
225
+ <h4>Title Text</h4>
226
+ ---
227
+ end
228
+
229
+
230
+ # ATX-style h5 -- left side only
231
+ it "makes a header out of an ATX-style h5 -- left side only" do
232
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
233
+ ##### Title Text
234
+ ---
235
+ <h5>Title Text</h5>
236
+ ---
237
+ end
238
+
239
+ # ATX-style h5 -- both sides, right side with one character
240
+ it "makes a header out of an ATX-style h5 -- both sides, right side with one character" do
241
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
242
+ ##### Title Text #
243
+ ---
244
+ <h5>Title Text</h5>
245
+ ---
246
+ end
247
+
248
+ # ATX-style h5 -- both sides, right side with three characters
249
+ it "makes a header out of an ATX-style h5 -- both sides, right side with three characters" do
250
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
251
+ ##### Title Text ###
252
+ ---
253
+ <h5>Title Text</h5>
254
+ ---
255
+ end
256
+
257
+ # ATX-style h5 -- both sides, right side with five characters
258
+ it "makes a header out of an ATX-style h5 -- both sides, right side with five characters" do
259
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
260
+ ##### Title Text #####
261
+ ---
262
+ <h5>Title Text</h5>
263
+ ---
264
+ end
265
+
266
+
267
+ # ATX-style h6 -- left side only
268
+ it "makes a header out of an ATX-style h6 -- left side only" do
269
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
270
+ ###### Title Text
271
+ ---
272
+ <h6>Title Text</h6>
273
+ ---
274
+ end
275
+
276
+ # ATX-style h6 -- both sides, right side with one character
277
+ it "makes a header out of an ATX-style h6 -- both sides, right side with one character" do
278
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
279
+ ###### Title Text #
280
+ ---
281
+ <h6>Title Text</h6>
282
+ ---
283
+ end
284
+
285
+ # ATX-style h6 -- both sides, right side with three characters
286
+ it "makes a header out of an ATX-style h6 -- both sides, right side with three characters" do
287
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
288
+ ###### Title Text ###
289
+ ---
290
+ <h6>Title Text</h6>
291
+ ---
292
+ end
293
+
294
+ # ATX-style h6 -- both sides, right side with five characters
295
+ it "makes a header out of an ATX-style h6 -- both sides, right side with five characters" do
296
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
297
+ ###### Title Text #####
298
+ ---
299
+ <h6>Title Text</h6>
300
+ ---
301
+ end
302
+
303
+ end
304
+
305
+
@@ -0,0 +1,250 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ BEGIN {
5
+ require 'pathname'
6
+ basedir = Pathname.new( __FILE__ ).dirname.parent
7
+
8
+ libdir = basedir + 'lib'
9
+ extdir = basedir + 'ext'
10
+
11
+ $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
+ $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
+ }
14
+
15
+ require 'spec'
16
+ require 'bluecloth'
17
+
18
+ require 'spec/lib/helpers'
19
+ require 'spec/lib/constants'
20
+ require 'spec/lib/matchers'
21
+
22
+
23
+ ### Output some debugging if $DEBUG is true
24
+ def debug_msg( *args )
25
+ $stderr.puts( *args ) if $DEBUG
26
+ end
27
+
28
+
29
+
30
+ #####################################################################
31
+ ### C O N T E X T S
32
+ #####################################################################
33
+
34
+ describe BlueCloth do
35
+ include BlueCloth::TestConstants,
36
+ BlueCloth::Matchers
37
+
38
+ it "defines the top-level Markdown constant" do
39
+ Object.const_defined?('Markdown').should be_true()
40
+ # :FIXME: This is probably a fragile test, as anything else that defines it before
41
+ # the BlueCloth tests run could lead to a false failure. I at least know that it'll
42
+ # work in my environment, and I'm not sure how else to test it.
43
+ ::Markdown.should be_equal( ::BlueCloth )
44
+ end
45
+
46
+ it "knows what version of Discount was used to build it" do
47
+ BlueCloth.discount_version.should =~ /^\d+\.\d+\.\d+.*RELAXED/
48
+ end
49
+
50
+ it "can build a flags bitmask out of an options hash" do
51
+ flags = BlueCloth.flags_from_opthash(
52
+ :remove_links => true,
53
+ :header_labels => true,
54
+ :pandoc_headers => false
55
+ )
56
+
57
+ ( flags & BlueCloth::MKD_NOLINKS ).should be_nonzero()
58
+ ( flags & BlueCloth::MKD_TOC ).should be_nonzero()
59
+ ( flags & BlueCloth::MKD_NOHEADER ).should be_nonzero()
60
+ end
61
+
62
+
63
+ it "allows output to be rendered several times" do
64
+ bc = BlueCloth.new( "Some text" )
65
+ bc.to_html.should == bc.to_html
66
+ end
67
+
68
+
69
+ it "correctly applies the :remove_links option to the output" do
70
+ input = "An [example](http://url.com/). A <a href='http://example.com/'>link</a>."
71
+ expected = "<p>An [example](http://url.com/). A &lt;a href='http://example.com/'>link</a>.</p>"
72
+
73
+ the_markdown( input, :remove_links => true ).should be_transformed_into( expected )
74
+ end
75
+
76
+ it "correctly applies the :remove_images option to the output" do
77
+ input = %{An ![alt text](/path/img.jpg "Title"). An <img href='http://example.com/1.jpg' />.}
78
+ expected = %{<p>An ![alt text](/path/img.jpg "Title"). An &lt;img href='http://example.com/1.jpg' />.</p>}
79
+
80
+ the_markdown( input, :remove_images => true ).should be_transformed_into( expected )
81
+ end
82
+
83
+ it "correctly applies the :smartypants option to the output" do
84
+ input = %{He was known to frequent that "other establishment"...}
85
+ expected = %{<p>He was known to frequent that &ldquo;other establishment&rdquo;&hellip;</p>}
86
+
87
+ the_markdown( input, :smartypants => true ).should be_transformed_into( expected )
88
+ end
89
+
90
+ it "correctly applies the :auto_links option to the output" do
91
+ the_indented_markdown( <<-"---", :auto_links => true ).should be_transformed_into(<<-"---").without_indentation
92
+ I wonder how many people have
93
+ http://google.com/ as their home page.
94
+ ---
95
+ <p>I wonder how many people have
96
+ <a href="http://google.com/">http://google.com/</a> as their home page.</p>
97
+ ---
98
+ end
99
+
100
+ it "doesn't form links for protocols it doesn't know about under :safe_links mode" do
101
+ the_indented_markdown( <<-"---", :safe_links => true ).should be_transformed_into(<<-"---").without_indentation
102
+ This is an example
103
+ [of something](javascript:do_something_bad(\\))
104
+ you might want to prevent.
105
+ ---
106
+ <p>This is an example
107
+ [of something](javascript:do_something_bad())
108
+ you might want to prevent.</p>
109
+ ---
110
+ end
111
+
112
+ it "forms links for protocols it doesn't know about when not under :safe_links mode" do
113
+ the_indented_markdown( <<-"---", :safe_links => false ).should be_transformed_into(<<-"---").without_indentation
114
+ This is an example
115
+ [of something](javascript:do_something_benign(\\))
116
+ you might want to allow.
117
+ ---
118
+ <p>This is an example
119
+ <a href="javascript:do_something_benign()">of something</a>
120
+ you might want to allow.</p>
121
+ ---
122
+ end
123
+
124
+
125
+ describe "Discount extensions" do
126
+
127
+ it "correctly applies the :pandoc_headers option" do
128
+ input = "% title\n% author1, author2\n% date\n\nStuff."
129
+
130
+ bc = BlueCloth.new( input, :pandoc_headers => true )
131
+ bc.header.should == {
132
+ :title => 'title',
133
+ :author => 'author1, author2',
134
+ :date => 'date'
135
+ }
136
+ bc.to_html.should == '<p>Stuff.</p>'
137
+ end
138
+
139
+ it "correctly expands id: links when :pseudoprotocols are enabled" do
140
+ input = "It was [just as he said](id:foo) it would be."
141
+ expected = %{<p>It was <a id="foo">just as he said</a> it would be.</p>}
142
+
143
+ the_markdown( input, :pseudoprotocols => true ).should be_transformed_into( expected )
144
+ end
145
+
146
+ it "correctly expands class: links when :pseudoprotocols are enabled" do
147
+ input = "It was [just as he said](class:foo) it would be."
148
+ expected = %{<p>It was <span class="foo">just as he said</span> it would be.</p>}
149
+
150
+ the_markdown( input, :pseudoprotocols => true ).should be_transformed_into( expected )
151
+ end
152
+
153
+ it "correctly expands raw: links when :pseudoprotocols are enabled" do
154
+ input = %{I have node idea [what this is for](raw:really "but") it's here.}
155
+ expected = %{<p>I have node idea really it's here.</p>}
156
+
157
+ the_markdown( input, :pseudoprotocols => true ).should be_transformed_into( expected )
158
+ end
159
+
160
+ it "correctly adds IDs to headers when :header_labels is enabled" do
161
+ input = %{# A header\n\nSome stuff\n\n## Another header\n\nMore stuff.\n\n}
162
+ expected = %{<h1 id=\"A+header\">A header</h1>\n\n<p>Some stuff</p>\n\n} +
163
+ %{<h2 id=\"Another+header\">Another header</h2>\n\n<p>More stuff.</p>}
164
+
165
+ the_markdown( input, :header_labels => true ).should be_transformed_into( expected )
166
+ end
167
+
168
+ it "expands superscripts when :strict_mode is disabled" do
169
+ input = %{It used to be that E = mc^2 used to be the province of physicists.}
170
+ expected = %{<p>It used to be that E = mc<sup>2</sup> used to be the province} +
171
+ %{ of physicists.</p>}
172
+ strict = %{<p>It used to be that E = mc^2 used to be the province} +
173
+ %{ of physicists.</p>}
174
+
175
+ the_markdown( input, :strict_mode => false ).should be_transformed_into( expected )
176
+ the_markdown( input, :strict_mode => true ).should be_transformed_into( strict )
177
+ end
178
+
179
+ it "uses relaxed emphasis when :strict_mode is disabled" do
180
+ input = %{If you use size_t instead, you _won't_ have to worry as much about portability.}
181
+ expected = %{<p>If you use size_t instead, you <em>won't</em> have to worry as much about portability.</p>}
182
+ strict = %{<p>If you use size<em>t instead, you </em>won't_ have to worry as much about portability.</p>}
183
+
184
+ the_markdown( input, :strict_mode => false ).should be_transformed_into( expected )
185
+ the_markdown( input, :strict_mode => true ).should be_transformed_into( strict )
186
+ end
187
+
188
+ end
189
+
190
+ ### Test email address output
191
+ describe " email obfuscation" do
192
+ TESTING_EMAILS = %w[
193
+ address@example.com
194
+ foo-list-admin@bar.com
195
+ fu@bar.COM
196
+ baz@ruby-lang.org
197
+ foo-tim-bazzle@bar-hop.co.uk
198
+ littlestar@twinkle.twinkle.band.CO.ZA
199
+ ll@lll.lllll.ll
200
+ Ull@Ulll.Ulllll.ll
201
+ UUUU1@UU1.UU1UUU.UU
202
+ l@ll.ll
203
+ Ull.Ullll@llll.ll
204
+ Ulll-Ull.Ulllll@ll.ll
205
+ 1@111.ll
206
+ ]
207
+ # I can't see a way to handle IDNs clearly yet, so these will have to wait.
208
+ # info@öko.de
209
+ # jemand@büro.de
210
+ # irgendwo-interreßant@dÅgta.se
211
+ #]
212
+
213
+ def decode( str )
214
+ str.gsub( /&#(x[a-f0-9]+|\d{1,3});/i ) do |match|
215
+ code = $1
216
+ debug_msg "Decoding &##{code};"
217
+
218
+ case code
219
+ when /^x([a-f0-9]+)/i
220
+ debug_msg "-> #{$1.to_i(16).chr}"
221
+ $1.to_i(16).chr
222
+ when /^\d+$/
223
+ debug_msg "-> #{code.to_i.chr}"
224
+ code.to_i.chr
225
+ else
226
+ raise "Hmmm... malformed entity %p" % code
227
+ end
228
+ end
229
+ end
230
+
231
+ TESTING_EMAILS.each do |addr|
232
+ it( "obfuscates the email address %p" % addr ) do
233
+ html = BlueCloth.new( "<#{addr}>" ).to_html
234
+
235
+ expected_output = %r{<p><a href="([^"]+)">[^<]+</a></p>}
236
+ match = expected_output.match( html )
237
+ match.should be_an_instance_of( MatchData )
238
+
239
+ match[1].should_not == addr
240
+
241
+ decoded_href = decode( match[1] )
242
+ debug_msg "Unencoded href = %p" % [ decoded_href ]
243
+ decoded_href.should == "mailto:#{addr}"
244
+ end
245
+ end
246
+ end
247
+
248
+ end
249
+
250
+ # vim: set nosta noet ts=4 sw=4: