jekyll-reloaded 0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/Gemfile +2 -0
  2. data/History.txt +321 -0
  3. data/LICENSE +21 -0
  4. data/README.textile +41 -0
  5. data/Rakefile +161 -0
  6. data/bin/jekyll +289 -0
  7. data/cucumber.yml +1 -0
  8. data/features/create_sites.feature +112 -0
  9. data/features/embed_filters.feature +60 -0
  10. data/features/markdown.feature +30 -0
  11. data/features/pagination.feature +27 -0
  12. data/features/permalinks.feature +65 -0
  13. data/features/post_data.feature +153 -0
  14. data/features/site_configuration.feature +145 -0
  15. data/features/site_data.feature +82 -0
  16. data/features/step_definitions/jekyll_steps.rb +145 -0
  17. data/features/support/env.rb +19 -0
  18. data/jekyll.gemspec +146 -0
  19. data/lib/guard/jekyll.rb +57 -0
  20. data/lib/jekyll/converter.rb +50 -0
  21. data/lib/jekyll/converters/identity.rb +22 -0
  22. data/lib/jekyll/converters/markdown.rb +125 -0
  23. data/lib/jekyll/converters/textile.rb +50 -0
  24. data/lib/jekyll/convertible.rb +116 -0
  25. data/lib/jekyll/core_ext.rb +52 -0
  26. data/lib/jekyll/errors.rb +6 -0
  27. data/lib/jekyll/filters.rb +118 -0
  28. data/lib/jekyll/generator.rb +7 -0
  29. data/lib/jekyll/generators/pagination.rb +113 -0
  30. data/lib/jekyll/layout.rb +51 -0
  31. data/lib/jekyll/live_site.rb +216 -0
  32. data/lib/jekyll/migrators/csv.rb +26 -0
  33. data/lib/jekyll/migrators/drupal.rb +103 -0
  34. data/lib/jekyll/migrators/enki.rb +49 -0
  35. data/lib/jekyll/migrators/joomla.rb +53 -0
  36. data/lib/jekyll/migrators/marley.rb +52 -0
  37. data/lib/jekyll/migrators/mephisto.rb +84 -0
  38. data/lib/jekyll/migrators/mt.rb +86 -0
  39. data/lib/jekyll/migrators/posterous.rb +67 -0
  40. data/lib/jekyll/migrators/rss.rb +47 -0
  41. data/lib/jekyll/migrators/textpattern.rb +58 -0
  42. data/lib/jekyll/migrators/tumblr.rb +195 -0
  43. data/lib/jekyll/migrators/typo.rb +51 -0
  44. data/lib/jekyll/migrators/wordpress.rb +294 -0
  45. data/lib/jekyll/migrators/wordpressdotcom.rb +70 -0
  46. data/lib/jekyll/page.rb +160 -0
  47. data/lib/jekyll/plugin.rb +77 -0
  48. data/lib/jekyll/post.rb +262 -0
  49. data/lib/jekyll/site.rb +339 -0
  50. data/lib/jekyll/static_file.rb +77 -0
  51. data/lib/jekyll/tags/highlight.rb +118 -0
  52. data/lib/jekyll/tags/include.rb +37 -0
  53. data/lib/jekyll/tags/post_url.rb +38 -0
  54. data/lib/jekyll.rb +134 -0
  55. data/test/helper.rb +34 -0
  56. data/test/source/.htaccess +8 -0
  57. data/test/source/_includes/sig.markdown +3 -0
  58. data/test/source/_layouts/default.html +27 -0
  59. data/test/source/_layouts/simple.html +1 -0
  60. data/test/source/_posts/2008-02-02-not-published.textile +8 -0
  61. data/test/source/_posts/2008-02-02-published.textile +8 -0
  62. data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
  63. data/test/source/_posts/2008-11-21-complex.textile +8 -0
  64. data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
  65. data/test/source/_posts/2008-12-13-include.markdown +8 -0
  66. data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
  67. data/test/source/_posts/2009-01-27-categories.textile +7 -0
  68. data/test/source/_posts/2009-01-27-category.textile +7 -0
  69. data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
  70. data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
  71. data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
  72. data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
  73. data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
  74. data/test/source/_posts/2009-05-18-tag.textile +6 -0
  75. data/test/source/_posts/2009-05-18-tags.textile +9 -0
  76. data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
  77. data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
  78. data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
  79. data/test/source/_posts/2010-01-09-date-override.textile +7 -0
  80. data/test/source/_posts/2010-01-09-time-override.textile +7 -0
  81. data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
  82. data/test/source/_posts/2010-01-16-override-data.textile +4 -0
  83. data/test/source/_posts/2011-04-12-md-extension.md +7 -0
  84. data/test/source/_posts/2011-04-12-text-extension.text +0 -0
  85. data/test/source/about.html +6 -0
  86. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  87. data/test/source/contacts.html +5 -0
  88. data/test/source/css/screen.css +76 -0
  89. data/test/source/deal.with.dots.html +7 -0
  90. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  91. data/test/source/index.html +22 -0
  92. data/test/source/sitemap.xml +32 -0
  93. data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
  94. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  95. data/test/suite.rb +11 -0
  96. data/test/test_configuration.rb +29 -0
  97. data/test/test_core_ext.rb +66 -0
  98. data/test/test_filters.rb +62 -0
  99. data/test/test_generated_site.rb +72 -0
  100. data/test/test_kramdown.rb +23 -0
  101. data/test/test_page.rb +117 -0
  102. data/test/test_pager.rb +113 -0
  103. data/test/test_post.rb +450 -0
  104. data/test/test_rdiscount.rb +18 -0
  105. data/test/test_redcarpet.rb +21 -0
  106. data/test/test_redcloth.rb +86 -0
  107. data/test/test_site.rb +220 -0
  108. data/test/test_tags.rb +201 -0
  109. metadata +332 -0
data/test/test_post.rb ADDED
@@ -0,0 +1,450 @@
1
+ require 'helper'
2
+
3
+ class TestPost < Test::Unit::TestCase
4
+ def setup_post(file)
5
+ Post.new(@site, source_dir, '', file)
6
+ end
7
+
8
+ def do_render(post)
9
+ layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")}
10
+ post.render(layouts, {"site" => {"posts" => []}})
11
+ end
12
+
13
+ context "A Post" do
14
+ setup do
15
+ clear_dest
16
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
17
+ @site = Site.new(Jekyll.configuration)
18
+ end
19
+
20
+ should "ensure valid posts are valid" do
21
+ assert Post.valid?("2008-09-09-foo-bar.textile")
22
+ assert Post.valid?("foo/bar/2008-09-09-foo-bar.textile")
23
+
24
+ assert !Post.valid?("lol2008-09-09-foo-bar.textile")
25
+ assert !Post.valid?("blah")
26
+ end
27
+
28
+ context "processing posts" do
29
+ setup do
30
+ @post = Post.allocate
31
+ @post.site = @site
32
+ @post.categories = []
33
+
34
+ @real_file = "2008-10-18-foo-bar.textile"
35
+ @fake_file = "2008-09-09-foo-bar.textile"
36
+ @source = source_dir('_posts')
37
+ end
38
+
39
+ should "keep date, title, and markup type" do
40
+ @post.process(@fake_file)
41
+
42
+ assert_equal Time.parse("2008-09-09"), @post.date
43
+ assert_equal "foo-bar", @post.slug
44
+ assert_equal ".textile", @post.ext
45
+ assert_equal "/2008/09/09", @post.dir
46
+ assert_equal "/2008/09/09/foo-bar", @post.id
47
+ end
48
+
49
+ should "create url based on date and title" do
50
+ @post.process(@fake_file)
51
+ assert_equal "/2008/09/09/foo-bar.html", @post.url
52
+ end
53
+
54
+ should "raise a good error on invalid post date" do
55
+ assert_raise Jekyll::FatalException do
56
+ @post.process("2009-27-03-foo-bar.textile")
57
+ end
58
+ end
59
+
60
+ should "CGI escape urls" do
61
+ @post.process("2009-03-12-hash-#1.markdown")
62
+ assert_equal "/2009/03/12/hash-%231.html", @post.url
63
+ assert_equal "/2009/03/12/hash-#1", @post.id
64
+ end
65
+
66
+ should "respect permalink in yaml front matter" do
67
+ file = "2008-12-03-permalinked-post.textile"
68
+ @post.process(file)
69
+ @post.read_yaml(@source, file)
70
+
71
+ assert_equal "my_category/permalinked-post", @post.permalink
72
+ assert_equal "my_category", @post.dir
73
+ assert_equal "my_category/permalinked-post", @post.url
74
+ end
75
+
76
+ context "with CRLF linebreaks" do
77
+ setup do
78
+ @real_file = "2009-05-24-yaml-linebreak.markdown"
79
+ @source = source_dir('win/_posts')
80
+ end
81
+ should "read yaml front-matter" do
82
+ @post.read_yaml(@source, @real_file)
83
+
84
+ assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data)
85
+ assert_equal "This is the content", @post.content
86
+ end
87
+ end
88
+
89
+ context "with embedded triple dash" do
90
+ setup do
91
+ @real_file = "2010-01-08-triple-dash.markdown"
92
+ end
93
+ should "consume the embedded dashes" do
94
+ @post.read_yaml(@source, @real_file)
95
+
96
+ assert_equal({"title" => "Foo --- Bar"}, @post.data)
97
+ assert_equal "Triple the fun!", @post.content
98
+ end
99
+ end
100
+
101
+ context "with site wide permalink" do
102
+ context "with unspecified (date) style" do
103
+ setup do
104
+ @post.process(@fake_file)
105
+ end
106
+
107
+ should "process the url correctly" do
108
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
109
+ assert_equal "/2008/09/09/foo-bar.html", @post.url
110
+ end
111
+ end
112
+
113
+ context "with unspecified (date) style and a category" do
114
+ setup do
115
+ @post.categories << "beer"
116
+ @post.process(@fake_file)
117
+ end
118
+
119
+ should "process the url correctly" do
120
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
121
+ assert_equal "/beer/2008/09/09/foo-bar.html", @post.url
122
+ end
123
+ end
124
+
125
+ context "with unspecified (date) style and categories" do
126
+ setup do
127
+ @post.categories << "food"
128
+ @post.categories << "beer"
129
+ @post.process(@fake_file)
130
+ end
131
+
132
+ should "process the url correctly" do
133
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
134
+ assert_equal "/food/beer/2008/09/09/foo-bar.html", @post.url
135
+ end
136
+ end
137
+
138
+ context "with space (categories)" do
139
+ setup do
140
+ @post.categories << "French cuisine"
141
+ @post.categories << "Belgian beer"
142
+ @post.process(@fake_file)
143
+ end
144
+
145
+ should "process the url correctly" do
146
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
147
+ assert_equal "/French%20cuisine/Belgian%20beer/2008/09/09/foo-bar.html", @post.url
148
+ end
149
+ end
150
+
151
+ context "with none style" do
152
+ setup do
153
+ @post.site.permalink_style = :none
154
+ @post.process(@fake_file)
155
+ end
156
+
157
+ should "process the url correctly" do
158
+ assert_equal "/:categories/:title.html", @post.template
159
+ assert_equal "/foo-bar.html", @post.url
160
+ end
161
+ end
162
+
163
+ context "with pretty style" do
164
+ setup do
165
+ @post.site.permalink_style = :pretty
166
+ @post.process(@fake_file)
167
+ end
168
+
169
+ should "process the url correctly" do
170
+ assert_equal "/:categories/:year/:month/:day/:title/", @post.template
171
+ assert_equal "/2008/09/09/foo-bar/", @post.url
172
+ end
173
+ end
174
+
175
+ context "with custom date permalink" do
176
+ setup do
177
+ @post.site.permalink_style = '/:categories/:year/:i_month/:i_day/:title/'
178
+ @post.process(@fake_file)
179
+ end
180
+
181
+ should "process the url correctly" do
182
+ assert_equal "/2008/9/9/foo-bar/", @post.url
183
+ end
184
+ end
185
+
186
+ context "with prefix style and no extension" do
187
+ setup do
188
+ @post.site.permalink_style = "/prefix/:title"
189
+ @post.process(@fake_file)
190
+ end
191
+
192
+ should "process the url correctly" do
193
+ assert_equal "/prefix/:title", @post.template
194
+ assert_equal "/prefix/foo-bar", @post.url
195
+ end
196
+ end
197
+ end
198
+
199
+ should "read yaml front-matter" do
200
+ @post.read_yaml(@source, @real_file)
201
+
202
+ assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
203
+ assert_equal "h1. {{ page.title }}\n\nBest *post* ever", @post.content
204
+ end
205
+
206
+ should "transform textile" do
207
+ @post.process(@real_file)
208
+ @post.read_yaml(@source, @real_file)
209
+ @post.transform
210
+
211
+ assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
212
+ end
213
+ end
214
+
215
+ context "when in a site" do
216
+ setup do
217
+ clear_dest
218
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
219
+ @site = Site.new(Jekyll.configuration)
220
+ @site.posts = [setup_post('2008-02-02-published.textile'),
221
+ setup_post('2009-01-27-categories.textile')]
222
+ end
223
+
224
+ should "have next post" do
225
+ assert_equal(@site.posts.last, @site.posts.first.next)
226
+ end
227
+
228
+ should "have previous post" do
229
+ assert_equal(@site.posts.first, @site.posts.last.previous)
230
+ end
231
+
232
+ should "not have previous post if first" do
233
+ assert_equal(nil, @site.posts.first.previous)
234
+ end
235
+
236
+ should "not have next post if last" do
237
+ assert_equal(nil, @site.posts.last.next)
238
+ end
239
+ end
240
+
241
+ context "initializing posts" do
242
+ should "publish when published yaml is no specified" do
243
+ post = setup_post("2008-02-02-published.textile")
244
+ assert_equal true, post.published
245
+ end
246
+
247
+ should "not published when published yaml is false" do
248
+ post = setup_post("2008-02-02-not-published.textile")
249
+ assert_equal false, post.published
250
+ end
251
+
252
+ should "recognize date in yaml" do
253
+ post = setup_post("2010-01-09-date-override.textile")
254
+ do_render(post)
255
+ assert_equal Time, post.date.class
256
+ assert_equal Time, post.to_liquid["date"].class
257
+ assert_equal "/2010/01/10/date-override.html", post.url
258
+ assert_equal "<p>Post with a front matter date</p>\n<p>10 Jan 2010</p>", post.output
259
+ end
260
+
261
+ should "recognize time in yaml" do
262
+ post = setup_post("2010-01-09-time-override.textile")
263
+ do_render(post)
264
+ assert_equal Time, post.date.class
265
+ assert_equal Time, post.to_liquid["date"].class
266
+ assert_equal "/2010/01/10/time-override.html", post.url
267
+ assert_equal "<p>Post with a front matter time</p>\n<p>10 Jan 2010</p>", post.output
268
+ end
269
+
270
+ should "recognize time with timezone in yaml" do
271
+ post = setup_post("2010-01-09-timezone-override.textile")
272
+ do_render(post)
273
+ assert_equal Time, post.date.class
274
+ assert_equal Time, post.to_liquid["date"].class
275
+ assert_equal "/2010/01/10/timezone-override.html", post.url
276
+ assert_equal "<p>Post with a front matter time with timezone</p>\n<p>10 Jan 2010</p>", post.output
277
+ end
278
+
279
+ should "to_liquid prioritizes post attributes over data" do
280
+ post = setup_post("2010-01-16-override-data.textile")
281
+ assert_equal Array, post.tags.class
282
+ assert_equal Array, post.to_liquid["tags"].class
283
+ assert_equal Time, post.date.class
284
+ assert_equal Time, post.to_liquid["date"].class
285
+ end
286
+
287
+ should "recognize category in yaml" do
288
+ post = setup_post("2009-01-27-category.textile")
289
+ assert post.categories.include?('foo')
290
+ end
291
+
292
+ should "recognize several categories in yaml" do
293
+ post = setup_post("2009-01-27-categories.textile")
294
+ assert post.categories.include?('foo')
295
+ assert post.categories.include?('bar')
296
+ assert post.categories.include?('baz')
297
+ end
298
+
299
+ should "recognize empty category in yaml" do
300
+ post = setup_post("2009-01-27-empty-category.textile")
301
+ assert_equal [], post.categories
302
+ end
303
+
304
+ should "recognize empty categories in yaml" do
305
+ post = setup_post("2009-01-27-empty-categories.textile")
306
+ assert_equal [], post.categories
307
+ end
308
+
309
+ should "recognize tag in yaml" do
310
+ post = setup_post("2009-05-18-tag.textile")
311
+ assert post.tags.include?('code')
312
+ end
313
+
314
+ should "recognize tags in yaml" do
315
+ post = setup_post("2009-05-18-tags.textile")
316
+ assert post.tags.include?('food')
317
+ assert post.tags.include?('cooking')
318
+ assert post.tags.include?('pizza')
319
+ end
320
+
321
+ should "recognize empty tag in yaml" do
322
+ post = setup_post("2009-05-18-empty-tag.textile")
323
+ assert_equal [], post.tags
324
+ end
325
+
326
+ should "recognize empty tags in yaml" do
327
+ post = setup_post("2009-05-18-empty-tags.textile")
328
+ assert_equal [], post.tags
329
+ end
330
+
331
+ should "allow no yaml" do
332
+ post = setup_post("2009-06-22-no-yaml.textile")
333
+ assert_equal "No YAML.", post.content
334
+ end
335
+
336
+ should "allow empty yaml" do
337
+ post = setup_post("2009-06-22-empty-yaml.textile")
338
+ assert_equal "Empty YAML.", post.content
339
+ end
340
+
341
+ context "rendering" do
342
+ setup do
343
+ clear_dest
344
+ end
345
+
346
+ should "render properly" do
347
+ post = setup_post("2008-10-18-foo-bar.textile")
348
+ do_render(post)
349
+ assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
350
+ end
351
+
352
+ should "write properly" do
353
+ post = setup_post("2008-10-18-foo-bar.textile")
354
+ do_render(post)
355
+ post.write(dest_dir)
356
+
357
+ assert File.directory?(dest_dir)
358
+ assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
359
+ end
360
+
361
+ should "write properly without html extension" do
362
+ post = setup_post("2008-10-18-foo-bar.textile")
363
+ post.site.permalink_style = ":title"
364
+ do_render(post)
365
+ post.write(dest_dir)
366
+
367
+ assert File.directory?(dest_dir)
368
+ assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
369
+ end
370
+
371
+ should "insert data" do
372
+ post = setup_post("2008-11-21-complex.textile")
373
+ do_render(post)
374
+
375
+ assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: #{Time.parse("2008-11-21")}<br />\nid: /2008/11/21/complex</p> >>>", post.output
376
+ end
377
+
378
+ should "include templates" do
379
+ post = setup_post("2008-12-13-include.markdown")
380
+ post.site.source = File.join(File.dirname(__FILE__), 'source')
381
+ do_render(post)
382
+
383
+ assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
384
+ end
385
+
386
+ should "render date specified in front matter properly" do
387
+ post = setup_post("2010-01-09-date-override.textile")
388
+ do_render(post)
389
+
390
+ assert_equal "<p>Post with a front matter date</p>\n<p>10 Jan 2010</p>", post.output
391
+ end
392
+
393
+ should "render time specified in front matter properly" do
394
+ post = setup_post("2010-01-09-time-override.textile")
395
+ do_render(post)
396
+
397
+ assert_equal "<p>Post with a front matter time</p>\n<p>10 Jan 2010</p>", post.output
398
+ end
399
+
400
+ end
401
+ end
402
+
403
+ should "generate categories and topics" do
404
+ post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
405
+ assert_equal ['foo'], post.categories
406
+ end
407
+ end
408
+
409
+ context "converter file extension settings" do
410
+ setup do
411
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
412
+ @site = Site.new(Jekyll.configuration)
413
+ end
414
+
415
+ should "process .md as markdown under default configuration" do
416
+ post = setup_post '2011-04-12-md-extension.md'
417
+ conv = post.converter
418
+ assert conv.kind_of? Jekyll::MarkdownConverter
419
+ end
420
+
421
+ should "process .text as indentity under default configuration" do
422
+ post = setup_post '2011-04-12-text-extension.text'
423
+ conv = post.converter
424
+ assert conv.kind_of? Jekyll::IdentityConverter
425
+ end
426
+
427
+ should "process .text as markdown under alternate configuration" do
428
+ @site.config['markdown_ext'] = 'markdown,mdw,mdwn,md,text'
429
+ post = setup_post '2011-04-12-text-extension.text'
430
+ conv = post.converter
431
+ assert conv.kind_of? Jekyll::MarkdownConverter
432
+ end
433
+
434
+ should "process .md as markdown under alternate configuration" do
435
+ @site.config['markdown_ext'] = 'markdown,mkd,mkdn,md,text'
436
+ post = setup_post '2011-04-12-text-extension.text'
437
+ conv = post.converter
438
+ assert conv.kind_of? Jekyll::MarkdownConverter
439
+ end
440
+
441
+ should "process .text as textile under alternate configuration" do
442
+ @site.config['textile_ext'] = 'textile,text'
443
+ post = setup_post '2011-04-12-text-extension.text'
444
+ conv = post.converter
445
+ assert conv.kind_of? Jekyll::TextileConverter
446
+ end
447
+
448
+ end
449
+
450
+ end
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ class TestRdiscount < Test::Unit::TestCase
4
+
5
+ context "rdiscount" do
6
+ setup do
7
+ config = {
8
+ 'rdiscount' => { 'extensions' => ['smart'] },
9
+ 'markdown' => 'rdiscount'
10
+ }
11
+ @markdown = MarkdownConverter.new config
12
+ end
13
+
14
+ should "pass rdiscount extensions" do
15
+ assert_equal "<p>&ldquo;smart&rdquo;</p>", @markdown.convert('"smart"').strip
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestRedcarpet < Test::Unit::TestCase
4
+ context "redcarpet" do
5
+ setup do
6
+ config = {
7
+ 'redcarpet' => { 'extensions' => ['smart'] },
8
+ 'markdown' => 'redcarpet'
9
+ }
10
+ @markdown = MarkdownConverter.new config
11
+ end
12
+
13
+ should "pass redcarpet options" do
14
+ assert_equal "<h1>Some Header</h1>", @markdown.convert('# Some Header #').strip
15
+ end
16
+
17
+ should "pass redcarpet extensions" do
18
+ assert_equal "<p>&ldquo;smart&rdquo;</p>", @markdown.convert('"smart"').strip
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,86 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestRedCloth < Test::Unit::TestCase
4
+
5
+ context "RedCloth default (no explicit config) hard_breaks enabled" do
6
+ setup do
7
+ @textile = TextileConverter.new
8
+ end
9
+
10
+ should "preserve single line breaks in HTML output" do
11
+ assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
12
+ end
13
+ end
14
+
15
+ context "Default hard_breaks enabled w/ redcloth section, no hard_breaks value" do
16
+ setup do
17
+ config = {
18
+ 'redcloth' => {}
19
+ }
20
+ @textile = TextileConverter.new config
21
+ end
22
+
23
+ should "preserve single line breaks in HTML output" do
24
+ assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
25
+ end
26
+ end
27
+
28
+ context "RedCloth with hard_breaks enabled" do
29
+ setup do
30
+ config = {
31
+ 'redcloth' => {
32
+ 'hard_breaks' => true # default
33
+ }
34
+ }
35
+ @textile = TextileConverter.new config
36
+ end
37
+
38
+ should "preserve single line breaks in HTML output" do
39
+ assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
40
+ end
41
+ end
42
+
43
+ context "RedCloth with hard_breaks disabled" do
44
+ setup do
45
+ config = {
46
+ 'redcloth' => {
47
+ 'hard_breaks' => false
48
+ }
49
+ }
50
+ @textile = TextileConverter.new config
51
+ end
52
+
53
+ should "not generate break tags in HTML output" do
54
+ assert_equal "<p>line1\nline2</p>", @textile.convert("p. line1\nline2").strip
55
+ end
56
+ end
57
+
58
+ context "RedCloth w/no_span_caps set to false" do
59
+ setup do
60
+ config = {
61
+ 'redcloth' => {
62
+ 'no_span_caps' => false
63
+ }
64
+ }
65
+ @textile = TextileConverter.new config
66
+ end
67
+ should "generate span tags around capitalized words" do
68
+ assert_equal "<p><span class=\"caps\">NSC</span></p>", @textile.convert("NSC").strip
69
+ end
70
+ end
71
+
72
+ context "RedCloth w/no_span_caps set to true" do
73
+ setup do
74
+ config = {
75
+ 'redcloth' => {
76
+ 'no_span_caps' => true
77
+ }
78
+ }
79
+ @textile = TextileConverter.new config
80
+ end
81
+
82
+ should "not generate span tags around capitalized words" do
83
+ assert_equal "<p>NSC</p>", @textile.convert("NSC").strip
84
+ end
85
+ end
86
+ end