jekyll 3.1.0.pre.beta1 → 3.1.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jekyll might be problematic. Click here for more details.

Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.markdown +1 -0
  4. data/bin/jekyll +17 -8
  5. data/lib/jekyll.rb +6 -6
  6. data/lib/jekyll/cleaner.rb +1 -1
  7. data/lib/jekyll/collection.rb +8 -7
  8. data/lib/jekyll/command.rb +0 -4
  9. data/lib/jekyll/commands/build.rb +2 -6
  10. data/lib/jekyll/commands/clean.rb +1 -3
  11. data/lib/jekyll/commands/doctor.rb +15 -19
  12. data/lib/jekyll/commands/help.rb +0 -2
  13. data/lib/jekyll/commands/serve.rb +11 -3
  14. data/lib/jekyll/commands/serve/servlet.rb +3 -3
  15. data/lib/jekyll/configuration.rb +28 -29
  16. data/lib/jekyll/converters/identity.rb +1 -1
  17. data/lib/jekyll/converters/markdown.rb +7 -7
  18. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +1 -1
  19. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +5 -6
  20. data/lib/jekyll/converters/smartypants.rb +34 -0
  21. data/lib/jekyll/convertible.rb +29 -16
  22. data/lib/jekyll/deprecator.rb +1 -1
  23. data/lib/jekyll/document.rb +26 -27
  24. data/lib/jekyll/drops/collection_drop.rb +0 -2
  25. data/lib/jekyll/drops/document_drop.rb +0 -1
  26. data/lib/jekyll/drops/drop.rb +54 -6
  27. data/lib/jekyll/drops/site_drop.rb +0 -1
  28. data/lib/jekyll/drops/unified_payload_drop.rb +0 -1
  29. data/lib/jekyll/drops/url_drop.rb +45 -13
  30. data/lib/jekyll/entry_filter.rb +1 -1
  31. data/lib/jekyll/errors.rb +4 -2
  32. data/lib/jekyll/external.rb +5 -6
  33. data/lib/jekyll/filters.rb +18 -7
  34. data/lib/jekyll/frontmatter_defaults.rb +16 -15
  35. data/lib/jekyll/generator.rb +1 -2
  36. data/lib/jekyll/hooks.rb +26 -26
  37. data/lib/jekyll/liquid_renderer.rb +1 -1
  38. data/lib/jekyll/liquid_renderer/table.rb +2 -2
  39. data/lib/jekyll/page.rb +7 -8
  40. data/lib/jekyll/plugin.rb +31 -12
  41. data/lib/jekyll/plugin_manager.rb +3 -4
  42. data/lib/jekyll/reader.rb +7 -7
  43. data/lib/jekyll/readers/collection_reader.rb +1 -2
  44. data/lib/jekyll/readers/data_reader.rb +7 -7
  45. data/lib/jekyll/readers/page_reader.rb +3 -3
  46. data/lib/jekyll/readers/post_reader.rb +2 -2
  47. data/lib/jekyll/readers/static_file_reader.rb +2 -2
  48. data/lib/jekyll/regenerator.rb +17 -18
  49. data/lib/jekyll/related_posts.rb +0 -2
  50. data/lib/jekyll/renderer.rb +14 -12
  51. data/lib/jekyll/site.rb +18 -22
  52. data/lib/jekyll/static_file.rb +15 -15
  53. data/lib/jekyll/stevenson.rb +2 -2
  54. data/lib/jekyll/tags/highlight.rb +10 -11
  55. data/lib/jekyll/tags/include.rb +10 -11
  56. data/lib/jekyll/tags/post_url.rb +7 -10
  57. data/lib/jekyll/url.rb +4 -5
  58. data/lib/jekyll/utils.rb +27 -22
  59. data/lib/jekyll/utils/ansi.rb +1 -1
  60. data/lib/jekyll/utils/platforms.rb +0 -1
  61. data/lib/jekyll/version.rb +1 -1
  62. data/lib/site_template/_includes/head.html +1 -1
  63. metadata +4 -3
@@ -5,7 +5,7 @@ module Jekyll
5
5
 
6
6
  priority :lowest
7
7
 
8
- def matches(ext)
8
+ def matches(_ext)
9
9
  true
10
10
  end
11
11
 
@@ -7,7 +7,7 @@ module Jekyll
7
7
 
8
8
  def setup
9
9
  return if @setup
10
- if (!@parser = get_processor)
10
+ unless (@parser = get_processor)
11
11
  Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
12
12
  Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"]
13
13
  Jekyll.logger.error "", "Available processors are: #{valid_processors.join(", ")}"
@@ -19,9 +19,9 @@ module Jekyll
19
19
 
20
20
  def get_processor
21
21
  case @config["markdown"].downcase
22
- when "redcarpet" then return RedcarpetParser.new(@config)
23
- when "kramdown" then return KramdownParser.new(@config)
24
- when "rdiscount" then return RDiscountParser.new(@config)
22
+ when "redcarpet" then return RedcarpetParser.new(@config)
23
+ when "kramdown" then return KramdownParser.new(@config)
24
+ when "rdiscount" then return RDiscountParser.new(@config)
25
25
  else
26
26
  get_custom_processor
27
27
  end
@@ -37,11 +37,11 @@ module Jekyll
37
37
 
38
38
  # Public: A list of processors that you provide via plugins.
39
39
  # This is really only available if you are not in safe mode, if you are
40
- # in safe mode (re: Github) then there will be none.
40
+ # in safe mode (re: GitHub) then there will be none.
41
41
 
42
42
  def third_party_processors
43
43
  self.class.constants - \
44
- %w[KramdownParser RDiscountParser RedcarpetParser PRIORITIES].map(
44
+ %w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map(
45
45
  &:to_sym
46
46
  )
47
47
  end
@@ -56,7 +56,7 @@ module Jekyll
56
56
  extname_list.include?(ext.downcase)
57
57
  end
58
58
 
59
- def output_ext(ext)
59
+ def output_ext(_ext)
60
60
  ".html"
61
61
  end
62
62
 
@@ -5,7 +5,7 @@ module Jekyll
5
5
  def initialize(config)
6
6
  Jekyll::External.require_with_graceful_fail "rdiscount"
7
7
  @config = config
8
- @rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
8
+ @rdiscount_extensions = @config['rdiscount']['extensions'].map(&:to_sym)
9
9
  end
10
10
 
11
11
  def convert(content)
@@ -2,12 +2,12 @@ module Jekyll
2
2
  module Converters
3
3
  class Markdown
4
4
  class RedcarpetParser
5
-
6
5
  module CommonMethods
7
6
  def add_code_tags(code, lang)
8
7
  code = code.to_s
9
8
  code = code.sub(/<pre>/, "<pre><code class=\"language-#{lang}\" data-lang=\"#{lang}\">")
10
- code = code.sub(/<\/pre>/,"</code></pre>")
9
+ code = code.sub(/<\/pre>/, "</code></pre>")
10
+ code
11
11
  end
12
12
  end
13
13
 
@@ -48,12 +48,11 @@ module Jekyll
48
48
  end
49
49
 
50
50
  protected
51
- def rouge_formatter(lexer)
51
+ def rouge_formatter(_lexer)
52
52
  Rouge::Formatters::HTML.new(:wrap => false)
53
53
  end
54
54
  end
55
55
 
56
-
57
56
  def initialize(config)
58
57
  External.require_with_graceful_fail("redcarpet")
59
58
  @config = config
@@ -71,10 +70,10 @@ module Jekyll
71
70
  end
72
71
  when "rouge"
73
72
  Class.new(Redcarpet::Render::HTML) do
74
- Jekyll::External.require_with_graceful_fail(%w[
73
+ Jekyll::External.require_with_graceful_fail(%w(
75
74
  rouge
76
75
  rouge/plugins/redcarpet
77
- ])
76
+ ))
78
77
 
79
78
  unless Gem::Version.new(Rouge.version) > Gem::Version.new("1.3.0")
80
79
  abort "Please install Rouge 1.3.0 or greater and try running Jekyll again."
@@ -0,0 +1,34 @@
1
+ class Kramdown::Parser::SmartyPants < Kramdown::Parser::Kramdown
2
+ def initialize(source, options)
3
+ super
4
+ @block_parsers = [:block_html]
5
+ @span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html]
6
+ end
7
+ end
8
+
9
+ module Jekyll
10
+ module Converters
11
+ class SmartyPants < Converter
12
+ safe true
13
+ priority :low
14
+
15
+ def initialize(config)
16
+ Jekyll::External.require_with_graceful_fail "kramdown"
17
+ @config = config["kramdown"].dup || {}
18
+ @config[:input] = :SmartyPants
19
+ end
20
+
21
+ def matches(_)
22
+ false
23
+ end
24
+
25
+ def output_ext(_)
26
+ nil
27
+ end
28
+
29
+ def convert(content)
30
+ Kramdown::Document.new(content, @config).to_html.chomp
31
+ end
32
+ end
33
+ end
34
+ end
@@ -42,26 +42,39 @@ module Jekyll
42
42
  #
43
43
  # Returns nothing.
44
44
  def read_yaml(base, name, opts = {})
45
+ filename = File.join(base, name)
46
+
45
47
  begin
46
48
  self.content = File.read(site.in_source_dir(base, name),
47
49
  merged_file_read_opts(opts))
48
50
  if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
49
51
  self.content = $POSTMATCH
50
- self.data = SafeYAML.load($1)
52
+ self.data = SafeYAML.load(Regexp.last_match(1))
51
53
  end
52
54
  rescue SyntaxError => e
53
- Jekyll.logger.warn "YAML Exception reading #{File.join(base, name)}: #{e.message}"
55
+ Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}"
54
56
  rescue Exception => e
55
- Jekyll.logger.warn "Error reading file #{File.join(base, name)}: #{e.message}"
57
+ Jekyll.logger.warn "Error reading file #{filename}: #{e.message}"
56
58
  end
57
59
 
58
60
  self.data ||= {}
59
61
 
62
+ validate_data! filename
63
+ validate_permalink! filename
64
+
65
+ self.data
66
+ end
67
+
68
+ def validate_data!(filename)
60
69
  unless self.data.is_a?(Hash)
61
- Jekyll.logger.abort_with "Fatal:", "Invalid YAML front matter in #{File.join(base, name)}"
70
+ raise Errors::InvalidYAMLFrontMatterError, "Invalid YAML front matter in #{filename}"
62
71
  end
72
+ end
63
73
 
64
- self.data
74
+ def validate_permalink!(filename)
75
+ if self.data['permalink'] && self.data['permalink'].size == 0
76
+ raise Errors::InvalidPermalinkError, "Invalid permalink in #{filename}"
77
+ end
65
78
  end
66
79
 
67
80
  # Transform the contents based on the content type.
@@ -87,9 +100,9 @@ module Jekyll
87
100
  if converters.all? { |c| c.is_a?(Jekyll::Converters::Identity) }
88
101
  ext
89
102
  else
90
- converters.map { |c|
103
+ converters.map do |c|
91
104
  c.output_ext(ext) unless c.is_a?(Jekyll::Converters::Identity)
92
- }.compact.last
105
+ end.compact.last
93
106
  end
94
107
  end
95
108
 
@@ -122,9 +135,9 @@ module Jekyll
122
135
  #
123
136
  # Returns the Hash representation of this Convertible.
124
137
  def to_liquid(attrs = nil)
125
- further_data = Hash[(attrs || self.class::ATTRIBUTES_FOR_LIQUID).map { |attribute|
138
+ further_data = Hash[(attrs || self.class::ATTRIBUTES_FOR_LIQUID).map do |attribute|
126
139
  [attribute, send(attribute)]
127
- }]
140
+ end]
128
141
 
129
142
  defaults = site.frontmatter_defaults.all(relative_path, type)
130
143
  Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data)
@@ -160,7 +173,7 @@ module Jekyll
160
173
  #
161
174
  # Returns true if extname == .sass or .scss, false otherwise.
162
175
  def sass_file?
163
- %w[.sass .scss].include?(ext)
176
+ %w(.sass .scss).include?(ext)
164
177
  end
165
178
 
166
179
  # Determine whether the document is a CoffeeScript file.
@@ -210,8 +223,8 @@ module Jekyll
210
223
 
211
224
  while layout
212
225
  Jekyll.logger.debug "Rendering Layout:", path
213
- payload.content = output
214
- payload.layout = layout.data
226
+ payload["content"] = output
227
+ payload["layout"] = Utils.deep_merge_hashes(payload["layout"] || {}, layout.data)
215
228
 
216
229
  self.output = render_liquid(layout.content,
217
230
  payload,
@@ -236,7 +249,7 @@ module Jekyll
236
249
 
237
250
  # Add any necessary layouts to this convertible document.
238
251
  #
239
- # payload - The site payload Hash.
252
+ # payload - The site payload Drop or Hash.
240
253
  # layouts - A Hash of {"name" => "layout"}.
241
254
  #
242
255
  # Returns nothing.
@@ -245,11 +258,11 @@ module Jekyll
245
258
 
246
259
  Jekyll.logger.debug "Pre-Render Hooks:", self.relative_path
247
260
  Jekyll::Hooks.trigger hook_owner, :pre_render, self, payload
248
- info = { :filters => [Jekyll::Filters], :registers => { :site => site, :page => payload.page } }
261
+ info = { :filters => [Jekyll::Filters], :registers => { :site => site, :page => payload["page"] } }
249
262
 
250
263
  # render and transform content (this becomes the final content of the object)
251
- payload.highlighter_prefix = converters.first.highlighter_prefix
252
- payload.highlighter_suffix = converters.first.highlighter_suffix
264
+ payload["highlighter_prefix"] = converters.first.highlighter_prefix
265
+ payload["highlighter_suffix"] = converters.first.highlighter_suffix
253
266
 
254
267
  if render_with_liquid?
255
268
  Jekyll.logger.debug "Rendering Liquid:", self.relative_path
@@ -21,7 +21,7 @@ module Jekyll
21
21
  end
22
22
 
23
23
  def no_subcommand(args)
24
- if args.size > 0 && args.first =~ /^--/ && !%w[--help --version].include?(args.first)
24
+ if args.size > 0 && args.first =~ /^--/ && !%w(--help --version).include?(args.first)
25
25
  deprecation_message "Jekyll now uses subcommands instead of just switches. Run `jekyll --help` to find out more."
26
26
  abort
27
27
  end
@@ -4,7 +4,8 @@ module Jekyll
4
4
  class Document
5
5
  include Comparable
6
6
 
7
- attr_reader :path, :site, :extname, :output_ext, :content, :output, :collection
7
+ attr_reader :path, :site, :extname, :collection
8
+ attr_accessor :content, :output
8
9
 
9
10
  YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
10
11
  DATELESS_FILENAME_MATCHER = /^(.*)(\.[^.]+)$/
@@ -22,7 +23,6 @@ module Jekyll
22
23
  @site = relations[:site]
23
24
  @path = path
24
25
  @extname = File.extname(path)
25
- @output_ext = Jekyll::Renderer.new(site, self).output_ext
26
26
  @collection = relations[:collection]
27
27
  @has_yaml_header = nil
28
28
 
@@ -32,27 +32,19 @@ module Jekyll
32
32
  categories_from_path(collection.relative_directory)
33
33
  end
34
34
 
35
- data.default_proc = proc do |hash, key|
35
+ data.default_proc = proc do |_, key|
36
36
  site.frontmatter_defaults.find(relative_path, collection.label, key)
37
37
  end
38
38
 
39
39
  trigger_hooks(:post_init)
40
40
  end
41
41
 
42
- def output=(output)
43
- @output = output
44
- end
45
-
46
- def content=(content)
47
- @content = content
48
- end
49
-
50
42
  # Fetch the Document's data.
51
43
  #
52
44
  # Returns a Hash containing the data. An empty hash is returned if
53
45
  # no data was read.
54
46
  def data
55
- @data ||= Hash.new
47
+ @data ||= {}
56
48
  end
57
49
 
58
50
  # Merge some data in with this document's data.
@@ -67,7 +59,7 @@ module Jekyll
67
59
  end
68
60
  Utils.deep_merge_hashes!(data, other)
69
61
  if data.key?('date') && !data['date'].is_a?(Time)
70
- data['date'] = Utils.parse_date(data['date'].to_s, "Document '#{relative_path}' does not have a valid date in the YAML front matter.")
62
+ data['date'] = Utils.parse_date(data['date'].to_s, "Document '#{relative_path}' does not have a valid date in the YAML front matter.")
71
63
  end
72
64
  data
73
65
  end
@@ -93,6 +85,13 @@ module Jekyll
93
85
  @relative_path ||= Pathname.new(path).relative_path_from(Pathname.new(site.source)).to_s
94
86
  end
95
87
 
88
+ # The output extension of the document.
89
+ #
90
+ # Returns the output extension
91
+ def output_ext
92
+ Jekyll::Renderer.new(site, self).output_ext
93
+ end
94
+
96
95
  # The base filename of the document, without the file extname.
97
96
  #
98
97
  # Returns the basename without the file extname.
@@ -120,14 +119,14 @@ module Jekyll
120
119
  # Returns the cleaned relative path of the document.
121
120
  def cleaned_relative_path
122
121
  @cleaned_relative_path ||=
123
- relative_path[0 .. -extname.length - 1].sub(collection.relative_directory, "")
122
+ relative_path[0..-extname.length - 1].sub(collection.relative_directory, "")
124
123
  end
125
124
 
126
125
  # Determine whether the document is a YAML file.
127
126
  #
128
127
  # Returns true if the extname is either .yml or .yaml, false otherwise.
129
128
  def yaml_file?
130
- %w[.yaml .yml].include?(extname)
129
+ %w(.yaml .yml).include?(extname)
131
130
  end
132
131
 
133
132
  # Determine whether the document is an asset file.
@@ -143,7 +142,7 @@ module Jekyll
143
142
  #
144
143
  # Returns true if extname == .sass or .scss, false otherwise.
145
144
  def sass_file?
146
- %w[.sass .scss].include?(extname)
145
+ %w(.sass .scss).include?(extname)
147
146
  end
148
147
 
149
148
  # Determine whether the document is a CoffeeScript file.
@@ -197,9 +196,9 @@ module Jekyll
197
196
  # Returns the computed URL for the document.
198
197
  def url
199
198
  @url = URL.new({
200
- template: url_template,
201
- placeholders: url_placeholders,
202
- permalink: permalink
199
+ :template => url_template,
200
+ :placeholders => url_placeholders,
201
+ :permalink => permalink
203
202
  }).to_s
204
203
  end
205
204
 
@@ -216,7 +215,7 @@ module Jekyll
216
215
  dest = site.in_dest_dir(base_directory)
217
216
  path = site.in_dest_dir(dest, URL.unescape_path(url))
218
217
  path = File.join(path, "index.html") if url.end_with?("/")
219
- path << output_ext unless path.end_with?(output_ext)
218
+ path << output_ext unless path.end_with? output_ext
220
219
  path
221
220
  end
222
221
 
@@ -270,7 +269,7 @@ module Jekyll
270
269
  self.content = File.read(path, merged_file_read_opts(opts))
271
270
  if content =~ YAML_FRONT_MATTER_REGEXP
272
271
  self.content = $POSTMATCH
273
- data_file = SafeYAML.load($1)
272
+ data_file = SafeYAML.load(Regexp.last_match(1))
274
273
  merge_data!(data_file) if data_file
275
274
  end
276
275
 
@@ -285,13 +284,13 @@ module Jekyll
285
284
 
286
285
  def post_read
287
286
  if DATE_FILENAME_MATCHER =~ relative_path
288
- m, cats, date, slug, ext = *relative_path.match(DATE_FILENAME_MATCHER)
287
+ _, _, date, slug, ext = *relative_path.match(DATE_FILENAME_MATCHER)
289
288
  merge_data!({
290
289
  "slug" => slug,
291
290
  "ext" => ext
292
291
  })
293
- merge_data!({"date" => date}) if data['date'].nil? || data['date'].to_i == site.time.to_i
294
- data['title'] ||= slug.split('-').select {|w| w.capitalize! || w }.join(' ')
292
+ merge_data!({ "date" => date }) if data['date'].nil? || data['date'].to_i == site.time.to_i
293
+ data['title'] ||= slug.split('-').select(&:capitalize).join(' ')
295
294
  end
296
295
  populate_categories
297
296
  populate_tags
@@ -317,7 +316,7 @@ module Jekyll
317
316
  merge_data!({
318
317
  'categories' => (
319
318
  Array(data['categories']) + Utils.pluralized_array_from_hash(data, 'category', 'categories')
320
- ).map { |c| c.to_s }.flatten.uniq
319
+ ).map(&:to_s).flatten.uniq
321
320
  })
322
321
  end
323
322
 
@@ -386,7 +385,7 @@ module Jekyll
386
385
  end
387
386
 
388
387
  def next_doc
389
- pos = collection.docs.index {|post| post.equal?(self) }
388
+ pos = collection.docs.index { |post| post.equal?(self) }
390
389
  if pos && pos < collection.docs.length - 1
391
390
  collection.docs[pos + 1]
392
391
  else
@@ -395,7 +394,7 @@ module Jekyll
395
394
  end
396
395
 
397
396
  def previous_doc
398
- pos = collection.docs.index {|post| post.equal?(self) }
397
+ pos = collection.docs.index { |post| post.equal?(self) }
399
398
  if pos && pos > 0
400
399
  collection.docs[pos - 1]
401
400
  else
@@ -1,5 +1,4 @@
1
1
  # encoding: UTF-8
2
- require "jekyll/drops/drop"
3
2
 
4
3
  module Jekyll
5
4
  module Drops
@@ -18,7 +17,6 @@ module Jekyll
18
17
 
19
18
  private
20
19
  def_delegator :@obj, :metadata, :fallback_data
21
-
22
20
  end
23
21
  end
24
22
  end
@@ -22,7 +22,6 @@ module Jekyll
22
22
 
23
23
  private
24
24
  def_delegator :@obj, :data, :fallback_data
25
-
26
25
  end
27
26
  end
28
27
  end