codeslinger-jekyll 0.5.0 → 0.5.1
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.
- data/History.txt +12 -0
- data/README.textile +23 -527
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/bin/jekyll +12 -2
- data/lib/jekyll/albino.rb +4 -2
- data/lib/jekyll/filters.rb +5 -1
- data/lib/jekyll/page.rb +7 -4
- data/lib/jekyll/post.rb +56 -18
- data/lib/jekyll/site.rb +32 -5
- data/lib/jekyll/tags/highlight.rb +2 -2
- data/lib/jekyll.rb +3 -2
- data/test/helper.rb +3 -0
- data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
- data/test/test_filters.rb +8 -0
- data/test/test_generated_site.rb +1 -1
- data/test/test_post.rb +126 -2
- data/test/test_site.rb +8 -0
- data/test/test_tags.rb +97 -16
- metadata +5 -4
data/lib/jekyll/page.rb
CHANGED
@@ -46,18 +46,21 @@ module Jekyll
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Write the generated page file to the destination directory.
|
49
|
-
# +
|
49
|
+
# +dest_prefix+ is the String path to the destination dir
|
50
|
+
# +dest_suffix+ is a suffix path to the destination dir
|
50
51
|
#
|
51
52
|
# Returns nothing
|
52
|
-
def write(
|
53
|
-
|
53
|
+
def write(dest_prefix, dest_suffix = nil)
|
54
|
+
dest = File.join(dest_prefix, @dir)
|
55
|
+
dest = File.join(dest, dest_suffix) if dest_suffix
|
56
|
+
FileUtils.mkdir_p(dest)
|
54
57
|
|
55
58
|
name = @name
|
56
59
|
if self.ext != ""
|
57
60
|
name = @name.split(".")[0..-2].join('.') + self.ext
|
58
61
|
end
|
59
62
|
|
60
|
-
path = File.join(dest,
|
63
|
+
path = File.join(dest, name)
|
61
64
|
File.open(path, 'w') do |f|
|
62
65
|
f.write(self.output)
|
63
66
|
end
|
data/lib/jekyll/post.rb
CHANGED
@@ -18,9 +18,12 @@ module Jekyll
|
|
18
18
|
name =~ MATCHER
|
19
19
|
end
|
20
20
|
|
21
|
-
attr_accessor :site
|
22
|
-
|
23
|
-
|
21
|
+
attr_accessor :site, :date, :slug, :ext, :topics, :published, :data, :content, :output
|
22
|
+
attr_writer :categories
|
23
|
+
|
24
|
+
def categories
|
25
|
+
@categories ||= []
|
26
|
+
end
|
24
27
|
|
25
28
|
# Initialize this Post instance.
|
26
29
|
# +site+ is the Site
|
@@ -88,16 +91,7 @@ module Jekyll
|
|
88
91
|
#
|
89
92
|
# Returns <String>
|
90
93
|
def dir
|
91
|
-
|
92
|
-
permalink.to_s.split("/")[0..-2].join("/") + '/'
|
93
|
-
else
|
94
|
-
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
|
95
|
-
if [:date, :pretty].include?(self.site.permalink_style)
|
96
|
-
prefix + date.strftime("/%Y/%m/%d/")
|
97
|
-
else
|
98
|
-
prefix + '/'
|
99
|
-
end
|
100
|
-
end
|
94
|
+
File.dirname(url)
|
101
95
|
end
|
102
96
|
|
103
97
|
# The full path and filename of the post.
|
@@ -109,13 +103,35 @@ module Jekyll
|
|
109
103
|
self.data && self.data['permalink']
|
110
104
|
end
|
111
105
|
|
106
|
+
def template
|
107
|
+
case self.site.permalink_style
|
108
|
+
when :pretty
|
109
|
+
"/:categories/:year/:month/:day/:title"
|
110
|
+
when :none
|
111
|
+
"/:categories/:title.html"
|
112
|
+
when :date
|
113
|
+
"/:categories/:year/:month/:day/:title.html"
|
114
|
+
else
|
115
|
+
self.site.permalink_style.to_s
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
112
119
|
# The generated relative url of this post
|
113
120
|
# e.g. /2008/11/05/my-awesome-post.html
|
114
121
|
#
|
115
122
|
# Returns <String>
|
116
123
|
def url
|
117
|
-
|
118
|
-
|
124
|
+
return permalink if permalink
|
125
|
+
|
126
|
+
@url ||= {
|
127
|
+
"year" => date.strftime("%Y"),
|
128
|
+
"month" => date.strftime("%m"),
|
129
|
+
"day" => date.strftime("%d"),
|
130
|
+
"title" => CGI.escape(slug),
|
131
|
+
"categories" => categories.sort.join('/')
|
132
|
+
}.inject(template) { |result, token|
|
133
|
+
result.gsub(/:#{token.first}/, token.last)
|
134
|
+
}.gsub(/\/\//, "/")
|
119
135
|
end
|
120
136
|
|
121
137
|
# The UID for this post (useful in feeds)
|
@@ -123,7 +139,7 @@ module Jekyll
|
|
123
139
|
#
|
124
140
|
# Returns <String>
|
125
141
|
def id
|
126
|
-
self.dir
|
142
|
+
File.join(self.dir, self.slug)
|
127
143
|
end
|
128
144
|
|
129
145
|
# Calculate related posts.
|
@@ -172,9 +188,10 @@ module Jekyll
|
|
172
188
|
def write(dest)
|
173
189
|
FileUtils.mkdir_p(File.join(dest, dir))
|
174
190
|
|
175
|
-
|
191
|
+
# The url needs to be unescaped in order to preserve the correct filename
|
192
|
+
path = File.join(dest, CGI.unescape(self.url))
|
176
193
|
|
177
|
-
if
|
194
|
+
if template[/\.html$/].nil?
|
178
195
|
FileUtils.mkdir_p(path)
|
179
196
|
path = File.join(path, "index.html")
|
180
197
|
end
|
@@ -194,12 +211,33 @@ module Jekyll
|
|
194
211
|
"id" => self.id,
|
195
212
|
"topics" => self.topics,
|
196
213
|
"categories" => self.categories,
|
214
|
+
"next" => self.next,
|
215
|
+
"previous" => self.previous,
|
197
216
|
"content" => self.content }.deep_merge(self.data)
|
198
217
|
end
|
199
218
|
|
200
219
|
def inspect
|
201
220
|
"<Post: #{self.id}>"
|
202
221
|
end
|
222
|
+
|
223
|
+
def next
|
224
|
+
pos = self.site.posts.index(self)
|
225
|
+
|
226
|
+
if pos && pos < self.site.posts.length-1
|
227
|
+
self.site.posts[pos+1]
|
228
|
+
else
|
229
|
+
nil
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def previous
|
234
|
+
pos = self.site.posts.index(self)
|
235
|
+
if pos && pos > 0
|
236
|
+
self.site.posts[pos-1]
|
237
|
+
else
|
238
|
+
nil
|
239
|
+
end
|
240
|
+
end
|
203
241
|
end
|
204
242
|
|
205
243
|
end
|
data/lib/jekyll/site.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Jekyll
|
2
2
|
|
3
3
|
class Site
|
4
|
-
attr_accessor :config, :layouts, :posts, :categories
|
4
|
+
attr_accessor :config, :layouts, :posts, :categories, :exclude
|
5
5
|
attr_accessor :source, :dest, :lsi, :pygments, :permalink_style
|
6
6
|
|
7
7
|
# Initialize the site
|
@@ -16,6 +16,7 @@ module Jekyll
|
|
16
16
|
self.lsi = config['lsi']
|
17
17
|
self.pygments = config['pygments']
|
18
18
|
self.permalink_style = config['permalink'].to_sym
|
19
|
+
self.exclude = config['exclude'] || []
|
19
20
|
|
20
21
|
self.reset
|
21
22
|
self.setup
|
@@ -41,7 +42,6 @@ module Jekyll
|
|
41
42
|
RDiscount.new(content).to_html
|
42
43
|
end
|
43
44
|
|
44
|
-
puts 'Using rdiscount for Markdown'
|
45
45
|
rescue LoadError
|
46
46
|
puts 'You must have the rdiscount gem installed first'
|
47
47
|
end
|
@@ -130,12 +130,13 @@ module Jekyll
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
self.posts.sort!
|
134
|
+
|
133
135
|
# second pass renders each post now that full site payload is available
|
134
136
|
self.posts.each do |post|
|
135
137
|
post.render(self.layouts, site_payload)
|
136
138
|
end
|
137
139
|
|
138
|
-
self.posts.sort!
|
139
140
|
self.categories.values.map { |cats| cats.sort! { |a, b| b <=> a} }
|
140
141
|
rescue Errno::ENOENT => e
|
141
142
|
# ignore missing layout dir
|
@@ -171,11 +172,14 @@ module Jekyll
|
|
171
172
|
directories.delete('_posts')
|
172
173
|
read_posts(dir)
|
173
174
|
end
|
175
|
+
|
174
176
|
[directories, files].each do |entries|
|
175
177
|
entries.each do |f|
|
176
178
|
if File.directory?(File.join(base, f))
|
177
179
|
next if self.dest.sub(/\/$/, '') == File.join(base, f)
|
178
180
|
transform_pages(File.join(dir, f))
|
181
|
+
elsif Pager.pagination_enabled?(self.config, f)
|
182
|
+
paginate_posts(f, dir)
|
179
183
|
else
|
180
184
|
first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) }
|
181
185
|
|
@@ -228,11 +232,34 @@ module Jekyll
|
|
228
232
|
def filter_entries(entries)
|
229
233
|
entries = entries.reject do |e|
|
230
234
|
unless ['_posts', '.htaccess'].include?(e)
|
231
|
-
#
|
232
|
-
['.', '_', '#'].include?(e[0..0]) or e[-1..-1] == '~'
|
235
|
+
['.', '_', '#'].include?(e[0..0]) || e[-1..-1] == '~' || self.exclude.include?(e)
|
233
236
|
end
|
234
237
|
end
|
235
238
|
end
|
236
239
|
|
240
|
+
# Paginates the blog's posts. Renders the index.html file into paginated directories, ie: page2, page3...
|
241
|
+
# and adds more wite-wide data
|
242
|
+
#
|
243
|
+
# {"paginator" => { "page" => <Number>,
|
244
|
+
# "per_page" => <Number>,
|
245
|
+
# "posts" => [<Post>],
|
246
|
+
# "total_posts" => <Number>,
|
247
|
+
# "total_pages" => <Number>,
|
248
|
+
# "previous_page" => <Number>,
|
249
|
+
# "next_page" => <Number> }}
|
250
|
+
def paginate_posts(file, dir)
|
251
|
+
all_posts = self.posts.sort { |a,b| b <=> a }
|
252
|
+
page = Page.new(self, self.source, dir, file)
|
253
|
+
|
254
|
+
pages = Pager.calculate_pages(all_posts, self.config['paginate'].to_i)
|
255
|
+
|
256
|
+
(1..pages).each do |num_page|
|
257
|
+
pager = Pager.new(self.config, num_page, all_posts, pages)
|
258
|
+
|
259
|
+
page.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash}))
|
260
|
+
suffix = "page#{num_page}" if num_page > 1
|
261
|
+
page.write(self.dest, suffix)
|
262
|
+
end
|
263
|
+
end
|
237
264
|
end
|
238
265
|
end
|
@@ -30,9 +30,9 @@ module Jekyll
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def render_pygments(context, code)
|
33
|
-
if context["content_type"] ==
|
33
|
+
if context["content_type"] == "markdown"
|
34
34
|
return "\n" + Albino.new(code, @lang).to_s(@options) + "\n"
|
35
|
-
elsif context["content_type"] ==
|
35
|
+
elsif context["content_type"] == "textile"
|
36
36
|
return "<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
|
37
37
|
else
|
38
38
|
return Albino.new(code, @lang).to_s(@options)
|
data/lib/jekyll.rb
CHANGED
@@ -16,6 +16,7 @@ require 'redcloth'
|
|
16
16
|
|
17
17
|
# internal requires
|
18
18
|
require 'jekyll/core_ext'
|
19
|
+
require 'jekyll/pager'
|
19
20
|
require 'jekyll/site'
|
20
21
|
require 'jekyll/convertible'
|
21
22
|
require 'jekyll/layout'
|
@@ -27,7 +28,7 @@ require 'jekyll/tags/include'
|
|
27
28
|
require 'jekyll/albino'
|
28
29
|
|
29
30
|
module Jekyll
|
30
|
-
# Default options. Overriden by values in _config.
|
31
|
+
# Default options. Overriden by values in _config.yml or command-line opts.
|
31
32
|
# (Strings rather symbols used for compatability with YAML)
|
32
33
|
DEFAULTS = {
|
33
34
|
'auto' => false,
|
@@ -61,7 +62,7 @@ module Jekyll
|
|
61
62
|
# then, we need to know where to look for _config.yml
|
62
63
|
source = override['source'] || Jekyll::DEFAULTS['source']
|
63
64
|
|
64
|
-
# Get configuration from <source>/_config.
|
65
|
+
# Get configuration from <source>/_config.yml
|
65
66
|
config = {}
|
66
67
|
config_file = File.join(source, '_config.yml')
|
67
68
|
begin
|
data/test/helper.rb
CHANGED
data/test/test_filters.rb
CHANGED
@@ -37,5 +37,13 @@ class TestFilters < Test::Unit::TestCase
|
|
37
37
|
assert_equal "AT&T", @filter.xml_escape("AT&T")
|
38
38
|
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></code>")
|
39
39
|
end
|
40
|
+
|
41
|
+
should "escape space as plus" do
|
42
|
+
assert_equal "my+things", @filter.cgi_escape("my things")
|
43
|
+
end
|
44
|
+
|
45
|
+
should "escape special characters" do
|
46
|
+
assert_equal "hey%21", @filter.cgi_escape("hey!")
|
47
|
+
end
|
40
48
|
end
|
41
49
|
end
|
data/test/test_generated_site.rb
CHANGED
@@ -18,7 +18,7 @@ class TestGeneratedSite < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
should "render post.content" do
|
21
|
-
latest_post = Dir[source_dir('_posts', '*')].last
|
21
|
+
latest_post = Dir[source_dir('_posts', '*')].sort.last
|
22
22
|
post = Post.new(@site, source_dir, '', File.basename(latest_post))
|
23
23
|
post.transform
|
24
24
|
assert @index.include?(post.content)
|
data/test/test_post.rb
CHANGED
@@ -25,6 +25,7 @@ class TestPost < Test::Unit::TestCase
|
|
25
25
|
assert !Post.valid?("blah")
|
26
26
|
end
|
27
27
|
|
28
|
+
|
28
29
|
context "processing posts" do
|
29
30
|
setup do
|
30
31
|
@post = Post.allocate
|
@@ -41,6 +42,8 @@ class TestPost < Test::Unit::TestCase
|
|
41
42
|
assert_equal Time.parse("2008-10-19"), @post.date
|
42
43
|
assert_equal "foo-bar", @post.slug
|
43
44
|
assert_equal ".textile", @post.ext
|
45
|
+
assert_equal "/2008/10/19", @post.dir
|
46
|
+
assert_equal "/2008/10/19/foo-bar", @post.id
|
44
47
|
end
|
45
48
|
|
46
49
|
should "create url based on date and title" do
|
@@ -49,16 +52,101 @@ class TestPost < Test::Unit::TestCase
|
|
49
52
|
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
50
53
|
end
|
51
54
|
|
52
|
-
should "
|
55
|
+
should "CGI escape urls" do
|
56
|
+
@post.categories = []
|
57
|
+
@post.process("2009-03-12-hash-#1.markdown")
|
58
|
+
assert_equal "/2009/03/12/hash-%231.html", @post.url
|
59
|
+
assert_equal "/2009/03/12/hash-#1", @post.id
|
60
|
+
end
|
61
|
+
|
62
|
+
should "respect permalink in yaml front matter" do
|
53
63
|
file = "2008-12-03-permalinked-post.textile"
|
54
64
|
@post.process(file)
|
55
65
|
@post.read_yaml(@source, file)
|
56
66
|
|
57
67
|
assert_equal "my_category/permalinked-post", @post.permalink
|
58
|
-
assert_equal "my_category
|
68
|
+
assert_equal "my_category", @post.dir
|
59
69
|
assert_equal "my_category/permalinked-post", @post.url
|
60
70
|
end
|
61
71
|
|
72
|
+
context "with site wide permalink" do
|
73
|
+
setup do
|
74
|
+
@post.categories = []
|
75
|
+
end
|
76
|
+
|
77
|
+
context "with unspecified (date) style" do
|
78
|
+
setup do
|
79
|
+
@post.process(@fake_file)
|
80
|
+
end
|
81
|
+
|
82
|
+
should "process the url correctly" do
|
83
|
+
assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
|
84
|
+
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "with unspecified (date) style and a category" do
|
89
|
+
setup do
|
90
|
+
@post.categories << "beer"
|
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 "/beer/2008/10/19/foo-bar.html", @post.url
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "with unspecified (date) style and categories" do
|
101
|
+
setup do
|
102
|
+
@post.categories << "food"
|
103
|
+
@post.categories << "beer"
|
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 "/beer/food/2008/10/19/foo-bar.html", @post.url
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "with none style" do
|
114
|
+
setup do
|
115
|
+
@post.site.permalink_style = :none
|
116
|
+
@post.process(@fake_file)
|
117
|
+
end
|
118
|
+
|
119
|
+
should "process the url correctly" do
|
120
|
+
assert_equal "/:categories/:title.html", @post.template
|
121
|
+
assert_equal "/foo-bar.html", @post.url
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "with pretty style" do
|
126
|
+
setup do
|
127
|
+
@post.site.permalink_style = :pretty
|
128
|
+
@post.process(@fake_file)
|
129
|
+
end
|
130
|
+
|
131
|
+
should "process the url correctly" do
|
132
|
+
assert_equal "/:categories/:year/:month/:day/:title", @post.template
|
133
|
+
assert_equal "/2008/10/19/foo-bar", @post.url
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "with prefix style and no extension" do
|
138
|
+
setup do
|
139
|
+
@post.site.permalink_style = "/prefix/:title"
|
140
|
+
@post.process(@fake_file)
|
141
|
+
end
|
142
|
+
|
143
|
+
should "process the url correctly" do
|
144
|
+
assert_equal "/prefix/:title", @post.template
|
145
|
+
assert_equal "/prefix/foo-bar", @post.url
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
62
150
|
should "read yaml front-matter" do
|
63
151
|
@post.read_yaml(@source, @real_file)
|
64
152
|
|
@@ -75,6 +163,32 @@ class TestPost < Test::Unit::TestCase
|
|
75
163
|
end
|
76
164
|
end
|
77
165
|
|
166
|
+
context "when in a site" do
|
167
|
+
setup do
|
168
|
+
clear_dest
|
169
|
+
stub(Jekyll).configuration { Jekyll::DEFAULTS }
|
170
|
+
@site = Site.new(Jekyll.configuration)
|
171
|
+
@site.posts = [setup_post('2008-02-02-published.textile'),
|
172
|
+
setup_post('2009-01-27-categories.textile')]
|
173
|
+
end
|
174
|
+
|
175
|
+
should "have next post" do
|
176
|
+
assert_equal(@site.posts.last, @site.posts.first.next)
|
177
|
+
end
|
178
|
+
|
179
|
+
should "have previous post" do
|
180
|
+
assert_equal(@site.posts.first, @site.posts.last.previous)
|
181
|
+
end
|
182
|
+
|
183
|
+
should "not have previous post if first" do
|
184
|
+
assert_equal(nil, @site.posts.first.previous)
|
185
|
+
end
|
186
|
+
|
187
|
+
should "not have next post if last" do
|
188
|
+
assert_equal(nil, @site.posts.last.next)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
78
192
|
context "initializing posts" do
|
79
193
|
should "publish when published yaml is no specified" do
|
80
194
|
post = setup_post("2008-02-02-published.textile")
|
@@ -118,6 +232,16 @@ class TestPost < Test::Unit::TestCase
|
|
118
232
|
assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
|
119
233
|
end
|
120
234
|
|
235
|
+
should "write properly without html extension" do
|
236
|
+
post = setup_post("2008-10-18-foo-bar.textile")
|
237
|
+
post.site.permalink_style = ":title"
|
238
|
+
do_render(post)
|
239
|
+
post.write(dest_dir)
|
240
|
+
|
241
|
+
assert File.directory?(dest_dir)
|
242
|
+
assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
|
243
|
+
end
|
244
|
+
|
121
245
|
should "insert data" do
|
122
246
|
post = setup_post("2008-11-21-complex.textile")
|
123
247
|
do_render(post)
|
data/test/test_site.rb
CHANGED
@@ -53,5 +53,13 @@ class TestSite < Test::Unit::TestCase
|
|
53
53
|
assert_equal %w[foo.markdown bar.markdown baz.markdown], @site.filter_entries(ent1)
|
54
54
|
assert_equal ent2, @site.filter_entries(ent2)
|
55
55
|
end
|
56
|
+
|
57
|
+
should "filter entries with exclude" do
|
58
|
+
excludes = %w[README TODO]
|
59
|
+
includes = %w[index.html site.css]
|
60
|
+
|
61
|
+
@site.exclude = excludes
|
62
|
+
assert_equal includes, @site.filter_entries(excludes + includes)
|
63
|
+
end
|
56
64
|
end
|
57
65
|
end
|
data/test/test_tags.rb
CHANGED
@@ -1,35 +1,116 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
3
|
class TestTags < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
7
29
|
---
|
8
|
-
layout: post
|
9
30
|
title: This is a test
|
10
|
-
|
11
31
|
---
|
32
|
+
|
12
33
|
This document results in a markdown error with maruku
|
13
34
|
|
14
|
-
{% highlight
|
15
|
-
|
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
|
16
55
|
|
17
|
-
|
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.."
|
18
77
|
{% endhighlight %}
|
19
78
|
|
79
|
+
*FINISH HIM*
|
20
80
|
CONTENT
|
21
81
|
end
|
22
82
|
|
23
|
-
|
24
|
-
|
25
|
-
|
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)
|
26
97
|
end
|
27
|
-
site = Site.new(Jekyll.configuration)
|
28
|
-
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
|
29
98
|
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
33
114
|
end
|
34
115
|
end
|
35
116
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeslinger-jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-06 00:00:00 -07:00
|
13
13
|
default_executable: jekyll
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,9 +18,9 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- - "
|
21
|
+
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 4.0
|
23
|
+
version: 4.1.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: liquid
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- test/source/_posts/2009-01-27-array-categories.textile
|
117
117
|
- test/source/_posts/2009-01-27-categories.textile
|
118
118
|
- test/source/_posts/2009-01-27-category.textile
|
119
|
+
- test/source/_posts/2009-03-12-hash-#1.markdown
|
119
120
|
- test/source/category/_posts/2008-9-23-categories.textile
|
120
121
|
- test/source/css/screen.css
|
121
122
|
- test/source/foo/_posts/bar/2008-12-12-topical-post.textile
|