jekyll 3.8.4 → 3.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30ddb55605e1faf1274aee9fbec6d856867e35495abc6ad30f79ed7ac17b42c6
4
- data.tar.gz: 1351677a06924f50eb7569cea85c546bab2abbe85e48363e3203a57ebe5364be
3
+ metadata.gz: 8438a4ebfcd825d8500646d91205a6f10cf7539e1d659e425b29de27576047e9
4
+ data.tar.gz: 58762696b5382761dea9315a60e619c3130bbf560be2f3237576b855d89f63c3
5
5
  SHA512:
6
- metadata.gz: f572c520a00fe7d2cc537ee75f572f293d1efdf6ae2638ffd08df0b0964ecda165e000f8fc16bb70f0d058ae70beea391d2974a6b24c7c0755b77241b7a39317
7
- data.tar.gz: a66258b04e2b5223cda4c937cfbfa4faa7f3a2827fb737609760bd36feec962c1be04d8a7a3520345342c50aa9ebb87958e30f10a743c02f0bb8f7e97db30d4e
6
+ metadata.gz: 7fda7be3b450dcff1a509faf177c06a0e2c03a06530aace708e4717ac650a815917aa345bc5e22ee4d9544ac05798e86db3685aa6c6cfbdad60771dbae2885b1
7
+ data.tar.gz: 1e30e0db8868ec2d0bf216681f1737121513aee96b5bc6a9e91c600358782ed2125a03e6cc3206a4cac3fd369be72a9db951863ff9d0f1a0d419bf5645a974e0
data/.rubocop.yml CHANGED
@@ -53,6 +53,8 @@ Layout/EmptyComment:
53
53
  Enabled: false
54
54
  Layout/EndAlignment:
55
55
  Severity: error
56
+ Lint/SplatKeywordArguments:
57
+ Enabled: false
56
58
  Lint/UnreachableCode:
57
59
  Severity: error
58
60
  Lint/UselessAccessModifier:
@@ -88,10 +88,18 @@ group :jekyll_plugins do
88
88
  end
89
89
 
90
90
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
91
- gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
91
+ # and associated library.
92
+ install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
93
+ gem "tzinfo", "~> 1.2"
94
+ gem "tzinfo-data"
95
+ end
92
96
 
93
97
  # Performance-booster for watching directories on Windows
94
- gem "wdm", "~> 0.1.0" if Gem.win_platform?
98
+ gem "wdm", "~> 0.1.0", :install_if => Gem.win_platform?
99
+
100
+ # kramdown v2 ships without the gfm parser by default. If you're using
101
+ # kramdown v1, comment out this line.
102
+ gem "kramdown-parser-gfm"
95
103
 
96
104
  RUBY
97
105
  end
@@ -81,6 +81,7 @@ module Jekyll
81
81
  "smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
82
82
  "input" => "GFM",
83
83
  "hard_wrap" => false,
84
+ "guess_lang" => true,
84
85
  "footnote_nr" => 1,
85
86
  "show_warnings" => false,
86
87
  },
@@ -18,6 +18,7 @@ module Jekyll
18
18
  @config = config["kramdown"] || {}
19
19
  @highlighter = nil
20
20
  setup
21
+ load_dependencies
21
22
  end
22
23
 
23
24
  # Setup and normalize the configuration:
@@ -30,6 +31,8 @@ module Jekyll
30
31
  def setup
31
32
  @config["syntax_highlighter"] ||= highlighter
32
33
  @config["syntax_highlighter_opts"] ||= {}
34
+ @config["syntax_highlighter_opts"]["default_lang"] ||= "plaintext"
35
+ @config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"]
33
36
  @config["coderay"] ||= {} # XXX: Legacy.
34
37
  modernize_coderay_config
35
38
  make_accessible
@@ -47,6 +50,24 @@ module Jekyll
47
50
  end
48
51
 
49
52
  private
53
+
54
+ def load_dependencies
55
+ return if Kramdown::VERSION.to_i < 2
56
+ if @config["input"] == "GFM"
57
+ Jekyll::External.require_with_graceful_fail("kramdown-parser-gfm")
58
+ end
59
+
60
+ if highlighter == "coderay"
61
+ Jekyll::External.require_with_graceful_fail("kramdown-syntax-coderay")
62
+ end
63
+
64
+ # `mathjax` emgine is bundled within kramdown-2.x and will be handled by
65
+ # kramdown itself.
66
+ if (math_engine = @config["math_engine"]) && math_engine != "mathjax"
67
+ Jekyll::External.require_with_graceful_fail("kramdown-math-#{math_engine}")
68
+ end
69
+ end
70
+
50
71
  def make_accessible(hash = @config)
51
72
  hash.keys.each do |key|
52
73
  hash[key.to_sym] = hash[key]
@@ -39,7 +39,7 @@ module Jekyll
39
39
 
40
40
  begin
41
41
  self.content = File.read(@path || site.in_source_dir(base, name),
42
- Utils.merged_file_read_opts(site, opts))
42
+ **Utils.merged_file_read_opts(site, opts))
43
43
  if content =~ Document::YAML_FRONT_MATTER_REGEXP
44
44
  self.content = $POSTMATCH
45
45
  self.data = SafeYAML.load(Regexp.last_match(1))
@@ -266,7 +266,7 @@ module Jekyll
266
266
  else
267
267
  begin
268
268
  merge_defaults
269
- read_content(opts)
269
+ read_content(**opts)
270
270
  read_post_data
271
271
  rescue StandardError => e
272
272
  handle_read_error(e)
@@ -445,8 +445,8 @@ module Jekyll
445
445
  end
446
446
 
447
447
  private
448
- def read_content(opts)
449
- self.content = File.read(path, Utils.merged_file_read_opts(site, opts))
448
+ def read_content(**opts)
449
+ self.content = File.read(path, **Utils.merged_file_read_opts(site, opts))
450
450
  if content =~ YAML_FRONT_MATTER_REGEXP
451
451
  self.content = $POSTMATCH
452
452
  data_file = SafeYAML.load(Regexp.last_match(1))
@@ -8,8 +8,7 @@ module Jekyll
8
8
  mutable false
9
9
 
10
10
  def_delegator :@obj, :site_data, :data
11
- def_delegators :@obj, :time, :pages, :static_files, :documents,
12
- :tags, :categories
11
+ def_delegators :@obj, :time, :pages, :static_files, :tags, :categories
13
12
 
14
13
  private def_delegator :@obj, :config, :fallback_data
15
14
 
@@ -39,6 +38,16 @@ module Jekyll
39
38
  @site_collections ||= @obj.collections.values.sort_by(&:label).map(&:to_liquid)
40
39
  end
41
40
 
41
+ # `Site#documents` cannot be memoized so that `Site#docs_to_write` can access the
42
+ # latest state of the attribute.
43
+ #
44
+ # Since this method will be called after `Site#pre_render` hook,
45
+ # the `Site#documents` array shouldn't thereafter change and can therefore be
46
+ # safely memoized to prevent additional computation of `Site#documents`.
47
+ def documents
48
+ @documents ||= @obj.documents
49
+ end
50
+
42
51
  # `{{ site.related_posts }}` is how posts can get posts related to
43
52
  # them, either through LSI if it's enabled, or through the most
44
53
  # recent posts.
@@ -128,36 +128,47 @@ module Jekyll
128
128
  #
129
129
  # Returns excerpt String
130
130
 
131
- LIQUID_TAG_REGEX = %r!{%-?\s*(\w+).+\s*-?%}!m
131
+ LIQUID_TAG_REGEX = %r!{%-?\s*(\w+)\s*.*?-?%}!m
132
132
  MKDWN_LINK_REF_REGEX = %r!^ {0,3}\[[^\]]+\]:.+$!
133
133
 
134
134
  def extract_excerpt(doc_content)
135
135
  head, _, tail = doc_content.to_s.partition(doc.excerpt_separator)
136
136
 
137
- # append appropriate closing tag (to a Liquid block), to the "head" if the
138
- # partitioning resulted in leaving the closing tag somewhere in the "tail"
139
- # partition.
140
- if head.include?("{%")
141
- head =~ LIQUID_TAG_REGEX
142
- tag_name = Regexp.last_match(1)
137
+ # append appropriate closing tag(s) (for each Liquid block), to the `head`
138
+ # if the partitioning resulted in leaving the closing tag somewhere
139
+ # in the `tail` partition.
143
140
 
144
- if liquid_block?(tag_name) && head.match(%r!{%-?\s*end#{tag_name}\s*-?%}!).nil?
145
- print_build_warning
141
+ if head.include?("{%")
142
+ modified = false
143
+ tag_names = head.scan(LIQUID_TAG_REGEX)
144
+ tag_names.flatten!
145
+ tag_names.reverse_each do |tag_name|
146
+ next unless liquid_block?(tag_name)
147
+ next if head =~ endtag_regex_stash(tag_name)
148
+
149
+ modified = true
146
150
  head << "\n{% end#{tag_name} %}"
147
151
  end
152
+ print_build_warning if modified
148
153
  end
149
154
 
150
- if tail.empty?
151
- head
152
- else
153
- head.to_s.dup << "\n\n" << tail.scan(MKDWN_LINK_REF_REGEX).join("\n")
154
- end
155
+ return head if tail.empty?
156
+
157
+ head << "\n\n" << tail.scan(MKDWN_LINK_REF_REGEX).join("\n")
155
158
  end
156
159
 
157
160
  private
158
161
 
162
+ def endtag_regex_stash(tag_name)
163
+ @endtag_regex_stash ||= {}
164
+ @endtag_regex_stash[tag_name] ||= %r!{%-?\s*end#{tag_name}.*?\s*-?%}!m
165
+ end
166
+
159
167
  def liquid_block?(tag_name)
160
- Liquid::Template.tags[tag_name].superclass == Liquid::Block
168
+ return false unless tag_name.is_a?(String)
169
+ return false unless Liquid::Template.tags[tag_name]
170
+
171
+ Liquid::Template.tags[tag_name].ancestors.include?(Liquid::Block)
161
172
  rescue NoMethodError
162
173
  Jekyll.logger.error "Error:",
163
174
  "A Liquid tag in the excerpt of #{doc.relative_path} couldn't be " \
@@ -167,12 +178,13 @@ module Jekyll
167
178
 
168
179
  def print_build_warning
169
180
  Jekyll.logger.warn "Warning:", "Excerpt modified in #{doc.relative_path}!"
170
- Jekyll.logger.warn "",
171
- "Found a Liquid block containing separator '#{doc.excerpt_separator}' and has " \
172
- "been modified with the appropriate closing tag."
173
- Jekyll.logger.warn "",
174
- "Feel free to define a custom excerpt or excerpt_separator in the document's " \
175
- "Front Matter if the generated excerpt is unsatisfactory."
181
+ Jekyll.logger.warn "", "Found a Liquid block containing the excerpt separator" \
182
+ " #{doc.excerpt_separator.inspect}. "
183
+ Jekyll.logger.warn "", "The block has been modified with the appropriate" \
184
+ " closing tag."
185
+ Jekyll.logger.warn "", "Feel free to define a custom excerpt or" \
186
+ " excerpt_separator in the document's front matter" \
187
+ " if the generated excerpt is unsatisfactory."
176
188
  end
177
189
  end
178
190
  end
@@ -53,7 +53,9 @@ module Jekyll
53
53
  private
54
54
 
55
55
  def filename_regex
56
- @filename_regex ||= %r!\A(#{source_dir}/|#{theme_dir}/|\W*)(.*)!i
56
+ @filename_regex ||= begin
57
+ %r!\A(#{Regexp.escape(source_dir)}/|#{Regexp.escape(theme_dir.to_s)}/|/*)(.*)!i
58
+ end
57
59
  end
58
60
 
59
61
  def new_profile_hash
data/lib/jekyll/site.rb CHANGED
@@ -314,15 +314,15 @@ module Jekyll
314
314
  #
315
315
  # Returns an Array of Documents which should be written
316
316
  def docs_to_write
317
- @docs_to_write ||= documents.select(&:write?)
317
+ documents.select(&:write?)
318
318
  end
319
319
 
320
320
  # Get all the documents
321
321
  #
322
322
  # Returns an Array of all Documents
323
323
  def documents
324
- collections.reduce(Set.new) do |docs, (_, collection)|
325
- docs + collection.docs + collection.files
324
+ collections.each_with_object(Set.new) do |(_, collection), set|
325
+ set.merge(collection.docs).merge(collection.files)
326
326
  end.to_a
327
327
  end
328
328
 
@@ -22,7 +22,7 @@ module Jekyll
22
22
  !mx
23
23
 
24
24
  FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!
25
- VALID_FILENAME_CHARS = %r!^[\w/\.-]+$!
25
+ VALID_FILENAME_CHARS = %r!^[\w/.\-()+~\#@]+$!
26
26
  INVALID_SEQUENCES = %r![./]{2,}!
27
27
 
28
28
  def initialize(tag_name, markup, tokens)
@@ -191,7 +191,7 @@ MSG
191
191
 
192
192
  # This method allows to modify the file content by inheriting from the class.
193
193
  def read_file(file, context)
194
- File.read(file, file_read_opts(context))
194
+ File.read(file, **file_read_opts(context))
195
195
  end
196
196
 
197
197
  private
@@ -224,6 +224,7 @@ MSG
224
224
  else
225
225
  File.join(site.config["collections_dir"], page_payload["path"])
226
226
  end
227
+ resource_path.sub!(%r!/#excerpt\z!, "")
227
228
  site.in_source_dir File.dirname(resource_path)
228
229
  end
229
230
  end
data/lib/jekyll/theme.rb CHANGED
@@ -56,12 +56,28 @@ module Jekyll
56
56
  end
57
57
 
58
58
  def realpath_for(folder)
59
- File.realpath(Jekyll.sanitized_path(root, folder.to_s))
60
- rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
61
- Jekyll.logger.warn "Invalid theme folder:", folder
59
+ # This resolves all symlinks for the theme subfolder and then ensures
60
+ # that the directory remains inside the theme root. This prevents the
61
+ # use of symlinks for theme subfolders to escape the theme root.
62
+ # However, symlinks are allowed to point to other directories within the theme.
63
+ Jekyll.sanitized_path(root, File.realpath(Jekyll.sanitized_path(root, folder.to_s)))
64
+ rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP => e
65
+ log_realpath_exception(e, folder)
62
66
  nil
63
67
  end
64
68
 
69
+ def log_realpath_exception(err, folder)
70
+ return if err.is_a?(Errno::ENOENT)
71
+
72
+ case err
73
+ when Errno::EACCES
74
+ Jekyll.logger.error "Theme error:", "Directory '#{folder}' is not accessible."
75
+ when Errno::ELOOP
76
+ Jekyll.logger.error "Theme error:",
77
+ "Directory '#{folder}' includes a symbolic link loop."
78
+ end
79
+ end
80
+
65
81
  def gemspec
66
82
  @gemspec ||= Gem::Specification.find_by_name(name)
67
83
  rescue Gem::LoadError
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jekyll
4
- VERSION = "3.8.4".freeze
4
+ VERSION = "3.9.1".freeze
5
5
  end
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.8.4
4
+ version: 3.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.0'
97
- - !ruby/object:Gem::Dependency
98
- name: kramdown
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.14'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.14'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: liquid
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +170,26 @@ dependencies:
184
170
  - - "~>"
185
171
  - !ruby/object:Gem::Version
186
172
  version: '1.0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: kramdown
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '1.17'
180
+ - - "<"
181
+ - !ruby/object:Gem::Version
182
+ version: '3'
183
+ type: :runtime
184
+ prerelease: false
185
+ version_requirements: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '1.17'
190
+ - - "<"
191
+ - !ruby/object:Gem::Version
192
+ version: '3'
187
193
  description: Jekyll is a simple, blog aware, static site generator.
188
194
  email: tom@mojombo.com
189
195
  executables:
@@ -311,7 +317,7 @@ homepage: https://github.com/jekyll/jekyll
311
317
  licenses:
312
318
  - MIT
313
319
  metadata: {}
314
- post_install_message:
320
+ post_install_message:
315
321
  rdoc_options:
316
322
  - "--charset=UTF-8"
317
323
  require_paths:
@@ -327,9 +333,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
327
333
  - !ruby/object:Gem::Version
328
334
  version: '0'
329
335
  requirements: []
330
- rubyforge_project:
331
- rubygems_version: 3.0.0.beta1
332
- signing_key:
336
+ rubygems_version: 3.1.6
337
+ signing_key:
333
338
  specification_version: 2
334
339
  summary: A simple, blog aware, static site generator.
335
340
  test_files: []