indirect-jekyll 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/History.txt +151 -0
- data/README.textile +42 -0
- data/Rakefile +90 -0
- data/VERSION.yml +4 -0
- data/bin/jekyll +150 -0
- data/features/create_sites.feature +46 -0
- data/features/embed_filters.feature +60 -0
- data/features/pagination.feature +40 -0
- data/features/permalinks.feature +65 -0
- data/features/post_data.feature +153 -0
- data/features/site_configuration.feature +63 -0
- data/features/site_data.feature +82 -0
- data/features/step_definitions/jekyll_steps.rb +136 -0
- data/features/support/env.rb +16 -0
- data/indirect-jekyll.gemspec +139 -0
- data/jekyll.gemspec +135 -0
- data/lib/jekyll.rb +85 -0
- data/lib/jekyll/albino.rb +122 -0
- data/lib/jekyll/converters/csv.rb +26 -0
- data/lib/jekyll/converters/mephisto.rb +79 -0
- data/lib/jekyll/converters/mt.rb +59 -0
- data/lib/jekyll/converters/textpattern.rb +50 -0
- data/lib/jekyll/converters/typo.rb +49 -0
- data/lib/jekyll/converters/wordpress.rb +54 -0
- data/lib/jekyll/convertible.rb +84 -0
- data/lib/jekyll/core_ext.rb +30 -0
- data/lib/jekyll/filters.rb +47 -0
- data/lib/jekyll/layout.rb +36 -0
- data/lib/jekyll/page.rb +112 -0
- data/lib/jekyll/pager.rb +45 -0
- data/lib/jekyll/post.rb +268 -0
- data/lib/jekyll/site.rb +265 -0
- data/lib/jekyll/tags/highlight.rb +56 -0
- data/lib/jekyll/tags/include.rb +31 -0
- data/test/helper.rb +27 -0
- data/test/source/_includes/sig.markdown +3 -0
- data/test/source/_layouts/default.html +27 -0
- data/test/source/_layouts/simple.html +1 -0
- data/test/source/_posts/2008-02-02-not-published.textile +8 -0
- data/test/source/_posts/2008-02-02-published.textile +8 -0
- data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
- data/test/source/_posts/2008-11-21-complex.textile +8 -0
- data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
- data/test/source/_posts/2008-12-13-include.markdown +8 -0
- data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
- data/test/source/_posts/2009-01-27-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-category.textile +7 -0
- data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
- data/test/source/_posts/2009-05-18-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-tags.textile +9 -0
- data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
- data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
- data/test/source/about.html +6 -0
- data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
- data/test/source/contacts.html +5 -0
- data/test/source/css/screen.css +76 -0
- data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
- data/test/source/index.html +22 -0
- data/test/source/sitemap.xml +23 -0
- data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
- data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
- data/test/suite.rb +9 -0
- data/test/test_configuration.rb +29 -0
- data/test/test_filters.rb +49 -0
- data/test/test_generated_site.rb +40 -0
- data/test/test_page.rb +98 -0
- data/test/test_pager.rb +47 -0
- data/test/test_post.rb +302 -0
- data/test/test_site.rb +85 -0
- data/test/test_tags.rb +116 -0
- metadata +194 -0
data/test/test_pager.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TestPager < Test::Unit::TestCase
|
4
|
+
context "pagination enabled" do
|
5
|
+
setup do
|
6
|
+
stub(Jekyll).configuration do
|
7
|
+
Jekyll::DEFAULTS.merge({
|
8
|
+
'source' => source_dir,
|
9
|
+
'destination' => dest_dir,
|
10
|
+
'paginate' => 2
|
11
|
+
})
|
12
|
+
end
|
13
|
+
|
14
|
+
@config = Jekyll.configuration
|
15
|
+
@site = Site.new(@config)
|
16
|
+
@posts = @site.read_posts('')
|
17
|
+
end
|
18
|
+
|
19
|
+
should "calculate number of pages" do
|
20
|
+
assert_equal(2, Pager.calculate_pages(@posts, @config['paginate']))
|
21
|
+
end
|
22
|
+
|
23
|
+
should "create first pager" do
|
24
|
+
pager = Pager.new(@config, 1, @posts)
|
25
|
+
assert_equal(@config['paginate'].to_i, pager.posts.size)
|
26
|
+
assert_equal(2, pager.total_pages)
|
27
|
+
assert_nil(pager.previous_page)
|
28
|
+
assert_equal(2, pager.next_page)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "create second pager" do
|
32
|
+
pager = Pager.new(@config, 2, @posts)
|
33
|
+
assert_equal(@posts.size - @config['paginate'].to_i, pager.posts.size)
|
34
|
+
assert_equal(2, pager.total_pages)
|
35
|
+
assert_equal(1, pager.previous_page)
|
36
|
+
assert_nil(pager.next_page)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "not create third pager" do
|
40
|
+
assert_raise(RuntimeError) { Pager.new(@config, 3, @posts) }
|
41
|
+
end
|
42
|
+
|
43
|
+
should "report that pagination is enabled" do
|
44
|
+
assert Pager.pagination_enabled?(@config, 'index.html')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/test/test_post.rb
ADDED
@@ -0,0 +1,302 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/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-10-19-foo-bar.textile")
|
22
|
+
assert Post.valid?("foo/bar/2008-10-19-foo-bar.textile")
|
23
|
+
|
24
|
+
assert !Post.valid?("lol2008-10-19-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
|
+
|
33
|
+
@real_file = "2008-10-18-foo-bar.textile"
|
34
|
+
@fake_file = "2008-10-19-foo-bar.textile"
|
35
|
+
@source = source_dir('_posts')
|
36
|
+
end
|
37
|
+
|
38
|
+
should "keep date, title, and markup type" do
|
39
|
+
@post.process(@fake_file)
|
40
|
+
|
41
|
+
assert_equal Time.parse("2008-10-19"), @post.date
|
42
|
+
assert_equal "foo-bar", @post.slug
|
43
|
+
assert_equal ".textile", @post.ext
|
44
|
+
assert_equal "/2008/10/19", @post.dir
|
45
|
+
assert_equal "/2008/10/19/foo-bar", @post.id
|
46
|
+
end
|
47
|
+
|
48
|
+
should "create url based on date and title" do
|
49
|
+
@post.categories = []
|
50
|
+
@post.process(@fake_file)
|
51
|
+
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
52
|
+
end
|
53
|
+
|
54
|
+
should "CGI escape urls" do
|
55
|
+
@post.categories = []
|
56
|
+
@post.process("2009-03-12-hash-#1.markdown")
|
57
|
+
assert_equal "/2009/03/12/hash-%231.html", @post.url
|
58
|
+
assert_equal "/2009/03/12/hash-#1", @post.id
|
59
|
+
end
|
60
|
+
|
61
|
+
should "respect permalink in yaml front matter" do
|
62
|
+
file = "2008-12-03-permalinked-post.textile"
|
63
|
+
@post.process(file)
|
64
|
+
@post.read_yaml(@source, file)
|
65
|
+
|
66
|
+
assert_equal "my_category/permalinked-post", @post.permalink
|
67
|
+
assert_equal "my_category", @post.dir
|
68
|
+
assert_equal "my_category/permalinked-post", @post.url
|
69
|
+
end
|
70
|
+
|
71
|
+
context "with CRLF linebreaks" do
|
72
|
+
setup do
|
73
|
+
@real_file = "2009-05-24-yaml-linebreak.markdown"
|
74
|
+
@source = source_dir('win/_posts')
|
75
|
+
end
|
76
|
+
should "read yaml front-matter" do
|
77
|
+
@post.read_yaml(@source, @real_file)
|
78
|
+
|
79
|
+
assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data)
|
80
|
+
assert_equal "\r\nThis is the content", @post.content
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "with site wide permalink" do
|
85
|
+
setup do
|
86
|
+
@post.categories = []
|
87
|
+
end
|
88
|
+
|
89
|
+
context "with unspecified (date) style" do
|
90
|
+
setup do
|
91
|
+
@post.process(@fake_file)
|
92
|
+
end
|
93
|
+
|
94
|
+
should "process the url correctly" do
|
95
|
+
assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
|
96
|
+
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "with unspecified (date) style and a category" do
|
101
|
+
setup do
|
102
|
+
@post.categories << "beer"
|
103
|
+
@post.process(@fake_file)
|
104
|
+
end
|
105
|
+
|
106
|
+
should "process the url correctly" do
|
107
|
+
assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
|
108
|
+
assert_equal "/beer/2008/10/19/foo-bar.html", @post.url
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "with unspecified (date) style and categories" do
|
113
|
+
setup do
|
114
|
+
@post.categories << "food"
|
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/food/2008/10/19/foo-bar.html", @post.url
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "with none style" do
|
126
|
+
setup do
|
127
|
+
@post.site.permalink_style = :none
|
128
|
+
@post.process(@fake_file)
|
129
|
+
end
|
130
|
+
|
131
|
+
should "process the url correctly" do
|
132
|
+
assert_equal "/:categories/:title.html", @post.template
|
133
|
+
assert_equal "/foo-bar.html", @post.url
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "with pretty style" do
|
138
|
+
setup do
|
139
|
+
@post.site.permalink_style = :pretty
|
140
|
+
@post.process(@fake_file)
|
141
|
+
end
|
142
|
+
|
143
|
+
should "process the url correctly" do
|
144
|
+
assert_equal "/:categories/:year/:month/:day/:title/", @post.template
|
145
|
+
assert_equal "/2008/10/19/foo-bar/", @post.url
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "with prefix style and no extension" do
|
150
|
+
setup do
|
151
|
+
@post.site.permalink_style = "/prefix/:title"
|
152
|
+
@post.process(@fake_file)
|
153
|
+
end
|
154
|
+
|
155
|
+
should "process the url correctly" do
|
156
|
+
assert_equal "/prefix/:title", @post.template
|
157
|
+
assert_equal "/prefix/foo-bar", @post.url
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
should "read yaml front-matter" do
|
163
|
+
@post.read_yaml(@source, @real_file)
|
164
|
+
|
165
|
+
assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
|
166
|
+
assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", @post.content
|
167
|
+
end
|
168
|
+
|
169
|
+
should "transform textile" do
|
170
|
+
@post.process(@real_file)
|
171
|
+
@post.read_yaml(@source, @real_file)
|
172
|
+
@post.transform
|
173
|
+
|
174
|
+
assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "when in a site" do
|
179
|
+
setup do
|
180
|
+
clear_dest
|
181
|
+
stub(Jekyll).configuration { Jekyll::DEFAULTS }
|
182
|
+
@site = Site.new(Jekyll.configuration)
|
183
|
+
@site.posts = [setup_post('2008-02-02-published.textile'),
|
184
|
+
setup_post('2009-01-27-categories.textile')]
|
185
|
+
end
|
186
|
+
|
187
|
+
should "have next post" do
|
188
|
+
assert_equal(@site.posts.last, @site.posts.first.next)
|
189
|
+
end
|
190
|
+
|
191
|
+
should "have previous post" do
|
192
|
+
assert_equal(@site.posts.first, @site.posts.last.previous)
|
193
|
+
end
|
194
|
+
|
195
|
+
should "not have previous post if first" do
|
196
|
+
assert_equal(nil, @site.posts.first.previous)
|
197
|
+
end
|
198
|
+
|
199
|
+
should "not have next post if last" do
|
200
|
+
assert_equal(nil, @site.posts.last.next)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context "initializing posts" do
|
205
|
+
should "publish when published yaml is no specified" do
|
206
|
+
post = setup_post("2008-02-02-published.textile")
|
207
|
+
assert_equal true, post.published
|
208
|
+
end
|
209
|
+
|
210
|
+
should "not published when published yaml is false" do
|
211
|
+
post = setup_post("2008-02-02-not-published.textile")
|
212
|
+
assert_equal false, post.published
|
213
|
+
end
|
214
|
+
|
215
|
+
should "recognize category in yaml" do
|
216
|
+
post = setup_post("2009-01-27-category.textile")
|
217
|
+
assert post.categories.include?('foo')
|
218
|
+
end
|
219
|
+
|
220
|
+
should "recognize several categories in yaml" do
|
221
|
+
post = setup_post("2009-01-27-categories.textile")
|
222
|
+
assert post.categories.include?('foo')
|
223
|
+
assert post.categories.include?('bar')
|
224
|
+
assert post.categories.include?('baz')
|
225
|
+
end
|
226
|
+
|
227
|
+
should "recognize tag in yaml" do
|
228
|
+
post = setup_post("2009-05-18-tag.textile")
|
229
|
+
assert post.tags.include?('code')
|
230
|
+
end
|
231
|
+
|
232
|
+
should "recognize tags in yaml" do
|
233
|
+
post = setup_post("2009-05-18-tags.textile")
|
234
|
+
assert post.tags.include?('food')
|
235
|
+
assert post.tags.include?('cooking')
|
236
|
+
assert post.tags.include?('pizza')
|
237
|
+
end
|
238
|
+
|
239
|
+
should "allow no yaml" do
|
240
|
+
post = setup_post("2009-06-22-no-yaml.textile")
|
241
|
+
assert_equal "No YAML.", post.content
|
242
|
+
end
|
243
|
+
|
244
|
+
should "allow empty yaml" do
|
245
|
+
post = setup_post("2009-06-22-empty-yaml.textile")
|
246
|
+
assert_equal "Empty YAML.", post.content
|
247
|
+
end
|
248
|
+
|
249
|
+
context "rendering" do
|
250
|
+
setup do
|
251
|
+
clear_dest
|
252
|
+
end
|
253
|
+
|
254
|
+
should "render properly" do
|
255
|
+
post = setup_post("2008-10-18-foo-bar.textile")
|
256
|
+
do_render(post)
|
257
|
+
assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
|
258
|
+
end
|
259
|
+
|
260
|
+
should "write properly" do
|
261
|
+
post = setup_post("2008-10-18-foo-bar.textile")
|
262
|
+
do_render(post)
|
263
|
+
post.write(dest_dir)
|
264
|
+
|
265
|
+
assert File.directory?(dest_dir)
|
266
|
+
assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
|
267
|
+
end
|
268
|
+
|
269
|
+
should "write properly without html extension" do
|
270
|
+
post = setup_post("2008-10-18-foo-bar.textile")
|
271
|
+
post.site.permalink_style = ":title"
|
272
|
+
do_render(post)
|
273
|
+
post.write(dest_dir)
|
274
|
+
|
275
|
+
assert File.directory?(dest_dir)
|
276
|
+
assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
|
277
|
+
end
|
278
|
+
|
279
|
+
should "insert data" do
|
280
|
+
post = setup_post("2008-11-21-complex.textile")
|
281
|
+
do_render(post)
|
282
|
+
|
283
|
+
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
|
284
|
+
end
|
285
|
+
|
286
|
+
should "include templates" do
|
287
|
+
post = setup_post("2008-12-13-include.markdown")
|
288
|
+
post.site.source = File.join(File.dirname(__FILE__), 'source')
|
289
|
+
do_render(post)
|
290
|
+
|
291
|
+
assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
should "generate categories and topics" do
|
297
|
+
post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
|
298
|
+
assert_equal ['foo'], post.categories
|
299
|
+
end
|
300
|
+
|
301
|
+
end
|
302
|
+
end
|
data/test/test_site.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TestSite < Test::Unit::TestCase
|
4
|
+
context "creating sites" do
|
5
|
+
setup do
|
6
|
+
stub(Jekyll).configuration do
|
7
|
+
Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
|
8
|
+
end
|
9
|
+
@site = Site.new(Jekyll.configuration)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "have an empty tag hash by default" do
|
13
|
+
assert_equal Hash.new, @site.tags
|
14
|
+
end
|
15
|
+
|
16
|
+
should "reset data before processing" do
|
17
|
+
clear_dest
|
18
|
+
@site.process
|
19
|
+
before_posts = @site.posts.length
|
20
|
+
before_layouts = @site.layouts.length
|
21
|
+
before_categories = @site.categories.length
|
22
|
+
|
23
|
+
@site.process
|
24
|
+
assert_equal before_posts, @site.posts.length
|
25
|
+
assert_equal before_layouts, @site.layouts.length
|
26
|
+
assert_equal before_categories, @site.categories.length
|
27
|
+
end
|
28
|
+
|
29
|
+
should "read layouts" do
|
30
|
+
@site.read_layouts
|
31
|
+
assert_equal ["default", "simple"].sort, @site.layouts.keys.sort
|
32
|
+
end
|
33
|
+
|
34
|
+
should "read posts" do
|
35
|
+
@site.read_posts('')
|
36
|
+
posts = Dir[source_dir('_posts', '*')]
|
37
|
+
assert_equal posts.size - 1, @site.posts.size
|
38
|
+
end
|
39
|
+
|
40
|
+
should "deploy payload" do
|
41
|
+
clear_dest
|
42
|
+
@site.process
|
43
|
+
|
44
|
+
posts = Dir[source_dir("**", "_posts", "*")]
|
45
|
+
categories = %w(bar baz category foo z_category publish_test win).sort
|
46
|
+
|
47
|
+
assert_equal posts.size - 1, @site.posts.size
|
48
|
+
assert_equal categories, @site.categories.keys.sort
|
49
|
+
assert_equal 4, @site.categories['foo'].size
|
50
|
+
end
|
51
|
+
|
52
|
+
should "filter entries" do
|
53
|
+
ent1 = %w[foo.markdown bar.markdown baz.markdown #baz.markdown#
|
54
|
+
.baz.markdow foo.markdown~]
|
55
|
+
ent2 = %w[.htaccess _posts bla.bla]
|
56
|
+
|
57
|
+
assert_equal %w[foo.markdown bar.markdown baz.markdown], @site.filter_entries(ent1)
|
58
|
+
assert_equal ent2, @site.filter_entries(ent2)
|
59
|
+
end
|
60
|
+
|
61
|
+
should "filter entries with exclude" do
|
62
|
+
excludes = %w[README TODO]
|
63
|
+
includes = %w[index.html site.css]
|
64
|
+
|
65
|
+
@site.exclude = excludes
|
66
|
+
assert_equal includes, @site.filter_entries(excludes + includes)
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'with an invalid markdown processor in the configuration' do
|
70
|
+
|
71
|
+
should 'give a meaningful error message' do
|
72
|
+
bad_processor = 'not a processor name'
|
73
|
+
begin
|
74
|
+
Site.new(Jekyll.configuration.merge({ 'markdown' => bad_processor }))
|
75
|
+
flunk 'Invalid markdown processors should cause a failure on site creation'
|
76
|
+
rescue RuntimeError => e
|
77
|
+
assert e.to_s =~ /invalid|bad/i
|
78
|
+
assert e.to_s =~ %r{#{bad_processor}}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
data/test/test_tags.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TestTags < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def create_post(content, override = {}, markdown = true)
|
6
|
+
stub(Jekyll).configuration do
|
7
|
+
Jekyll::DEFAULTS.merge({'pygments' => true}).merge(override)
|
8
|
+
end
|
9
|
+
site = Site.new(Jekyll.configuration)
|
10
|
+
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
|
11
|
+
|
12
|
+
if markdown
|
13
|
+
payload = {"content_type" => "markdown"}
|
14
|
+
else
|
15
|
+
payload = {"content_type" => "textile"}
|
16
|
+
end
|
17
|
+
|
18
|
+
@result = Liquid::Template.parse(content).render(payload, info)
|
19
|
+
|
20
|
+
if markdown
|
21
|
+
@result = site.markdown(@result)
|
22
|
+
else
|
23
|
+
@result = site.textile(@result)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def fill_post(code, override = {})
|
28
|
+
content = <<CONTENT
|
29
|
+
---
|
30
|
+
title: This is a test
|
31
|
+
---
|
32
|
+
|
33
|
+
This document results in a markdown error with maruku
|
34
|
+
|
35
|
+
{% highlight text %}
|
36
|
+
#{code}
|
37
|
+
{% endhighlight %}
|
38
|
+
CONTENT
|
39
|
+
create_post(content, override)
|
40
|
+
end
|
41
|
+
|
42
|
+
context "post content has highlight tag" do
|
43
|
+
setup do
|
44
|
+
fill_post("test")
|
45
|
+
end
|
46
|
+
|
47
|
+
should "not cause a markdown error" do
|
48
|
+
assert_no_match /markdown\-html\-error/, @result
|
49
|
+
end
|
50
|
+
|
51
|
+
should "render markdown with pygments line handling" do
|
52
|
+
assert_match %{<pre>test\n</pre>}, @result
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "post content has highlight tag with UTF character" do
|
57
|
+
setup do
|
58
|
+
fill_post("Æ")
|
59
|
+
end
|
60
|
+
|
61
|
+
should "render markdown with pygments line handling" do
|
62
|
+
assert_match %{<pre>Æ\n</pre>}, @result
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "simple post with markdown and pre tags" do
|
67
|
+
setup do
|
68
|
+
@content = <<CONTENT
|
69
|
+
---
|
70
|
+
title: Maruku vs. RDiscount
|
71
|
+
---
|
72
|
+
|
73
|
+
_FIGHT!_
|
74
|
+
|
75
|
+
{% highlight ruby %}
|
76
|
+
puts "3..2..1.."
|
77
|
+
{% endhighlight %}
|
78
|
+
|
79
|
+
*FINISH HIM*
|
80
|
+
CONTENT
|
81
|
+
end
|
82
|
+
|
83
|
+
context "using Textile" do
|
84
|
+
setup do
|
85
|
+
create_post(@content, {}, false)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Broken in RedCloth 4.1.9
|
89
|
+
should "not textilize highlight block" do
|
90
|
+
assert_no_match %r{3\.\.2\.\.1\.\."</span><br />}, @result
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "using Maruku" do
|
95
|
+
setup do
|
96
|
+
create_post(@content)
|
97
|
+
end
|
98
|
+
|
99
|
+
should "parse correctly" do
|
100
|
+
assert_match %r{<em>FIGHT!</em>}, @result
|
101
|
+
assert_match %r{<em>FINISH HIM</em>}, @result
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context "using RDiscount" do
|
106
|
+
setup do
|
107
|
+
create_post(@content, 'markdown' => 'rdiscount')
|
108
|
+
end
|
109
|
+
|
110
|
+
should "parse correctly" do
|
111
|
+
assert_match %r{<em>FIGHT!</em>}, @result
|
112
|
+
assert_match %r{<em>FINISH HIM</em>}, @result
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|