jekyll 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +48 -19
  3. data/lib/jekyll.rb +3 -0
  4. data/lib/jekyll/collection.rb +1 -1
  5. data/lib/jekyll/command.rb +4 -2
  6. data/lib/jekyll/commands/new.rb +2 -2
  7. data/lib/jekyll/commands/serve.rb +9 -1
  8. data/lib/jekyll/configuration.rb +1 -1
  9. data/lib/jekyll/converters/identity.rb +2 -2
  10. data/lib/jekyll/converters/markdown/kramdown_parser.rb +70 -1
  11. data/lib/jekyll/convertible.rb +15 -15
  12. data/lib/jekyll/document.rb +18 -4
  13. data/lib/jekyll/drops/document_drop.rb +12 -0
  14. data/lib/jekyll/drops/page_drop.rb +18 -0
  15. data/lib/jekyll/drops/url_drop.rb +8 -0
  16. data/lib/jekyll/entry_filter.rb +19 -6
  17. data/lib/jekyll/excerpt.rb +1 -1
  18. data/lib/jekyll/filters.rb +99 -14
  19. data/lib/jekyll/filters/url_filters.rb +41 -14
  20. data/lib/jekyll/frontmatter_defaults.rb +12 -17
  21. data/lib/jekyll/hooks.rb +2 -5
  22. data/lib/jekyll/inclusion.rb +32 -0
  23. data/lib/jekyll/liquid_renderer.rb +18 -15
  24. data/lib/jekyll/liquid_renderer/table.rb +1 -21
  25. data/lib/jekyll/page.rb +43 -0
  26. data/lib/jekyll/page_excerpt.rb +26 -0
  27. data/lib/jekyll/profiler.rb +58 -0
  28. data/lib/jekyll/readers/collection_reader.rb +1 -0
  29. data/lib/jekyll/readers/data_reader.rb +1 -0
  30. data/lib/jekyll/readers/layout_reader.rb +1 -0
  31. data/lib/jekyll/readers/page_reader.rb +1 -0
  32. data/lib/jekyll/readers/post_reader.rb +1 -0
  33. data/lib/jekyll/readers/static_file_reader.rb +1 -0
  34. data/lib/jekyll/readers/theme_assets_reader.rb +1 -0
  35. data/lib/jekyll/renderer.rb +9 -15
  36. data/lib/jekyll/site.rb +14 -5
  37. data/lib/jekyll/static_file.rb +14 -9
  38. data/lib/jekyll/tags/include.rb +58 -3
  39. data/lib/jekyll/theme.rb +6 -0
  40. data/lib/jekyll/utils.rb +4 -4
  41. data/lib/jekyll/utils/win_tz.rb +1 -1
  42. data/lib/jekyll/version.rb +1 -1
  43. data/lib/theme_template/theme.gemspec.erb +1 -4
  44. metadata +14 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0562e1d33bdfbe9a42636335c4f4d9c9da442ec3887886536f888720c9a87b9b
4
- data.tar.gz: 8561a49dec1141a1b7c111939a8220113d5e01e51605f0eba76536ab06b265c7
3
+ metadata.gz: 8de141f536d43289d9c0f6dcea9282eca345760cb15208d11971128f0e9c9b23
4
+ data.tar.gz: d3f2ed7b92cc8a96b1c56c183912247d60399fb13bf899b874093797d1b8c574
5
5
  SHA512:
6
- metadata.gz: fbccdaab958f04e2175e8b224b5495fcf5a55703a559e9f1f96b7821601f28b0db0545a96f4119314274751051ec300f1121ec0d0988a203c2cc99de37b71325
7
- data.tar.gz: afa55cd05bcabfb2a3749c6ed0968039742068c440132ce786b6d2b3ab89458deba2652ec8363b686891c403d127e5177fe296acd85808eaf45f6bf58a934978
6
+ metadata.gz: 188a24d699ba093c3a55048cacb969158cb027a4df37cdc62bd31c22dd8223c8c8b138a190b5eaee85fb811be771fa3e8256bde4b1c8f6fdfbac8a69dbc221c4
7
+ data.tar.gz: d2eb7caccefdaebfeec3cce77f749d4ade2d463eb39d85ab9f3fe9a54afadc193fcfc7218692124e217843443f0ae9b0a3ee71a9ffb6ececc245fc063c370f1e
@@ -1,4 +1,5 @@
1
1
  ---
2
+ inherit_from: .rubocop_todo.yml
2
3
 
3
4
  require:
4
5
  - rubocop-performance
@@ -20,30 +21,51 @@ AllCops:
20
21
  - script/**/*
21
22
  - vendor/**/*
22
23
  - tmp/**/*
23
- Layout/AlignHash:
24
+
25
+ Layout/EmptyComment:
26
+ Enabled: false
27
+ Layout/EmptyLinesAroundAttributeAccessor:
28
+ Enabled: true
29
+ Layout/EndAlignment:
30
+ Severity: error
31
+ Layout/HashAlignment:
24
32
  EnforcedHashRocketStyle: table
25
33
  Layout/IndentationWidth:
26
34
  Severity: error
27
- Layout/IndentFirstArrayElement:
35
+ Layout/FirstArrayElementIndentation:
28
36
  EnforcedStyle: consistent
29
- Layout/IndentFirstHashElement:
37
+ Layout/FirstHashElementIndentation:
30
38
  EnforcedStyle: consistent
39
+ Layout/LineLength:
40
+ Exclude:
41
+ - !ruby/regexp /features\/.*.rb/
42
+ - Rakefile
43
+ - rake/*.rake
44
+ - Gemfile
45
+ Max: 100
46
+ Severity: warning
31
47
  Layout/MultilineMethodCallIndentation:
32
48
  EnforcedStyle: indented
33
49
  Layout/MultilineOperationIndentation:
34
50
  EnforcedStyle: indented
51
+ Layout/SpaceAroundMethodCallOperator:
52
+ Enabled: true
53
+
35
54
  Lint/NestedPercentLiteral:
36
55
  Exclude:
37
56
  - test/test_site.rb
38
- Layout/EmptyComment:
39
- Enabled: false
40
- Layout/EndAlignment:
41
- Severity: error
57
+ Lint/DeprecatedOpenSSLConstant:
58
+ Enabled: true
59
+ Lint/RaiseException:
60
+ Enabled: true
61
+ Lint/StructNewOverride:
62
+ Enabled: true
42
63
  Lint/UnreachableCode:
43
64
  Severity: error
44
65
  Lint/Void:
45
66
  Exclude:
46
67
  - lib/jekyll/site.rb
68
+
47
69
  Metrics/AbcSize:
48
70
  Max: 21
49
71
  Metrics/BlockLength:
@@ -64,24 +86,19 @@ Metrics/CyclomaticComplexity:
64
86
  Exclude:
65
87
  - lib/jekyll/utils.rb
66
88
  - lib/jekyll/commands/serve.rb
67
- Metrics/LineLength:
68
- Exclude:
69
- - !ruby/regexp /features\/.*.rb/
70
- - Rakefile
71
- - rake/*.rake
72
- - Gemfile
73
- Max: 100
74
- Severity: warning
75
89
  Metrics/MethodLength:
76
90
  CountComments: false
77
91
  Max: 20
78
92
  Severity: error
79
93
  Metrics/ModuleLength:
80
94
  Max: 240
95
+ Exclude:
96
+ - lib/jekyll/filters.rb
81
97
  Metrics/ParameterLists:
82
98
  Max: 4
83
99
  Metrics/PerceivedComplexity:
84
100
  Max: 8
101
+
85
102
  Naming/FileName:
86
103
  Enabled: false
87
104
  Naming/HeredocDelimiterNaming:
@@ -93,6 +110,7 @@ Naming/MemoizedInstanceVariableName:
93
110
  - lib/jekyll/drops/site_drop.rb
94
111
  - lib/jekyll/drops/unified_payload_drop.rb
95
112
  - lib/jekyll/page_without_a_file.rb
113
+
96
114
  Security/MarshalLoad:
97
115
  Exclude:
98
116
  - !ruby/regexp /test\/.*.rb$/
@@ -101,31 +119,40 @@ Security/YAMLLoad:
101
119
  Exclude:
102
120
  - !ruby/regexp /features\/.*.rb/
103
121
  - !ruby/regexp /test\/.*.rb$/
122
+
104
123
  Style/AccessModifierDeclarations:
105
124
  Enabled: false
106
125
  Style/Alias:
107
126
  EnforcedStyle: prefer_alias_method
108
127
  Style/AndOr:
109
128
  Severity: error
110
- Style/BracesAroundHashParameters:
111
- Enabled: false
112
129
  Style/ClassAndModuleChildren:
113
130
  Exclude:
114
131
  - test/**/*.rb
115
- Style/FrozenStringLiteralComment:
116
- EnforcedStyle: always
117
132
  Style/Documentation:
118
133
  Enabled: false
119
134
  Style/DoubleNegation:
120
135
  Enabled: false
136
+ Style/ExponentialNotation:
137
+ Enabled: true
121
138
  Style/FormatStringToken:
122
139
  Exclude:
123
140
  - lib/jekyll/utils/ansi.rb
141
+ - lib/jekyll/liquid_renderer/table.rb
142
+ - lib/jekyll/profiler.rb
143
+ Style/FrozenStringLiteralComment:
144
+ EnforcedStyle: always
124
145
  Style/GuardClause:
125
146
  Enabled: false
147
+ Style/HashEachMethods:
148
+ Enabled: true
126
149
  Style/HashSyntax:
127
150
  EnforcedStyle: hash_rockets
128
151
  Severity: error
152
+ Style/HashTransformKeys:
153
+ Enabled: false
154
+ Style/HashTransformValues:
155
+ Enabled: true
129
156
  Style/MixinUsage:
130
157
  Exclude:
131
158
  - test/helper.rb
@@ -151,6 +178,8 @@ Style/SafeNavigation:
151
178
  - lib/jekyll/document.rb
152
179
  Style/SignalException:
153
180
  EnforcedStyle: only_raise
181
+ Style/SlicingWithRange:
182
+ Enabled: false
154
183
  Style/StringLiterals:
155
184
  EnforcedStyle: double_quotes
156
185
  Style/StringLiteralsInInterpolation:
@@ -50,10 +50,12 @@ module Jekyll
50
50
  autoload :EntryFilter, "jekyll/entry_filter"
51
51
  autoload :Errors, "jekyll/errors"
52
52
  autoload :Excerpt, "jekyll/excerpt"
53
+ autoload :PageExcerpt, "jekyll/page_excerpt"
53
54
  autoload :External, "jekyll/external"
54
55
  autoload :FrontmatterDefaults, "jekyll/frontmatter_defaults"
55
56
  autoload :Hooks, "jekyll/hooks"
56
57
  autoload :Layout, "jekyll/layout"
58
+ autoload :Inclusion, "jekyll/inclusion"
57
59
  autoload :Cache, "jekyll/cache"
58
60
  autoload :CollectionReader, "jekyll/readers/collection_reader"
59
61
  autoload :DataReader, "jekyll/readers/data_reader"
@@ -68,6 +70,7 @@ module Jekyll
68
70
  autoload :PathManager, "jekyll/path_manager"
69
71
  autoload :PluginManager, "jekyll/plugin_manager"
70
72
  autoload :Publisher, "jekyll/publisher"
73
+ autoload :Profiler, "jekyll/profiler"
71
74
  autoload :Reader, "jekyll/reader"
72
75
  autoload :Regenerator, "jekyll/regenerator"
73
76
  autoload :RelatedPosts, "jekyll/related_posts"
@@ -239,7 +239,7 @@ module Jekyll
239
239
 
240
240
  # Fall back to `Document#<=>` if the properties were equal or were non-sortable
241
241
  # Otherwise continue with current sort-order
242
- if order.zero? || order.nil?
242
+ if order.nil? || order.zero?
243
243
  apples[-1] <=> olives[-1]
244
244
  else
245
245
  order
@@ -67,6 +67,8 @@ module Jekyll
67
67
  cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
68
68
  cmd.option "unpublished", "--unpublished",
69
69
  "Render posts that were marked as unpublished"
70
+ cmd.option "disable_disk_cache", "--disable-disk-cache",
71
+ "Disable caching to disk in non-safe mode"
70
72
  cmd.option "quiet", "-q", "--quiet", "Silence output."
71
73
  cmd.option "verbose", "-V", "--verbose", "Print verbose output."
72
74
  cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
@@ -84,7 +86,7 @@ module Jekyll
84
86
  # klass - an array of Jekyll::Command subclasses associated with the command
85
87
  #
86
88
  # Note that all exceptions are rescued..
87
- # rubocop: disable RescueException
89
+ # rubocop: disable Lint/RescueException
88
90
  def process_with_graceful_fail(cmd, options, *klass)
89
91
  klass.each { |k| k.process(options) if k.respond_to?(:process) }
90
92
  rescue Exception => e
@@ -97,7 +99,7 @@ module Jekyll
97
99
  Jekyll.logger.error "", " for any additional information or backtrace. "
98
100
  Jekyll.logger.abort_with "", dashes
99
101
  end
100
- # rubocop: enable RescueException
102
+ # rubocop: enable Lint/RescueException
101
103
  end
102
104
  end
103
105
  end
@@ -91,13 +91,13 @@ module Jekyll
91
91
 
92
92
  # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
93
93
  # and associated library.
94
- install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
94
+ platforms :mingw, :x64_mingw, :mswin, :jruby do
95
95
  gem "tzinfo", "~> 1.2"
96
96
  gem "tzinfo-data"
97
97
  end
98
98
 
99
99
  # Performance-booster for watching directories on Windows
100
- gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform?
100
+ gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
101
101
 
102
102
  RUBY
103
103
  end
@@ -307,7 +307,15 @@ module Jekyll
307
307
  require "webrick/https"
308
308
 
309
309
  opts[:SSLCertificate] = OpenSSL::X509::Certificate.new(read_file(src, cert))
310
- opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(read_file(src, key))
310
+ begin
311
+ opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(read_file(src, key))
312
+ rescue StandardError
313
+ if defined?(OpenSSL::PKey::EC)
314
+ opts[:SSLPrivateKey] = OpenSSL::PKey::EC.new(read_file(src, key))
315
+ else
316
+ raise
317
+ end
318
+ end
311
319
  opts[:SSLEnable] = true
312
320
  end
313
321
 
@@ -66,7 +66,7 @@ module Jekyll
66
66
 
67
67
  "kramdown" => {
68
68
  "auto_ids" => true,
69
- "toc_levels" => "1..6",
69
+ "toc_levels" => (1..6).to_a,
70
70
  "entity_output" => "as_char",
71
71
  "smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
72
72
  "input" => "GFM",
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Jekyll
4
4
  module Converters
5
- # Identify converter. Returns same content as given.
5
+ # Identity converter. Returns same content as given.
6
6
  # For more info on converters see https://jekyllrb.com/docs/plugins/converters/
7
7
  class Identity < Converter
8
8
  safe true
@@ -12,7 +12,7 @@ module Jekyll
12
12
  # Public: Does the given extension match this converter's list of acceptable extensions?
13
13
  # Takes one argument: the file's extension (including the dot).
14
14
  #
15
- # ext - The String extension to check (not relevant here)
15
+ # _ext - The String extension to check (not relevant here)
16
16
  #
17
17
  # Returns true since it always matches.
18
18
  def matches(_ext)
@@ -1,5 +1,73 @@
1
1
  # Frozen-string-literal: true
2
2
 
3
+ module Kramdown
4
+ # A Kramdown::Document subclass meant to optimize memory usage from initializing
5
+ # a kramdown document for parsing.
6
+ #
7
+ # The optimization is by using the same options Hash (and its derivatives) for
8
+ # converting all Markdown documents in a Jekyll site.
9
+ class JekyllDocument < Document
10
+ class << self
11
+ attr_reader :options, :parser
12
+
13
+ # The implementation is basically the core logic in +Kramdown::Document#initialize+
14
+ #
15
+ # rubocop:disable Naming/MemoizedInstanceVariableName
16
+ def setup(options)
17
+ @cache ||= {}
18
+
19
+ # reset variables on a subsequent set up with a different options Hash
20
+ unless @cache[:id] == options.hash
21
+ @options = @parser = nil
22
+ @cache[:id] = options.hash
23
+ end
24
+
25
+ @options ||= Options.merge(options).freeze
26
+ @parser ||= begin
27
+ parser_name = (@options[:input] || "kramdown").to_s
28
+ parser_name = parser_name[0..0].upcase + parser_name[1..-1]
29
+ try_require("parser", parser_name)
30
+
31
+ if Parser.const_defined?(parser_name)
32
+ Parser.const_get(parser_name)
33
+ else
34
+ raise Kramdown::Error, "kramdown has no parser to handle the specified " \
35
+ "input format: #{@options[:input]}"
36
+ end
37
+ end
38
+ end
39
+ # rubocop:enable Naming/MemoizedInstanceVariableName
40
+
41
+ private
42
+
43
+ def try_require(type, name)
44
+ require "kramdown/#{type}/#{Utils.snake_case(name)}"
45
+ rescue LoadError
46
+ false
47
+ end
48
+ end
49
+
50
+ def initialize(source, options = {})
51
+ JekyllDocument.setup(options)
52
+
53
+ @options = JekyllDocument.options
54
+ @root, @warnings = JekyllDocument.parser.parse(source, @options)
55
+ end
56
+
57
+ # Use Kramdown::Converter::Html class to convert this document into HTML.
58
+ #
59
+ # The implementation is basically an optimized version of core logic in
60
+ # +Kramdown::Document#method_missing+ from kramdown-2.1.0.
61
+ def to_html
62
+ output, warnings = Kramdown::Converter::Html.convert(@root, @options)
63
+ @warnings.concat(warnings)
64
+ output
65
+ end
66
+ end
67
+ end
68
+
69
+ #
70
+
3
71
  module Jekyll
4
72
  module Converters
5
73
  class Markdown
@@ -31,13 +99,14 @@ module Jekyll
31
99
  def setup
32
100
  @config["syntax_highlighter"] ||= highlighter
33
101
  @config["syntax_highlighter_opts"] ||= {}
102
+ @config["syntax_highlighter_opts"]["default_lang"] ||= "plaintext"
34
103
  @config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"]
35
104
  @config["coderay"] ||= {} # XXX: Legacy.
36
105
  modernize_coderay_config
37
106
  end
38
107
 
39
108
  def convert(content)
40
- document = Kramdown::Document.new(content, @config)
109
+ document = Kramdown::JekyllDocument.new(content, @config)
41
110
  html_output = document.to_html
42
111
  if @config["show_warnings"]
43
112
  document.warnings.each do |warning|
@@ -78,7 +78,7 @@ module Jekyll
78
78
  #
79
79
  # Returns the transformed contents.
80
80
  def transform
81
- _renderer.convert(content)
81
+ renderer.convert(content)
82
82
  end
83
83
 
84
84
  # Determine the extension depending on content_type.
@@ -86,7 +86,7 @@ module Jekyll
86
86
  # Returns the String extension for the output file.
87
87
  # e.g. ".html" for an HTML output file.
88
88
  def output_ext
89
- _renderer.output_ext
89
+ renderer.output_ext
90
90
  end
91
91
 
92
92
  # Determine which converter to use based on this convertible's
@@ -94,7 +94,7 @@ module Jekyll
94
94
  #
95
95
  # Returns the Converter instance.
96
96
  def converters
97
- _renderer.converters
97
+ renderer.converters
98
98
  end
99
99
 
100
100
  # Render Liquid in the content
@@ -105,7 +105,7 @@ module Jekyll
105
105
  #
106
106
  # Returns the converted content
107
107
  def render_liquid(content, payload, info, path)
108
- _renderer.render_liquid(content, payload, info, path)
108
+ renderer.render_liquid(content, payload, info, path)
109
109
  end
110
110
 
111
111
  # Convert this Convertible's data to a Hash suitable for use by Liquid.
@@ -191,10 +191,10 @@ module Jekyll
191
191
  #
192
192
  # Returns nothing
193
193
  def render_all_layouts(layouts, payload, info)
194
- _renderer.layouts = layouts
195
- self.output = _renderer.place_in_layouts(output, payload, info)
194
+ renderer.layouts = layouts
195
+ self.output = renderer.place_in_layouts(output, payload, info)
196
196
  ensure
197
- @_renderer = nil # this will allow the modifications above to disappear
197
+ @renderer = nil # this will allow the modifications above to disappear
198
198
  end
199
199
 
200
200
  # Add any necessary layouts to this convertible document.
@@ -204,15 +204,15 @@ module Jekyll
204
204
  #
205
205
  # Returns nothing.
206
206
  def do_layout(payload, layouts)
207
- self.output = _renderer.tap do |renderer|
208
- renderer.layouts = layouts
209
- renderer.payload = payload
207
+ self.output = renderer.tap do |doc_renderer|
208
+ doc_renderer.layouts = layouts
209
+ doc_renderer.payload = payload
210
210
  end.run
211
211
 
212
212
  Jekyll.logger.debug "Post-Render Hooks:", relative_path
213
213
  Jekyll::Hooks.trigger hook_owner, :post_render, self
214
214
  ensure
215
- @_renderer = nil # this will allow the modifications above to disappear
215
+ @renderer = nil # this will allow the modifications above to disappear
216
216
  end
217
217
 
218
218
  # Write the generated page file to the destination directory.
@@ -241,12 +241,12 @@ module Jekyll
241
241
  end
242
242
  end
243
243
 
244
- private
245
-
246
- def _renderer
247
- @_renderer ||= Jekyll::Renderer.new(site, self)
244
+ def renderer
245
+ @renderer ||= Jekyll::Renderer.new(site, self)
248
246
  end
249
247
 
248
+ private
249
+
250
250
  def no_layout?
251
251
  data["layout"] == "none"
252
252
  end