jekyll 3.9.1 → 4.0.0.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +27 -50
- data/LICENSE +1 -1
- data/README.markdown +46 -17
- data/lib/blank_template/_config.yml +3 -0
- data/lib/blank_template/_layouts/default.html +12 -0
- data/lib/blank_template/_sass/main.scss +9 -0
- data/lib/blank_template/assets/css/main.scss +4 -0
- data/lib/blank_template/index.md +8 -0
- data/lib/jekyll.rb +5 -0
- data/lib/jekyll/cache.rb +183 -0
- data/lib/jekyll/cleaner.rb +2 -1
- data/lib/jekyll/collection.rb +78 -8
- data/lib/jekyll/command.rb +31 -6
- data/lib/jekyll/commands/build.rb +11 -20
- data/lib/jekyll/commands/clean.rb +2 -0
- data/lib/jekyll/commands/doctor.rb +15 -8
- data/lib/jekyll/commands/help.rb +1 -1
- data/lib/jekyll/commands/new.rb +37 -39
- data/lib/jekyll/commands/new_theme.rb +30 -28
- data/lib/jekyll/commands/serve.rb +46 -80
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +6 -10
- data/lib/jekyll/commands/serve/servlet.rb +9 -11
- data/lib/jekyll/configuration.rb +26 -26
- data/lib/jekyll/converters/identity.rb +18 -0
- data/lib/jekyll/converters/markdown.rb +49 -40
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +1 -10
- data/lib/jekyll/converters/smartypants.rb +34 -14
- data/lib/jekyll/convertible.rb +11 -13
- data/lib/jekyll/deprecator.rb +1 -3
- data/lib/jekyll/document.rb +44 -41
- data/lib/jekyll/drops/collection_drop.rb +2 -3
- data/lib/jekyll/drops/document_drop.rb +2 -1
- data/lib/jekyll/drops/drop.rb +3 -6
- data/lib/jekyll/drops/excerpt_drop.rb +4 -0
- data/lib/jekyll/drops/site_drop.rb +4 -13
- data/lib/jekyll/drops/unified_payload_drop.rb +1 -0
- data/lib/jekyll/drops/url_drop.rb +1 -0
- data/lib/jekyll/entry_filter.rb +2 -1
- data/lib/jekyll/excerpt.rb +45 -34
- data/lib/jekyll/external.rb +10 -5
- data/lib/jekyll/filters.rb +72 -31
- data/lib/jekyll/filters/date_filters.rb +6 -3
- data/lib/jekyll/filters/grouping_filters.rb +1 -2
- data/lib/jekyll/filters/url_filters.rb +6 -1
- data/lib/jekyll/frontmatter_defaults.rb +35 -19
- data/lib/jekyll/hooks.rb +2 -3
- data/lib/jekyll/liquid_extensions.rb +0 -2
- data/lib/jekyll/liquid_renderer.rb +13 -1
- data/lib/jekyll/liquid_renderer/file.rb +14 -3
- data/lib/jekyll/liquid_renderer/table.rb +67 -65
- data/lib/jekyll/log_adapter.rb +5 -1
- data/lib/jekyll/page.rb +10 -11
- data/lib/jekyll/page_without_a_file.rb +0 -4
- data/lib/jekyll/plugin.rb +5 -11
- data/lib/jekyll/plugin_manager.rb +2 -0
- data/lib/jekyll/reader.rb +38 -8
- data/lib/jekyll/readers/data_reader.rb +7 -9
- data/lib/jekyll/readers/layout_reader.rb +2 -12
- data/lib/jekyll/readers/post_reader.rb +29 -17
- data/lib/jekyll/readers/static_file_reader.rb +1 -1
- data/lib/jekyll/readers/theme_assets_reader.rb +7 -5
- data/lib/jekyll/regenerator.rb +4 -12
- data/lib/jekyll/renderer.rb +14 -25
- data/lib/jekyll/site.rb +78 -34
- data/lib/jekyll/static_file.rb +47 -11
- data/lib/jekyll/stevenson.rb +2 -3
- data/lib/jekyll/tags/highlight.rb +22 -52
- data/lib/jekyll/tags/include.rb +22 -38
- data/lib/jekyll/tags/link.rb +11 -7
- data/lib/jekyll/tags/post_url.rb +17 -16
- data/lib/jekyll/theme.rb +12 -23
- data/lib/jekyll/theme_builder.rb +91 -89
- data/lib/jekyll/url.rb +3 -2
- data/lib/jekyll/utils.rb +5 -4
- data/lib/jekyll/utils/ansi.rb +1 -1
- data/lib/jekyll/utils/exec.rb +0 -1
- data/lib/jekyll/utils/internet.rb +2 -4
- data/lib/jekyll/utils/platforms.rb +8 -8
- data/lib/jekyll/utils/thread_event.rb +1 -5
- data/lib/jekyll/utils/win_tz.rb +1 -1
- data/lib/jekyll/version.rb +1 -1
- data/lib/site_template/.gitignore +2 -0
- data/lib/site_template/404.html +1 -0
- data/lib/site_template/_config.yml +17 -5
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +5 -1
- data/lib/site_template/{about.md → about.markdown} +0 -0
- data/lib/site_template/{index.md → index.markdown} +0 -0
- data/lib/theme_template/gitignore.erb +1 -0
- data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -0
- metadata +85 -51
- data/lib/jekyll/converters/markdown/rdiscount_parser.rb +0 -37
- data/lib/jekyll/converters/markdown/redcarpet_parser.rb +0 -112
- data/lib/jekyll/utils/rouge.rb +0 -22
data/lib/jekyll/configuration.rb
CHANGED
@@ -9,6 +9,7 @@ module Jekyll
|
|
9
9
|
"source" => Dir.pwd,
|
10
10
|
"destination" => File.join(Dir.pwd, "_site"),
|
11
11
|
"collections_dir" => "",
|
12
|
+
"cache_dir" => ".jekyll-cache",
|
12
13
|
"plugins_dir" => "_plugins",
|
13
14
|
"layouts_dir" => "_layouts",
|
14
15
|
"data_dir" => "_data",
|
@@ -18,10 +19,7 @@ module Jekyll
|
|
18
19
|
# Handling Reading
|
19
20
|
"safe" => false,
|
20
21
|
"include" => [".htaccess"],
|
21
|
-
"exclude" =>
|
22
|
-
Gemfile Gemfile.lock node_modules vendor/bundle/ vendor/cache/ vendor/gems/
|
23
|
-
vendor/ruby/
|
24
|
-
),
|
22
|
+
"exclude" => [],
|
25
23
|
"keep_files" => [".git", ".svn"],
|
26
24
|
"encoding" => "utf-8",
|
27
25
|
"markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
|
@@ -66,14 +64,6 @@ module Jekyll
|
|
66
64
|
"strict_variables" => false,
|
67
65
|
},
|
68
66
|
|
69
|
-
"rdiscount" => {
|
70
|
-
"extensions" => [],
|
71
|
-
},
|
72
|
-
|
73
|
-
"redcarpet" => {
|
74
|
-
"extensions" => [],
|
75
|
-
},
|
76
|
-
|
77
67
|
"kramdown" => {
|
78
68
|
"auto_ids" => true,
|
79
69
|
"toc_levels" => "1..6",
|
@@ -100,7 +90,7 @@ module Jekyll
|
|
100
90
|
# problems and backwards-compatibility.
|
101
91
|
def from(user_config)
|
102
92
|
Utils.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys)
|
103
|
-
.add_default_collections
|
93
|
+
.add_default_collections.add_default_excludes
|
104
94
|
end
|
105
95
|
end
|
106
96
|
|
@@ -162,7 +152,7 @@ module Jekyll
|
|
162
152
|
# Get configuration from <source>/_config.yml or <source>/<config_file>
|
163
153
|
config_files = override["config"]
|
164
154
|
if config_files.to_s.empty?
|
165
|
-
default = %w(yml yaml).find(-> { "yml" }) do |ext|
|
155
|
+
default = %w(yml yaml toml).find(-> { "yml" }) do |ext|
|
166
156
|
File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}"))
|
167
157
|
end
|
168
158
|
config_files = Jekyll.sanitized_path(source(override), "_config.#{default}")
|
@@ -177,6 +167,7 @@ module Jekyll
|
|
177
167
|
#
|
178
168
|
# Returns this configuration, overridden by the values in the file
|
179
169
|
def read_config_file(file)
|
170
|
+
file = File.expand_path(file)
|
180
171
|
next_config = safe_load_file(file)
|
181
172
|
check_config_is_hash!(next_config, file)
|
182
173
|
Jekyll.logger.info "Configuration file:", file
|
@@ -204,6 +195,7 @@ module Jekyll
|
|
204
195
|
begin
|
205
196
|
files.each do |config_file|
|
206
197
|
next if config_file.nil? || config_file.empty?
|
198
|
+
|
207
199
|
new_config = read_config_file(config_file)
|
208
200
|
configuration = Utils.deep_merge_hashes(configuration, new_config)
|
209
201
|
end
|
@@ -277,7 +269,22 @@ module Jekyll
|
|
277
269
|
config
|
278
270
|
end
|
279
271
|
|
280
|
-
|
272
|
+
DEFAULT_EXCLUDES = %w(
|
273
|
+
.sass-cache .jekyll-cache
|
274
|
+
gemfiles Gemfile Gemfile.lock
|
275
|
+
node_modules
|
276
|
+
vendor/bundle/ vendor/cache/ vendor/gems/ vendor/ruby/
|
277
|
+
).freeze
|
278
|
+
|
279
|
+
def add_default_excludes
|
280
|
+
config = clone
|
281
|
+
return config if config["exclude"].nil?
|
282
|
+
|
283
|
+
config["exclude"].concat(DEFAULT_EXCLUDES).uniq!
|
284
|
+
config
|
285
|
+
end
|
286
|
+
|
287
|
+
def renamed_key(old, new, config)
|
281
288
|
if config.key?(old)
|
282
289
|
Jekyll::Deprecator.deprecation_message "The '#{old}' configuration" \
|
283
290
|
" option has been renamed to '#{new}'. Please update your config" \
|
@@ -287,6 +294,7 @@ module Jekyll
|
|
287
294
|
end
|
288
295
|
|
289
296
|
private
|
297
|
+
|
290
298
|
def style_to_permalink(permalink_style)
|
291
299
|
case permalink_style.to_sym
|
292
300
|
when :pretty
|
@@ -308,14 +316,12 @@ module Jekyll
|
|
308
316
|
# file - the file from which the config was extracted
|
309
317
|
#
|
310
318
|
# Raises an ArgumentError if given config is not a hash
|
311
|
-
private
|
312
319
|
def check_config_is_hash!(extracted_config, file)
|
313
320
|
unless extracted_config.is_a?(Hash)
|
314
321
|
raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
|
315
322
|
end
|
316
323
|
end
|
317
324
|
|
318
|
-
private
|
319
325
|
def check_auto(config)
|
320
326
|
if config.key?("auto") || config.key?("watch")
|
321
327
|
Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" \
|
@@ -326,7 +332,6 @@ module Jekyll
|
|
326
332
|
end
|
327
333
|
end
|
328
334
|
|
329
|
-
private
|
330
335
|
def check_server(config)
|
331
336
|
if config.key?("server")
|
332
337
|
Jekyll::Deprecator.deprecation_message "The 'server' configuration option" \
|
@@ -336,7 +341,6 @@ module Jekyll
|
|
336
341
|
end
|
337
342
|
end
|
338
343
|
|
339
|
-
private
|
340
344
|
def check_pygments(config)
|
341
345
|
if config.key?("pygments")
|
342
346
|
Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" \
|
@@ -349,7 +353,6 @@ module Jekyll
|
|
349
353
|
end
|
350
354
|
end
|
351
355
|
|
352
|
-
private
|
353
356
|
def check_include_exclude(config)
|
354
357
|
%w(include exclude).each do |option|
|
355
358
|
if config[option].is_a?(String)
|
@@ -359,11 +362,10 @@ module Jekyll
|
|
359
362
|
" as a list of comma-separated values."
|
360
363
|
config[option] = csv_to_array(config[option])
|
361
364
|
end
|
362
|
-
config[option]
|
365
|
+
config[option]&.map!(&:to_s)
|
363
366
|
end
|
364
367
|
end
|
365
368
|
|
366
|
-
private
|
367
369
|
def check_coderay(config)
|
368
370
|
if (config["kramdown"] || {}).key?("use_coderay")
|
369
371
|
Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" \
|
@@ -372,7 +374,6 @@ module Jekyll
|
|
372
374
|
end
|
373
375
|
end
|
374
376
|
|
375
|
-
private
|
376
377
|
def check_maruku(config)
|
377
378
|
if config.fetch("markdown", "kramdown").to_s.casecmp("maruku").zero?
|
378
379
|
Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \
|
@@ -389,7 +390,6 @@ module Jekyll
|
|
389
390
|
#
|
390
391
|
# Raises a Jekyll::Errors::InvalidConfigurationError if the config `plugins`
|
391
392
|
# is a string
|
392
|
-
private
|
393
393
|
def check_plugins(config)
|
394
394
|
if config.key?("plugins") && config["plugins"].is_a?(String)
|
395
395
|
Jekyll.logger.error "Configuration Error:", "You specified the" \
|
@@ -397,8 +397,8 @@ module Jekyll
|
|
397
397
|
" use an array instead. If you wanted to set the directory of your" \
|
398
398
|
" plugins, use the config key `plugins_dir` instead."
|
399
399
|
raise Jekyll::Errors::InvalidConfigurationError,
|
400
|
-
|
401
|
-
|
400
|
+
"'plugins' should not be a string, but was: " \
|
401
|
+
"#{config["plugins"].inspect}. Use 'plugins_dir' instead."
|
402
402
|
end
|
403
403
|
end
|
404
404
|
end
|
@@ -2,19 +2,37 @@
|
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module Converters
|
5
|
+
# Identify converter. Returns same content as given.
|
6
|
+
# For more info on converters see https://jekyllrb.com/docs/plugins/converters/
|
5
7
|
class Identity < Converter
|
6
8
|
safe true
|
7
9
|
|
8
10
|
priority :lowest
|
9
11
|
|
12
|
+
# Public: Does the given extension match this converter's list of acceptable extensions?
|
13
|
+
# Takes one argument: the file's extension (including the dot).
|
14
|
+
#
|
15
|
+
# ext - The String extension to check (not relevant here)
|
16
|
+
#
|
17
|
+
# Returns true since it always matches.
|
10
18
|
def matches(_ext)
|
11
19
|
true
|
12
20
|
end
|
13
21
|
|
22
|
+
# Public: The extension to be given to the output file (including the dot).
|
23
|
+
#
|
24
|
+
# ext - The String extension or original file.
|
25
|
+
#
|
26
|
+
# Returns The String output file extension.
|
14
27
|
def output_ext(ext)
|
15
28
|
ext
|
16
29
|
end
|
17
30
|
|
31
|
+
# Logic to do the content conversion.
|
32
|
+
#
|
33
|
+
# content - String content of file (without front matter).
|
34
|
+
#
|
35
|
+
# Returns a String of the converted content.
|
18
36
|
def convert(content)
|
19
37
|
content
|
20
38
|
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module Converters
|
5
|
+
# Markdown converter.
|
6
|
+
# For more info on converters see https://jekyllrb.com/docs/plugins/converters/
|
5
7
|
class Markdown < Converter
|
6
8
|
highlighter_prefix "\n"
|
7
9
|
highlighter_suffix "\n"
|
@@ -9,80 +11,91 @@ module Jekyll
|
|
9
11
|
|
10
12
|
def setup
|
11
13
|
return if @setup ||= false
|
14
|
+
|
12
15
|
unless (@parser = get_processor)
|
13
|
-
Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
|
14
16
|
if @config["safe"]
|
15
|
-
Jekyll.logger.
|
17
|
+
Jekyll.logger.warn "Build Warning:", "Custom processors are not loaded in safe mode"
|
16
18
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
)
|
21
|
-
|
19
|
+
|
20
|
+
Jekyll.logger.error "Markdown processor:",
|
21
|
+
"#{@config["markdown"].inspect} is not a valid Markdown processor."
|
22
|
+
Jekyll.logger.error "", "Available processors are: #{valid_processors.join(", ")}"
|
23
|
+
Jekyll.logger.error ""
|
24
|
+
raise Errors::FatalException, "Invalid Markdown processor given: #{@config["markdown"]}"
|
22
25
|
end
|
23
26
|
|
27
|
+
@cache = Jekyll::Cache.new("Jekyll::Converters::Markdown")
|
24
28
|
@setup = true
|
25
29
|
end
|
26
30
|
|
27
|
-
#
|
31
|
+
# RuboCop does not allow reader methods to have names starting with `get_`
|
28
32
|
# To ensure compatibility, this check has been disabled on this method
|
29
33
|
#
|
30
34
|
# rubocop:disable Naming/AccessorMethodName
|
31
35
|
def get_processor
|
32
36
|
case @config["markdown"].downcase
|
33
|
-
when "
|
34
|
-
when "kramdown" then return KramdownParser.new(@config)
|
35
|
-
when "rdiscount" then return RDiscountParser.new(@config)
|
37
|
+
when "kramdown" then KramdownParser.new(@config)
|
36
38
|
else
|
37
39
|
custom_processor
|
38
40
|
end
|
39
41
|
end
|
40
42
|
# rubocop:enable Naming/AccessorMethodName
|
41
43
|
|
42
|
-
# Public: Provides you with a list of processors
|
43
|
-
#
|
44
|
-
#
|
45
|
-
|
44
|
+
# Public: Provides you with a list of processors comprised of the ones we support internally
|
45
|
+
# and the ones that you have provided to us (if they're whitelisted for use in safe mode).
|
46
|
+
#
|
47
|
+
# Returns an array of symbols.
|
46
48
|
def valid_processors
|
47
|
-
|
49
|
+
[:kramdown] + third_party_processors
|
48
50
|
end
|
49
51
|
|
50
52
|
# Public: A list of processors that you provide via plugins.
|
51
|
-
#
|
52
|
-
#
|
53
|
-
|
53
|
+
#
|
54
|
+
# Returns an array of symbols
|
54
55
|
def third_party_processors
|
55
|
-
self.class.constants -
|
56
|
-
%w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map(
|
57
|
-
&:to_sym
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
|
-
def extname_list
|
62
|
-
@extname_list ||= @config["markdown_ext"].split(",").map do |e|
|
63
|
-
".#{e.downcase}"
|
64
|
-
end
|
56
|
+
self.class.constants - [:KramdownParser, :PRIORITIES]
|
65
57
|
end
|
66
58
|
|
59
|
+
# Does the given extension match this converter's list of acceptable extensions?
|
60
|
+
# Takes one argument: the file's extension (including the dot).
|
61
|
+
#
|
62
|
+
# ext - The String extension to check.
|
63
|
+
#
|
64
|
+
# Returns true if it matches, false otherwise.
|
67
65
|
def matches(ext)
|
68
66
|
extname_list.include?(ext.downcase)
|
69
67
|
end
|
70
68
|
|
69
|
+
# Public: The extension to be given to the output file (including the dot).
|
70
|
+
#
|
71
|
+
# ext - The String extension or original file.
|
72
|
+
#
|
73
|
+
# Returns The String output file extension.
|
71
74
|
def output_ext(_ext)
|
72
75
|
".html"
|
73
76
|
end
|
74
77
|
|
78
|
+
# Logic to do the content conversion.
|
79
|
+
#
|
80
|
+
# content - String content of file (without front matter).
|
81
|
+
#
|
82
|
+
# Returns a String of the converted content.
|
75
83
|
def convert(content)
|
76
84
|
setup
|
77
|
-
@
|
85
|
+
@cache.getset(content) do
|
86
|
+
@parser.convert(content)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def extname_list
|
91
|
+
@extname_list ||= @config["markdown_ext"].split(",").map! { |e| ".#{e.downcase}" }
|
78
92
|
end
|
79
93
|
|
80
94
|
private
|
95
|
+
|
81
96
|
def custom_processor
|
82
97
|
converter_name = @config["markdown"]
|
83
|
-
if custom_class_allowed?(converter_name)
|
84
|
-
self.class.const_get(converter_name).new(@config)
|
85
|
-
end
|
98
|
+
self.class.const_get(converter_name).new(@config) if custom_class_allowed?(converter_name)
|
86
99
|
end
|
87
100
|
|
88
101
|
# Private: Determine whether a class name is an allowed custom
|
@@ -90,14 +103,10 @@ module Jekyll
|
|
90
103
|
#
|
91
104
|
# parser_name - the name of the parser class
|
92
105
|
#
|
93
|
-
# Returns true if the parser name contains only alphanumeric
|
94
|
-
#
|
95
|
-
|
96
|
-
private
|
106
|
+
# Returns true if the parser name contains only alphanumeric characters and is defined
|
107
|
+
# within Jekyll::Converters::Markdown
|
97
108
|
def custom_class_allowed?(parser_name)
|
98
|
-
parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?(
|
99
|
-
parser_name.to_sym
|
100
|
-
)
|
109
|
+
parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?(parser_name.to_sym)
|
101
110
|
end
|
102
111
|
end
|
103
112
|
end
|
@@ -31,7 +31,6 @@ module Jekyll
|
|
31
31
|
def setup
|
32
32
|
@config["syntax_highlighter"] ||= highlighter
|
33
33
|
@config["syntax_highlighter_opts"] ||= {}
|
34
|
-
@config["syntax_highlighter_opts"]["default_lang"] ||= "plaintext"
|
35
34
|
@config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"]
|
36
35
|
@config["coderay"] ||= {} # XXX: Legacy.
|
37
36
|
modernize_coderay_config
|
@@ -52,10 +51,7 @@ module Jekyll
|
|
52
51
|
private
|
53
52
|
|
54
53
|
def load_dependencies
|
55
|
-
|
56
|
-
if @config["input"] == "GFM"
|
57
|
-
Jekyll::External.require_with_graceful_fail("kramdown-parser-gfm")
|
58
|
-
end
|
54
|
+
require "kramdown-parser-gfm" if @config["input"] == "GFM"
|
59
55
|
|
60
56
|
if highlighter == "coderay"
|
61
57
|
Jekyll::External.require_with_graceful_fail("kramdown-syntax-coderay")
|
@@ -80,8 +76,6 @@ module Jekyll
|
|
80
76
|
# config[highlighter]
|
81
77
|
# Where `enable_coderay` is now deprecated because Kramdown
|
82
78
|
# supports Rouge now too.
|
83
|
-
|
84
|
-
private
|
85
79
|
def highlighter
|
86
80
|
return @highlighter if @highlighter
|
87
81
|
|
@@ -105,7 +99,6 @@ module Jekyll
|
|
105
99
|
end
|
106
100
|
end
|
107
101
|
|
108
|
-
private
|
109
102
|
def strip_coderay_prefix(hash)
|
110
103
|
hash.each_with_object({}) do |(key, val), hsh|
|
111
104
|
cleaned_key = key.to_s.gsub(%r!\Acoderay_!, "")
|
@@ -123,8 +116,6 @@ module Jekyll
|
|
123
116
|
# If our highlighter is CodeRay we go in to merge the CodeRay defaults
|
124
117
|
# with your "coderay" key if it's there, deprecating it in the
|
125
118
|
# process of you using it.
|
126
|
-
|
127
|
-
private
|
128
119
|
def modernize_coderay_config
|
129
120
|
unless @config["coderay"].empty?
|
130
121
|
Jekyll::Deprecator.deprecation_message(
|
@@ -1,40 +1,60 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module Kramdown
|
4
|
+
module Parser
|
5
|
+
class SmartyPants < Kramdown::Parser::Kramdown
|
6
|
+
def initialize(source, options)
|
7
|
+
super
|
8
|
+
@block_parsers = [:block_html, :content]
|
9
|
+
@span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html]
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
def parse_content
|
13
|
+
add_text @src.scan(%r!\A.*\n!)
|
14
|
+
end
|
15
|
+
define_parser(:content, %r!\A!)
|
16
|
+
end
|
12
17
|
end
|
13
|
-
define_parser(:content, %r!\A!)
|
14
18
|
end
|
15
19
|
|
16
20
|
module Jekyll
|
17
21
|
module Converters
|
22
|
+
# SmartyPants converter.
|
23
|
+
# For more info on converters see https://jekyllrb.com/docs/plugins/converters/
|
18
24
|
class SmartyPants < Converter
|
19
25
|
safe true
|
20
26
|
priority :low
|
21
27
|
|
22
28
|
def initialize(config)
|
23
|
-
unless defined?(Kramdown)
|
24
|
-
Jekyll::External.require_with_graceful_fail "kramdown"
|
25
|
-
end
|
29
|
+
Jekyll::External.require_with_graceful_fail "kramdown" unless defined?(Kramdown)
|
26
30
|
@config = config["kramdown"].dup || {}
|
27
31
|
@config[:input] = :SmartyPants
|
28
32
|
end
|
29
33
|
|
30
|
-
|
34
|
+
# Does the given extension match this converter's list of acceptable extensions?
|
35
|
+
# Takes one argument: the file's extension (including the dot).
|
36
|
+
#
|
37
|
+
# ext - The String extension to check.
|
38
|
+
#
|
39
|
+
# Returns true if it matches, false otherwise.
|
40
|
+
def matches(_ext)
|
31
41
|
false
|
32
42
|
end
|
33
43
|
|
34
|
-
|
44
|
+
# Public: The extension to be given to the output file (including the dot).
|
45
|
+
#
|
46
|
+
# ext - The String extension or original file.
|
47
|
+
#
|
48
|
+
# Returns The String output file extension.
|
49
|
+
def output_ext(_ext)
|
35
50
|
nil
|
36
51
|
end
|
37
52
|
|
53
|
+
# Logic to do the content conversion.
|
54
|
+
#
|
55
|
+
# content - String content of file (without front matter).
|
56
|
+
#
|
57
|
+
# Returns a String of the converted content.
|
38
58
|
def convert(content)
|
39
59
|
document = Kramdown::Document.new(content, @config)
|
40
60
|
html_output = document.to_html.chomp
|