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
@@ -1,7 +1,7 @@
1
1
  module Jekyll
2
2
  class StaticFile
3
3
  # The cache of last modification times [path] -> mtime.
4
- @@mtimes = Hash.new
4
+ @@mtimes = {}
5
5
 
6
6
  attr_reader :relative_path, :extname
7
7
 
@@ -75,7 +75,7 @@ module Jekyll
75
75
  def write(dest)
76
76
  dest_path = destination(dest)
77
77
 
78
- return false if File.exist?(dest_path) and !modified?
78
+ return false if File.exist?(dest_path) && !modified?
79
79
  @@mtimes[path] = mtime
80
80
 
81
81
  FileUtils.mkdir_p(File.dirname(dest_path))
@@ -90,7 +90,7 @@ module Jekyll
90
90
  #
91
91
  # Returns nothing.
92
92
  def self.reset_cache
93
- @@mtimes = Hash.new
93
+ @@mtimes = {}
94
94
  nil
95
95
  end
96
96
 
@@ -104,12 +104,12 @@ module Jekyll
104
104
 
105
105
  def placeholders
106
106
  {
107
- collection: @collection.label,
108
- path: relative_path[
107
+ :collection => @collection.label,
108
+ :path => relative_path[
109
109
  @collection.relative_directory.size..relative_path.size],
110
- output_ext: '',
111
- name: '',
112
- title: '',
110
+ :output_ext => '',
111
+ :name => '',
112
+ :title => ''
113
113
  }
114
114
  end
115
115
 
@@ -118,13 +118,13 @@ module Jekyll
118
118
  # be overriden in the collection's configuration in _config.yml.
119
119
  def url
120
120
  @url ||= if @collection.nil?
121
- relative_path
122
- else
123
- ::Jekyll::URL.new({
124
- template: @collection.url_template,
125
- placeholders: placeholders,
126
- })
127
- end.to_s.gsub /\/$/, ''
121
+ relative_path
122
+ else
123
+ ::Jekyll::URL.new({
124
+ :template => @collection.url_template,
125
+ :placeholders => placeholders
126
+ })
127
+ end.to_s.gsub(/\/$/, '')
128
128
  end
129
129
 
130
130
  # Returns the type of the collection if present, nil otherwise.
@@ -5,7 +5,7 @@ module Jekyll
5
5
  @level = DEBUG
6
6
  @default_formatter = Formatter.new
7
7
  @logdev = $stdout
8
- @formatter = proc do |severity, datetime, progname, msg|
8
+ @formatter = proc do |_, _, _, msg|
9
9
  "#{msg}"
10
10
  end
11
11
  end
@@ -14,7 +14,7 @@ module Jekyll
14
14
  severity ||= UNKNOWN
15
15
  @logdev = set_logdevice(severity)
16
16
 
17
- if @logdev.nil? or severity < @level
17
+ if @logdev.nil? || severity < @level
18
18
  return true
19
19
  end
20
20
  progname ||= @progname
@@ -13,21 +13,21 @@ module Jekyll
13
13
  def initialize(tag_name, markup, tokens)
14
14
  super
15
15
  if markup.strip =~ SYNTAX
16
- @lang = $1.downcase
16
+ @lang = Regexp.last_match(1).downcase
17
17
  @highlight_options = {}
18
- if defined?($2) && $2 != ''
18
+ if defined?(Regexp.last_match(2)) && Regexp.last_match(2) != ''
19
19
  # Split along 3 possible forms -- key="<quoted list>", key=value, or key
20
- $2.scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt|
20
+ Regexp.last_match(2).scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt|
21
21
  key, value = opt.split('=')
22
22
  # If a quoted list, convert to array
23
23
  if value && value.include?("\"")
24
- value.gsub!(/"/, "")
24
+ value.delete!('"')
25
25
  value = value.split
26
26
  end
27
27
  @highlight_options[key.to_sym] = value || true
28
28
  end
29
29
  end
30
- @highlight_options[:linenos] = "inline" if @highlight_options.key?(:linenos) and @highlight_options[:linenos] == true
30
+ @highlight_options[:linenos] = "inline" if @highlight_options.key?(:linenos) && @highlight_options[:linenos] == true
31
31
  else
32
32
  raise SyntaxError.new <<-eos
33
33
  Syntax Error in tag 'highlight' while parsing the following markup:
@@ -68,7 +68,7 @@ eos
68
68
  [:linenos, opts.fetch(:linenos, nil)],
69
69
  [:encoding, opts.fetch(:encoding, 'utf-8')],
70
70
  [:cssclass, opts.fetch(:cssclass, nil)]
71
- ].reject {|f| f.last.nil? }]
71
+ ].reject { |f| f.last.nil? }]
72
72
  else
73
73
  opts
74
74
  end
@@ -88,7 +88,7 @@ eos
88
88
  puts
89
89
  Jekyll.logger.error code
90
90
  puts
91
- Jekyll.logger.error "While attempting to convert the above code, Pygments.rb" +
91
+ Jekyll.logger.error "While attempting to convert the above code, Pygments.rb" \
92
92
  " returned an unacceptable value."
93
93
  Jekyll.logger.error "This is usually a timeout problem solved by running `jekyll build` again."
94
94
  raise ArgumentError.new("Pygments.rb returned an unacceptable value when attempting to highlight some code.")
@@ -99,7 +99,7 @@ eos
99
99
 
100
100
  def render_rouge(code)
101
101
  Jekyll::External.require_with_graceful_fail('rouge')
102
- formatter = Rouge::Formatters::HTML.new(line_numbers: @highlight_options[:linenos], wrap: false)
102
+ formatter = Rouge::Formatters::HTML.new(:line_numbers => @highlight_options[:linenos], :wrap => false)
103
103
  lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText
104
104
  formatter.format(lexer.lex(code))
105
105
  end
@@ -110,12 +110,11 @@ eos
110
110
 
111
111
  def add_code_tag(code)
112
112
  code_attributes = [
113
- "class=\"language-#{@lang.to_s.gsub('+', '-')}\"",
114
- "data-lang=\"#{@lang.to_s}\""
113
+ "class=\"language-#{@lang.to_s.tr('+', '-')}\"",
114
+ "data-lang=\"#{@lang}\""
115
115
  ].join(" ")
116
116
  "<figure class=\"highlight\"><pre><code #{code_attributes}>#{code.chomp}</code></pre></figure>"
117
117
  end
118
-
119
118
  end
120
119
  end
121
120
  end
@@ -12,7 +12,6 @@ module Jekyll
12
12
  end
13
13
 
14
14
  class IncludeTag < Liquid::Tag
15
-
16
15
  attr_reader :includes_dir
17
16
 
18
17
  VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/
@@ -25,7 +24,7 @@ module Jekyll
25
24
  @file = matched['variable'].strip
26
25
  @params = matched['params'].strip
27
26
  else
28
- @file, @params = markup.strip.split(' ', 2);
27
+ @file, @params = markup.strip.split(' ', 2)
29
28
  end
30
29
  validate_params if @params
31
30
  @tag_name = tag_name
@@ -43,12 +42,12 @@ module Jekyll
43
42
  markup = markup[match.end(0)..-1]
44
43
 
45
44
  value = if match[2]
46
- match[2].gsub(/\\"/, '"')
47
- elsif match[3]
48
- match[3].gsub(/\\'/, "'")
49
- elsif match[4]
50
- context[match[4]]
51
- end
45
+ match[2].gsub(/\\"/, '"')
46
+ elsif match[3]
47
+ match[3].gsub(/\\'/, "'")
48
+ elsif match[4]
49
+ context[match[4]]
50
+ end
52
51
 
53
52
  params[match[1]] = value
54
53
  end
@@ -57,7 +56,7 @@ module Jekyll
57
56
 
58
57
  def validate_file_name(file)
59
58
  if file !~ /^[a-zA-Z0-9_\/\.-]+$/ || file =~ /\.\// || file =~ /\/\./
60
- raise ArgumentError.new <<-eos
59
+ raise ArgumentError.new <<-eos
61
60
  Invalid syntax for include tag. File contains invalid characters or sequences:
62
61
 
63
62
  #{file}
@@ -115,7 +114,7 @@ eos
115
114
  validate_path(path, dir, site.safe)
116
115
 
117
116
  # Add include to dependency tree
118
- if context.registers[:page] and context.registers[:page].has_key? "path"
117
+ if context.registers[:page] && context.registers[:page].key?("path")
119
118
  site.regenerator.add_dependency(
120
119
  site.in_source_dir(context.registers[:page]["path"]),
121
120
  path
@@ -138,7 +137,7 @@ eos
138
137
  context.registers[:cached_partials] ||= {}
139
138
  cached_partial = context.registers[:cached_partials]
140
139
 
141
- if cached_partial.has_key?(path)
140
+ if cached_partial.key?(path)
142
141
  cached_partial[path]
143
142
  else
144
143
  cached_partial[path] = context.registers[:site].liquid_renderer.file(path).parse(read_file(path, context))
@@ -60,22 +60,19 @@ eos
60
60
  site = context.registers[:site]
61
61
 
62
62
  site.posts.docs.each do |p|
63
- if @post == p
64
- return p.url
65
- end
63
+ return p.url if @post == p
66
64
  end
67
65
 
68
66
  # New matching method did not match, fall back to old method
69
67
  # with deprecation warning if this matches
70
68
 
71
69
  site.posts.docs.each do |p|
72
- if @post.deprecated_equality p
73
- Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " +
74
- "a post using the new matching method of checking name " +
75
- "(path-date-slug) equality. Please make sure that you " +
76
- "change this tag to match the post's name exactly."
77
- return p.url
78
- end
70
+ next unless @post.deprecated_equality p
71
+ Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " \
72
+ "a post using the new matching method of checking name " \
73
+ "(path-date-slug) equality. Please make sure that you " \
74
+ "change this tag to match the post's name exactly."
75
+ return p.url
79
76
  end
80
77
 
81
78
  raise ArgumentError.new <<-eos
@@ -11,7 +11,6 @@ require 'uri'
11
11
  #
12
12
  module Jekyll
13
13
  class URL
14
-
15
14
  # options - One of :permalink or :template must be supplied.
16
15
  # :template - The String used as template for URL generation,
17
16
  # for example "/:path/:basename:output_ext", where
@@ -79,21 +78,21 @@ module Jekyll
79
78
  end
80
79
 
81
80
  def generate_url_from_drop(template)
82
- template.gsub(/:([a-z_]+)/) do |match|
83
- replacement = @placeholders.public_send(match.sub(':', ''))
81
+ template.gsub(/:([a-z_]+)/.freeze) do |match|
82
+ replacement = @placeholders.public_send(match.sub(':'.freeze, ''.freeze))
84
83
  if replacement.nil?
85
84
  ''.freeze
86
85
  else
87
86
  self.class.escape_path(replacement)
88
87
  end
89
- end.gsub(/\/\//, '/')
88
+ end.gsub(/\/\//.freeze, '/'.freeze)
90
89
  end
91
90
 
92
91
  # Returns a sanitized String URL, stripping "../../" and multiples of "/",
93
92
  # as well as the beginning "/" so we can enforce and ensure it.
94
93
 
95
94
  def sanitize_url(str)
96
- "/" + str.gsub(/\/{2,}/, "/").gsub(%r!\.+\/|\A/+!, "")
95
+ "/" + str.gsub(/\/{2,}/, "/").gsub(/\.+\/|\A\/+/, "")
97
96
  end
98
97
 
99
98
  # Escapes a path to be a valid URL path segment
@@ -1,10 +1,11 @@
1
1
  module Jekyll
2
- module Utils extend self
2
+ module Utils
3
+ extend self
3
4
  autoload :Platforms, 'jekyll/utils/platforms'
4
5
  autoload :Ansi, "jekyll/utils/ansi"
5
6
 
6
7
  # Constants for use in #slugify
7
- SLUGIFY_MODES = %w{raw default pretty}
8
+ SLUGIFY_MODES = %w(raw default pretty)
8
9
  SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
9
10
  SLUGIFY_DEFAULT_REGEXP = Regexp.new('[^[:alnum:]]+').freeze
10
11
  SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
@@ -30,14 +31,12 @@ module Jekyll
30
31
  #
31
32
  # Thanks to whoever made it.
32
33
  def deep_merge_hashes!(target, overwrite)
33
- overwrite.each_key do |key|
34
- if (overwrite[key].is_a?(Hash) or overwrite[key].is_a?(Drops::Drop)) and
35
- (target[key].is_a?(Hash) or target[key].is_a?(Drops::Drop))
36
- target[key] = Utils.deep_merge_hashes(target[key], overwrite[key])
37
- next
34
+ target.merge!(overwrite) do |key, old_val, new_val|
35
+ if new_val.nil?
36
+ old_val
37
+ else
38
+ mergable?(old_val) && mergable?(new_val) ? deep_merge_hashes(old_val, new_val) : new_val
38
39
  end
39
-
40
- target[key] = overwrite[key]
41
40
  end
42
41
 
43
42
  if target.respond_to?(:default_proc) && overwrite.respond_to?(:default_proc) && target.default_proc.nil?
@@ -47,6 +46,10 @@ module Jekyll
47
46
  target
48
47
  end
49
48
 
49
+ def mergable?(value)
50
+ value.is_a?(Hash) || value.is_a?(Drops::Drop)
51
+ end
52
+
50
53
  # Read array from the supplied hash favouring the singular key
51
54
  # and then the plural key, and handling any nil entries.
52
55
  #
@@ -62,7 +65,7 @@ module Jekyll
62
65
  end
63
66
 
64
67
  def value_from_singular_key(hash, key)
65
- hash[key] if (hash.key?(key) || (hash.default_proc && hash[key]))
68
+ hash[key] if hash.key?(key) || (hash.default_proc && hash[key])
66
69
  end
67
70
 
68
71
  def value_from_plural_key(hash, key)
@@ -120,7 +123,9 @@ module Jekyll
120
123
  #
121
124
  # Returns true if the YAML front matter is present.
122
125
  def has_yaml_header?(file)
123
- !!(File.open(file, 'rb') { |f| f.read(5) } =~ /\A---\r?\n/)
126
+ !!(File.open(file, 'rb') { |f| f.readline } =~ /\A---\s*\r?\n/)
127
+ rescue EOFError
128
+ false
124
129
  end
125
130
 
126
131
  # Slugify a filename or title.
@@ -164,16 +169,17 @@ module Jekyll
164
169
  end
165
170
 
166
171
  # Replace each character sequence with a hyphen
167
- re = case mode
168
- when 'raw'
169
- SLUGIFY_RAW_REGEXP
170
- when 'default'
171
- SLUGIFY_DEFAULT_REGEXP
172
- when 'pretty'
173
- # "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL
174
- # and is allowed in both extN and NTFS.
175
- SLUGIFY_PRETTY_REGEXP
176
- end
172
+ re =
173
+ case mode
174
+ when 'raw'
175
+ SLUGIFY_RAW_REGEXP
176
+ when 'default'
177
+ SLUGIFY_DEFAULT_REGEXP
178
+ when 'pretty'
179
+ # "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL
180
+ # and is allowed in both extN and NTFS.
181
+ SLUGIFY_PRETTY_REGEXP
182
+ end
177
183
 
178
184
  # Strip according to the mode
179
185
  slug = string.gsub(re, '-')
@@ -225,7 +231,6 @@ module Jekyll
225
231
  template
226
232
  end
227
233
 
228
-
229
234
  # Work the same way as Dir.glob but seperating the input into two parts
230
235
  # ('dir' + '/' + 'pattern') to make sure the first part('dir') does not act
231
236
  # as a pattern.
@@ -33,7 +33,7 @@ module Jekyll
33
33
  def has?(str)
34
34
  !!(str =~ MATCH)
35
35
  end
36
-
36
+
37
37
  # Reset the color back to the default color so that you do not leak any
38
38
  # colors when you move onto the next line. This is probably normally
39
39
  # used as part of a wrapper so that we don't leak colors.
@@ -19,7 +19,6 @@ module Jekyll
19
19
 
20
20
  { :windows? => /mswin|mingw|cygwin/, :linux? => /linux/, \
21
21
  :osx? => /darwin|mac os/, :unix? => /solaris|bsd/ }.each do |k, v|
22
-
23
22
  define_method k do
24
23
  !!(
25
24
  RbConfig::CONFIG["host_os"] =~ v
@@ -1,3 +1,3 @@
1
1
  module Jekyll
2
- VERSION = '3.1.0.pre.beta1'
2
+ VERSION = '3.1.0.pre.rc1'
3
3
  end
@@ -3,7 +3,7 @@
3
3
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1">
5
5
 
6
- <title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
6
+ <title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
7
7
  <meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
8
8
 
9
9
  <link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.pre.beta1
4
+ version: 3.1.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-27 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -152,6 +152,7 @@ files:
152
152
  - lib/jekyll/converters/markdown/kramdown_parser.rb
153
153
  - lib/jekyll/converters/markdown/rdiscount_parser.rb
154
154
  - lib/jekyll/converters/markdown/redcarpet_parser.rb
155
+ - lib/jekyll/converters/smartypants.rb
155
156
  - lib/jekyll/convertible.rb
156
157
  - lib/jekyll/deprecator.rb
157
158
  - lib/jekyll/document.rb
@@ -243,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
244
  version: 1.3.1
244
245
  requirements: []
245
246
  rubyforge_project:
246
- rubygems_version: 2.2.5
247
+ rubygems_version: 2.5.1
247
248
  signing_key:
248
249
  specification_version: 2
249
250
  summary: A simple, blog aware, static site generator.