jekyll 4.2.1 → 4.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +474 -350
  3. data/LICENSE +21 -21
  4. data/README.markdown +83 -86
  5. data/exe/jekyll +57 -57
  6. data/lib/blank_template/_config.yml +3 -3
  7. data/lib/blank_template/_layouts/default.html +12 -12
  8. data/lib/blank_template/_sass/{main.scss → base.scss} +9 -9
  9. data/lib/blank_template/assets/css/main.scss +4 -4
  10. data/lib/blank_template/index.md +8 -8
  11. data/lib/jekyll/cache.rb +186 -190
  12. data/lib/jekyll/cleaner.rb +111 -111
  13. data/lib/jekyll/collection.rb +310 -309
  14. data/lib/jekyll/command.rb +105 -105
  15. data/lib/jekyll/commands/build.rb +82 -93
  16. data/lib/jekyll/commands/clean.rb +44 -45
  17. data/lib/jekyll/commands/doctor.rb +177 -177
  18. data/lib/jekyll/commands/help.rb +34 -34
  19. data/lib/jekyll/commands/new.rb +168 -169
  20. data/lib/jekyll/commands/new_theme.rb +39 -40
  21. data/lib/jekyll/commands/serve/live_reload_reactor.rb +119 -122
  22. data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
  23. data/lib/jekyll/commands/serve/mime_types_charset.json +71 -0
  24. data/lib/jekyll/commands/serve/servlet.rb +206 -202
  25. data/lib/jekyll/commands/serve/websockets.rb +81 -81
  26. data/lib/jekyll/commands/serve.rb +367 -362
  27. data/lib/jekyll/configuration.rb +313 -313
  28. data/lib/jekyll/converter.rb +54 -54
  29. data/lib/jekyll/converters/identity.rb +41 -41
  30. data/lib/jekyll/converters/markdown/kramdown_parser.rb +197 -199
  31. data/lib/jekyll/converters/markdown.rb +113 -113
  32. data/lib/jekyll/converters/smartypants.rb +70 -70
  33. data/lib/jekyll/convertible.rb +257 -257
  34. data/lib/jekyll/deprecator.rb +50 -50
  35. data/lib/jekyll/document.rb +543 -544
  36. data/lib/jekyll/drops/collection_drop.rb +20 -20
  37. data/lib/jekyll/drops/document_drop.rb +74 -70
  38. data/lib/jekyll/drops/drop.rb +293 -293
  39. data/lib/jekyll/drops/excerpt_drop.rb +23 -19
  40. data/lib/jekyll/drops/jekyll_drop.rb +32 -32
  41. data/lib/jekyll/drops/site_drop.rb +66 -66
  42. data/lib/jekyll/drops/static_file_drop.rb +14 -14
  43. data/lib/jekyll/drops/theme_drop.rb +36 -0
  44. data/lib/jekyll/drops/unified_payload_drop.rb +30 -26
  45. data/lib/jekyll/drops/url_drop.rb +140 -140
  46. data/lib/jekyll/entry_filter.rb +117 -121
  47. data/lib/jekyll/errors.rb +20 -20
  48. data/lib/jekyll/excerpt.rb +200 -201
  49. data/lib/jekyll/external.rb +75 -79
  50. data/lib/jekyll/filters/date_filters.rb +110 -110
  51. data/lib/jekyll/filters/grouping_filters.rb +64 -64
  52. data/lib/jekyll/filters/url_filters.rb +98 -98
  53. data/lib/jekyll/filters.rb +532 -535
  54. data/lib/jekyll/frontmatter_defaults.rb +238 -240
  55. data/lib/jekyll/generator.rb +5 -5
  56. data/lib/jekyll/hooks.rb +107 -107
  57. data/lib/jekyll/inclusion.rb +32 -32
  58. data/lib/jekyll/layout.rb +55 -67
  59. data/lib/jekyll/liquid_extensions.rb +22 -22
  60. data/lib/jekyll/liquid_renderer/file.rb +77 -77
  61. data/lib/jekyll/liquid_renderer/table.rb +45 -55
  62. data/lib/jekyll/liquid_renderer.rb +80 -80
  63. data/lib/jekyll/log_adapter.rb +151 -151
  64. data/lib/jekyll/mime.types +939 -866
  65. data/lib/jekyll/page.rb +215 -217
  66. data/lib/jekyll/page_excerpt.rb +25 -25
  67. data/lib/jekyll/page_without_a_file.rb +14 -14
  68. data/lib/jekyll/path_manager.rb +74 -74
  69. data/lib/jekyll/plugin.rb +92 -92
  70. data/lib/jekyll/plugin_manager.rb +123 -115
  71. data/lib/jekyll/profiler.rb +51 -58
  72. data/lib/jekyll/publisher.rb +23 -23
  73. data/lib/jekyll/reader.rb +209 -192
  74. data/lib/jekyll/readers/collection_reader.rb +23 -23
  75. data/lib/jekyll/readers/data_reader.rb +113 -79
  76. data/lib/jekyll/readers/layout_reader.rb +62 -62
  77. data/lib/jekyll/readers/page_reader.rb +25 -25
  78. data/lib/jekyll/readers/post_reader.rb +85 -85
  79. data/lib/jekyll/readers/static_file_reader.rb +25 -25
  80. data/lib/jekyll/readers/theme_assets_reader.rb +52 -52
  81. data/lib/jekyll/regenerator.rb +195 -195
  82. data/lib/jekyll/related_posts.rb +52 -52
  83. data/lib/jekyll/renderer.rb +263 -265
  84. data/lib/jekyll/site.rb +576 -551
  85. data/lib/jekyll/static_file.rb +205 -208
  86. data/lib/jekyll/stevenson.rb +60 -60
  87. data/lib/jekyll/tags/highlight.rb +114 -110
  88. data/lib/jekyll/tags/include.rb +275 -275
  89. data/lib/jekyll/tags/link.rb +42 -42
  90. data/lib/jekyll/tags/post_url.rb +106 -106
  91. data/lib/jekyll/theme.rb +90 -86
  92. data/lib/jekyll/theme_builder.rb +121 -121
  93. data/lib/jekyll/url.rb +167 -167
  94. data/lib/jekyll/utils/ansi.rb +57 -57
  95. data/lib/jekyll/utils/exec.rb +26 -26
  96. data/lib/jekyll/utils/internet.rb +37 -37
  97. data/lib/jekyll/utils/platforms.rb +67 -67
  98. data/lib/jekyll/utils/thread_event.rb +31 -31
  99. data/lib/jekyll/utils/win_tz.rb +46 -75
  100. data/lib/jekyll/utils.rb +371 -367
  101. data/lib/jekyll/version.rb +5 -5
  102. data/lib/jekyll.rb +195 -195
  103. data/lib/site_template/.gitignore +5 -5
  104. data/lib/site_template/404.html +25 -25
  105. data/lib/site_template/_config.yml +55 -55
  106. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
  107. data/lib/site_template/about.markdown +18 -18
  108. data/lib/site_template/index.markdown +6 -6
  109. data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
  110. data/lib/theme_template/Gemfile +4 -4
  111. data/lib/theme_template/LICENSE.txt.erb +21 -21
  112. data/lib/theme_template/README.md.erb +50 -52
  113. data/lib/theme_template/_layouts/default.html +1 -1
  114. data/lib/theme_template/_layouts/page.html +5 -5
  115. data/lib/theme_template/_layouts/post.html +5 -5
  116. data/lib/theme_template/example/_config.yml.erb +1 -1
  117. data/lib/theme_template/example/_post.md +12 -12
  118. data/lib/theme_template/example/index.html +14 -14
  119. data/lib/theme_template/example/style.scss +7 -7
  120. data/lib/theme_template/gitignore.erb +6 -6
  121. data/lib/theme_template/theme.gemspec.erb +16 -16
  122. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
  123. data/rubocop/jekyll/no_p_allowed.rb +23 -23
  124. data/rubocop/jekyll/no_puts_allowed.rb +23 -23
  125. data/rubocop/jekyll.rb +5 -5
  126. metadata +64 -18
@@ -1,54 +1,54 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class Converter < Plugin
5
- # Public: Get or set the highlighter prefix. When an argument is specified,
6
- # the prefix will be set. If no argument is specified, the current prefix
7
- # will be returned.
8
- #
9
- # highlighter_prefix - The String prefix (default: nil).
10
- #
11
- # Returns the String prefix.
12
- def self.highlighter_prefix(highlighter_prefix = nil)
13
- unless defined?(@highlighter_prefix) && highlighter_prefix.nil?
14
- @highlighter_prefix = highlighter_prefix
15
- end
16
- @highlighter_prefix
17
- end
18
-
19
- # Public: Get or set the highlighter suffix. When an argument is specified,
20
- # the suffix will be set. If no argument is specified, the current suffix
21
- # will be returned.
22
- #
23
- # highlighter_suffix - The String suffix (default: nil).
24
- #
25
- # Returns the String suffix.
26
- def self.highlighter_suffix(highlighter_suffix = nil)
27
- unless defined?(@highlighter_suffix) && highlighter_suffix.nil?
28
- @highlighter_suffix = highlighter_suffix
29
- end
30
- @highlighter_suffix
31
- end
32
-
33
- # Initialize the converter.
34
- #
35
- # Returns an initialized Converter.
36
- def initialize(config = {})
37
- @config = config
38
- end
39
-
40
- # Get the highlighter prefix.
41
- #
42
- # Returns the String prefix.
43
- def highlighter_prefix
44
- self.class.highlighter_prefix
45
- end
46
-
47
- # Get the highlighter suffix.
48
- #
49
- # Returns the String suffix.
50
- def highlighter_suffix
51
- self.class.highlighter_suffix
52
- end
53
- end
54
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Converter < Plugin
5
+ # Public: Get or set the highlighter prefix. When an argument is specified,
6
+ # the prefix will be set. If no argument is specified, the current prefix
7
+ # will be returned.
8
+ #
9
+ # highlighter_prefix - The String prefix (default: nil).
10
+ #
11
+ # Returns the String prefix.
12
+ def self.highlighter_prefix(highlighter_prefix = nil)
13
+ unless defined?(@highlighter_prefix) && highlighter_prefix.nil?
14
+ @highlighter_prefix = highlighter_prefix
15
+ end
16
+ @highlighter_prefix
17
+ end
18
+
19
+ # Public: Get or set the highlighter suffix. When an argument is specified,
20
+ # the suffix will be set. If no argument is specified, the current suffix
21
+ # will be returned.
22
+ #
23
+ # highlighter_suffix - The String suffix (default: nil).
24
+ #
25
+ # Returns the String suffix.
26
+ def self.highlighter_suffix(highlighter_suffix = nil)
27
+ unless defined?(@highlighter_suffix) && highlighter_suffix.nil?
28
+ @highlighter_suffix = highlighter_suffix
29
+ end
30
+ @highlighter_suffix
31
+ end
32
+
33
+ # Initialize the converter.
34
+ #
35
+ # Returns an initialized Converter.
36
+ def initialize(config = {})
37
+ @config = config
38
+ end
39
+
40
+ # Get the highlighter prefix.
41
+ #
42
+ # Returns the String prefix.
43
+ def highlighter_prefix
44
+ self.class.highlighter_prefix
45
+ end
46
+
47
+ # Get the highlighter suffix.
48
+ #
49
+ # Returns the String suffix.
50
+ def highlighter_suffix
51
+ self.class.highlighter_suffix
52
+ end
53
+ end
54
+ end
@@ -1,41 +1,41 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- module Converters
5
- # Identity converter. Returns same content as given.
6
- # For more info on converters see https://jekyllrb.com/docs/plugins/converters/
7
- class Identity < Converter
8
- safe true
9
-
10
- priority :lowest
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.
18
- def matches(_ext)
19
- true
20
- end
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.
27
- def output_ext(ext)
28
- ext
29
- end
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.
36
- def convert(content)
37
- content
38
- end
39
- end
40
- end
41
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Converters
5
+ # Identity converter. Returns same content as given.
6
+ # For more info on converters see https://jekyllrb.com/docs/plugins/converters/
7
+ class Identity < Converter
8
+ safe true
9
+
10
+ priority :lowest
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.
18
+ def matches(_ext)
19
+ true
20
+ end
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.
27
+ def output_ext(ext)
28
+ ext
29
+ end
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.
36
+ def convert(content)
37
+ content
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,199 +1,197 @@
1
- # Frozen-string-literal: true
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
-
71
- module Jekyll
72
- module Converters
73
- class Markdown
74
- class KramdownParser
75
- CODERAY_DEFAULTS = {
76
- "css" => "style",
77
- "bold_every" => 10,
78
- "line_numbers" => "inline",
79
- "line_number_start" => 1,
80
- "tab_width" => 4,
81
- "wrap" => "div",
82
- }.freeze
83
-
84
- def initialize(config)
85
- @main_fallback_highlighter = config["highlighter"] || "rouge"
86
- @config = config["kramdown"] || {}
87
- @highlighter = nil
88
- setup
89
- load_dependencies
90
- end
91
-
92
- # Setup and normalize the configuration:
93
- # * Create Kramdown if it doesn't exist.
94
- # * Set syntax_highlighter, detecting enable_coderay and merging
95
- # highlighter if none.
96
- # * Merge kramdown[coderay] into syntax_highlighter_opts stripping coderay_.
97
- # * Make sure `syntax_highlighter_opts` exists.
98
-
99
- def setup
100
- @config["syntax_highlighter"] ||= highlighter
101
- @config["syntax_highlighter_opts"] ||= {}
102
- @config["syntax_highlighter_opts"]["default_lang"] ||= "plaintext"
103
- @config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"]
104
- @config["coderay"] ||= {} # XXX: Legacy.
105
- modernize_coderay_config
106
- end
107
-
108
- def convert(content)
109
- document = Kramdown::JekyllDocument.new(content, @config)
110
- html_output = document.to_html
111
- if @config["show_warnings"]
112
- document.warnings.each do |warning|
113
- Jekyll.logger.warn "Kramdown warning:", warning
114
- end
115
- end
116
- html_output
117
- end
118
-
119
- private
120
-
121
- def load_dependencies
122
- require "kramdown-parser-gfm" if @config["input"] == "GFM"
123
-
124
- if highlighter == "coderay"
125
- Jekyll::External.require_with_graceful_fail("kramdown-syntax-coderay")
126
- end
127
-
128
- # `mathjax` emgine is bundled within kramdown-2.x and will be handled by
129
- # kramdown itself.
130
- if (math_engine = @config["math_engine"]) && math_engine != "mathjax"
131
- Jekyll::External.require_with_graceful_fail("kramdown-math-#{math_engine}")
132
- end
133
- end
134
-
135
- # config[kramdown][syntax_higlighter] >
136
- # config[kramdown][enable_coderay] >
137
- # config[highlighter]
138
- # Where `enable_coderay` is now deprecated because Kramdown
139
- # supports Rouge now too.
140
- def highlighter
141
- return @highlighter if @highlighter
142
-
143
- if @config["syntax_highlighter"]
144
- return @highlighter = @config[
145
- "syntax_highlighter"
146
- ]
147
- end
148
-
149
- @highlighter = begin
150
- if @config.key?("enable_coderay") && @config["enable_coderay"]
151
- Jekyll::Deprecator.deprecation_message(
152
- "You are using 'enable_coderay', " \
153
- "use syntax_highlighter: coderay in your configuration file."
154
- )
155
-
156
- "coderay"
157
- else
158
- @main_fallback_highlighter
159
- end
160
- end
161
- end
162
-
163
- def strip_coderay_prefix(hash)
164
- hash.each_with_object({}) do |(key, val), hsh|
165
- cleaned_key = key.to_s.gsub(%r!\Acoderay_!, "")
166
-
167
- if key != cleaned_key
168
- Jekyll::Deprecator.deprecation_message(
169
- "You are using '#{key}'. Normalizing to #{cleaned_key}."
170
- )
171
- end
172
-
173
- hsh[cleaned_key] = val
174
- end
175
- end
176
-
177
- # If our highlighter is CodeRay we go in to merge the CodeRay defaults
178
- # with your "coderay" key if it's there, deprecating it in the
179
- # process of you using it.
180
- def modernize_coderay_config
181
- unless @config["coderay"].empty?
182
- Jekyll::Deprecator.deprecation_message(
183
- "You are using 'kramdown.coderay' in your configuration, " \
184
- "please use 'syntax_highlighter_opts' instead."
185
- )
186
-
187
- @config["syntax_highlighter_opts"] = begin
188
- strip_coderay_prefix(
189
- @config["syntax_highlighter_opts"] \
190
- .merge(CODERAY_DEFAULTS) \
191
- .merge(@config["coderay"])
192
- )
193
- end
194
- end
195
- end
196
- end
197
- end
198
- end
199
- end
1
+ # frozen_string_literal: true
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
+
71
+ module Jekyll
72
+ module Converters
73
+ class Markdown
74
+ class KramdownParser
75
+ CODERAY_DEFAULTS = {
76
+ "css" => "style",
77
+ "bold_every" => 10,
78
+ "line_numbers" => "inline",
79
+ "line_number_start" => 1,
80
+ "tab_width" => 4,
81
+ "wrap" => "div",
82
+ }.freeze
83
+
84
+ def initialize(config)
85
+ @main_fallback_highlighter = config["highlighter"] || "rouge"
86
+ @config = config["kramdown"] || {}
87
+ @highlighter = nil
88
+ setup
89
+ load_dependencies
90
+ end
91
+
92
+ # Setup and normalize the configuration:
93
+ # * Create Kramdown if it doesn't exist.
94
+ # * Set syntax_highlighter, detecting enable_coderay and merging
95
+ # highlighter if none.
96
+ # * Merge kramdown[coderay] into syntax_highlighter_opts stripping coderay_.
97
+ # * Make sure `syntax_highlighter_opts` exists.
98
+
99
+ def setup
100
+ @config["syntax_highlighter"] ||= highlighter
101
+ @config["syntax_highlighter_opts"] ||= {}
102
+ @config["syntax_highlighter_opts"]["default_lang"] ||= "plaintext"
103
+ @config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"]
104
+ @config["coderay"] ||= {} # XXX: Legacy.
105
+ modernize_coderay_config
106
+ end
107
+
108
+ def convert(content)
109
+ document = Kramdown::JekyllDocument.new(content, @config)
110
+ html_output = document.to_html
111
+ if @config["show_warnings"]
112
+ document.warnings.each do |warning|
113
+ Jekyll.logger.warn "Kramdown warning:", warning
114
+ end
115
+ end
116
+ html_output
117
+ end
118
+
119
+ private
120
+
121
+ def load_dependencies
122
+ require "kramdown-parser-gfm" if @config["input"] == "GFM"
123
+
124
+ if highlighter == "coderay"
125
+ Jekyll::External.require_with_graceful_fail("kramdown-syntax-coderay")
126
+ end
127
+
128
+ # `mathjax` engine is bundled within kramdown-2.x and will be handled by
129
+ # kramdown itself.
130
+ if (math_engine = @config["math_engine"]) && math_engine != "mathjax"
131
+ Jekyll::External.require_with_graceful_fail("kramdown-math-#{math_engine}")
132
+ end
133
+ end
134
+
135
+ # config[kramdown][syntax_highlighter] >
136
+ # config[kramdown][enable_coderay] >
137
+ # config[highlighter]
138
+ # Where `enable_coderay` is now deprecated because Kramdown
139
+ # supports Rouge now too.
140
+ def highlighter
141
+ return @highlighter if @highlighter
142
+
143
+ if @config["syntax_highlighter"]
144
+ return @highlighter = @config[
145
+ "syntax_highlighter"
146
+ ]
147
+ end
148
+
149
+ @highlighter = if @config.key?("enable_coderay") && @config["enable_coderay"]
150
+ Jekyll::Deprecator.deprecation_message(
151
+ "You are using 'enable_coderay', " \
152
+ "use syntax_highlighter: coderay in your configuration file."
153
+ )
154
+
155
+ "coderay"
156
+ else
157
+ @main_fallback_highlighter
158
+ end
159
+ end
160
+
161
+ def strip_coderay_prefix(hash)
162
+ hash.each_with_object({}) do |(key, val), hsh|
163
+ cleaned_key = key.to_s.delete_prefix("coderay_")
164
+
165
+ if key != cleaned_key
166
+ Jekyll::Deprecator.deprecation_message(
167
+ "You are using '#{key}'. Normalizing to #{cleaned_key}."
168
+ )
169
+ end
170
+
171
+ hsh[cleaned_key] = val
172
+ end
173
+ end
174
+
175
+ # If our highlighter is CodeRay we go in to merge the CodeRay defaults
176
+ # with your "coderay" key if it's there, deprecating it in the
177
+ # process of you using it.
178
+ def modernize_coderay_config
179
+ unless @config["coderay"].empty?
180
+ Jekyll::Deprecator.deprecation_message(
181
+ "You are using 'kramdown.coderay' in your configuration, " \
182
+ "please use 'syntax_highlighter_opts' instead."
183
+ )
184
+
185
+ @config["syntax_highlighter_opts"] = begin
186
+ strip_coderay_prefix(
187
+ @config["syntax_highlighter_opts"] \
188
+ .merge(CODERAY_DEFAULTS) \
189
+ .merge(@config["coderay"])
190
+ )
191
+ end
192
+ end
193
+ end
194
+ end
195
+ end
196
+ end
197
+ end