jekyll 3.8.3 → 3.9.2

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
- SHA1:
3
- metadata.gz: c71d2ab96becf45cf452ef5d75a3bda56f748cf1
4
- data.tar.gz: e85756fdfebef019f13b142f3651aee2b726168f
2
+ SHA256:
3
+ metadata.gz: d1f18811c89301d6ac1f83c43a4d2c1780bbe1e69e15c660ddef08048826bed5
4
+ data.tar.gz: ad03fafa2fc29fbdcd80f517ccef5f07eb109e79c83334c1aa7142a5b2561f64
5
5
  SHA512:
6
- metadata.gz: 3c508885c5de7efc01f089b4b522e2b69e9e8c2d12d557c4d73308fcb92a15d66c49267bb6b2d4af97b44ccd7e77dfbb8295c5925fbad5d70e22090db2f220da
7
- data.tar.gz: 7f2b541eef16a03084917a0a311c5fe703c089f41c8b9ec4b432d04e45c612dd5d45ad7ab411bee0f5d2845519f591d838f7a4063a2c8691f9515bd8e1b77650
6
+ metadata.gz: a8b270aaeff77e73442f5f6094c063254716873107b5aacaef68b992a9c15bedca1c5b4921965de784cdb823abdbe37f9af504c82d566bded0a831c80b674161
7
+ data.tar.gz: 7cfb965920cf1ddf96d515c94ce25b0595a9d23ff434607f70aba4ea668dfc1e7e2e46f19d0ebe03c1f733360eb0d7c9c9616210396623f884111be656942d61
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,11 +88,22 @@ 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
 
104
+ # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
105
+ # do not have a Java counterpart.
106
+ gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]
96
107
  RUBY
97
108
  end
98
109
 
@@ -0,0 +1,71 @@
1
+ {
2
+ "application/javascript": "UTF-8",
3
+ "application/json": "UTF-8",
4
+ "application/manifest+json": "UTF-8",
5
+ "application/vnd.syncml+xml": "UTF-8",
6
+ "application/vnd.syncml.dm+wbxml": "UTF-8",
7
+ "application/vnd.syncml.dm+xml": "UTF-8",
8
+ "application/vnd.syncml.dmddf+xml": "UTF-8",
9
+ "application/vnd.wap.wbxml": "UTF-8",
10
+ "text/cache-manifest": "UTF-8",
11
+ "text/calendar": "UTF-8",
12
+ "text/coffeescript": "UTF-8",
13
+ "text/css": "UTF-8",
14
+ "text/csv": "UTF-8",
15
+ "text/html": "UTF-8",
16
+ "text/jade": "UTF-8",
17
+ "text/jsx": "UTF-8",
18
+ "text/less": "UTF-8",
19
+ "text/markdown": "UTF-8",
20
+ "text/mathml": "UTF-8",
21
+ "text/mdx": "UTF-8",
22
+ "text/n3": "UTF-8",
23
+ "text/plain": "UTF-8",
24
+ "text/prs.lines.tag": "UTF-8",
25
+ "text/richtext": "UTF-8",
26
+ "text/sgml": "UTF-8",
27
+ "text/shex": "UTF-8",
28
+ "text/slim": "UTF-8",
29
+ "text/spdx": "UTF-8",
30
+ "text/stylus": "UTF-8",
31
+ "text/tab-separated-values": "UTF-8",
32
+ "text/troff": "UTF-8",
33
+ "text/turtle": "UTF-8",
34
+ "text/uri-list": "UTF-8",
35
+ "text/vcard": "UTF-8",
36
+ "text/vnd.curl": "UTF-8",
37
+ "text/vnd.curl.dcurl": "UTF-8",
38
+ "text/vnd.curl.mcurl": "UTF-8",
39
+ "text/vnd.curl.scurl": "UTF-8",
40
+ "text/vnd.familysearch.gedcom": "UTF-8",
41
+ "text/vnd.fly": "UTF-8",
42
+ "text/vnd.fmi.flexstor": "UTF-8",
43
+ "text/vnd.graphviz": "UTF-8",
44
+ "text/vnd.in3d.3dml": "UTF-8",
45
+ "text/vnd.in3d.spot": "UTF-8",
46
+ "text/vnd.sun.j2me.app-descriptor": "UTF-8",
47
+ "text/vnd.wap.wml": "UTF-8",
48
+ "text/vnd.wap.wmlscript": "UTF-8",
49
+ "text/vtt": "UTF-8",
50
+ "text/x-asm": "UTF-8",
51
+ "text/x-c": "UTF-8",
52
+ "text/x-component": "UTF-8",
53
+ "text/x-fortran": "UTF-8",
54
+ "text/x-handlebars-template": "UTF-8",
55
+ "text/x-java-source": "UTF-8",
56
+ "text/x-lua": "UTF-8",
57
+ "text/x-markdown": "UTF-8",
58
+ "text/x-nfo": "UTF-8",
59
+ "text/x-opml": "UTF-8",
60
+ "text/x-pascal": "UTF-8",
61
+ "text/x-processing": "UTF-8",
62
+ "text/x-sass": "UTF-8",
63
+ "text/x-scss": "UTF-8",
64
+ "text/x-setext": "UTF-8",
65
+ "text/x-sfv": "UTF-8",
66
+ "text/x-suse-ymp": "UTF-8",
67
+ "text/x-uuencode": "UTF-8",
68
+ "text/x-vcalendar": "UTF-8",
69
+ "text/x-vcard": "UTF-8",
70
+ "text/yaml": "UTF-8"
71
+ }
@@ -137,6 +137,7 @@ module Jekyll
137
137
  def initialize(server, root, callbacks)
138
138
  # So we can access them easily.
139
139
  @jekyll_opts = server.config[:JekyllOptions]
140
+ @mime_types_charset = server.config[:MimeTypesCharset]
140
141
  set_defaults
141
142
  super
142
143
  end
@@ -172,27 +173,28 @@ module Jekyll
172
173
  end
173
174
  end
174
175
 
175
- validate_and_ensure_charset(req, res)
176
+ conditionally_inject_charset(res)
176
177
  res.header.merge!(@headers)
177
178
  rtn
178
179
  end
179
180
  # rubocop:enable Naming/MethodName
180
181
 
181
- #
182
-
183
182
  private
184
- def validate_and_ensure_charset(_req, res)
185
- key = res.header.keys.grep(%r!content-type!i).first
186
- typ = res.header[key]
187
183
 
188
- unless typ =~ %r!;\s*charset=!
189
- res.header[key] = "#{typ}; charset=#{@jekyll_opts["encoding"]}"
190
- end
184
+ #
185
+ # Inject charset based on Jekyll config only if our mime-types database contains
186
+ # the charset metadata.
187
+ #
188
+ # Refer `script/vendor-mimes` in the repository for further details.
189
+ def conditionally_inject_charset(res)
190
+ typ = res.header["content-type"]
191
+ return unless @mime_types_charset.key?(typ)
192
+ return if %r!;\s*charset=!.match?(typ)
193
+
194
+ res.header["content-type"] = "#{typ}; charset=#{@jekyll_opts["encoding"]}"
191
195
  end
192
196
 
193
197
  #
194
-
195
- private
196
198
  def set_defaults
197
199
  hash_ = @jekyll_opts.fetch("webrick", {}).fetch("headers", {})
198
200
  DEFAULTS.each_with_object(@headers = hash_) do |(key, val), hash|
@@ -202,6 +202,7 @@ module Jekyll
202
202
  :JekyllOptions => opts,
203
203
  :DoNotReverseLookup => true,
204
204
  :MimeTypes => mime_types,
205
+ :MimeTypesCharset => mime_types_charset,
205
206
  :DocumentRoot => opts["destination"],
206
207
  :StartCallback => start_callback(opts["detach"]),
207
208
  :StopCallback => stop_callback(opts["detach"]),
@@ -379,6 +380,11 @@ module Jekyll
379
380
  end
380
381
 
381
382
  private
383
+
384
+ def mime_types_charset
385
+ SafeYAML.load_file(File.expand_path("serve/mime_types_charset.json", __dir__))
386
+ end
387
+
382
388
  def read_file(source_dir, file_path)
383
389
  File.read(Jekyll.sanitized_path(source_dir, file_path))
384
390
  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.
@@ -31,9 +31,12 @@ module Jekyll
31
31
 
32
32
  def filter(entries)
33
33
  entries.reject do |e|
34
- unless included?(e)
35
- special?(e) || backup?(e) || excluded?(e) || symlink?(e)
36
- end
34
+ # Reject this entry if it is a symlink.
35
+ next true if symlink?(e)
36
+ # Do not reject this entry if it is included.
37
+ next false if included?(e)
38
+ # Reject this entry if it is special, a backup file, or excluded.
39
+ special?(e) || backup?(e) || excluded?(e)
37
40
  end
38
41
  end
39
42
 
@@ -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