jekyll 3.10.0 → 4.0.0.pre.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +27 -50
  3. data/LICENSE +1 -1
  4. data/README.markdown +46 -17
  5. data/lib/blank_template/_config.yml +3 -0
  6. data/lib/blank_template/_layouts/default.html +12 -0
  7. data/lib/blank_template/_sass/main.scss +9 -0
  8. data/lib/blank_template/assets/css/main.scss +4 -0
  9. data/lib/blank_template/index.md +8 -0
  10. data/lib/jekyll/cache.rb +183 -0
  11. data/lib/jekyll/cleaner.rb +2 -1
  12. data/lib/jekyll/collection.rb +78 -8
  13. data/lib/jekyll/command.rb +31 -6
  14. data/lib/jekyll/commands/build.rb +11 -20
  15. data/lib/jekyll/commands/clean.rb +2 -0
  16. data/lib/jekyll/commands/doctor.rb +15 -8
  17. data/lib/jekyll/commands/help.rb +1 -1
  18. data/lib/jekyll/commands/new.rb +37 -42
  19. data/lib/jekyll/commands/new_theme.rb +30 -28
  20. data/lib/jekyll/commands/serve/live_reload_reactor.rb +6 -10
  21. data/lib/jekyll/commands/serve/servlet.rb +15 -19
  22. data/lib/jekyll/commands/serve.rb +46 -86
  23. data/lib/jekyll/configuration.rb +26 -26
  24. data/lib/jekyll/converters/identity.rb +18 -0
  25. data/lib/jekyll/converters/markdown/kramdown_parser.rb +1 -10
  26. data/lib/jekyll/converters/markdown.rb +49 -40
  27. data/lib/jekyll/converters/smartypants.rb +34 -14
  28. data/lib/jekyll/convertible.rb +11 -13
  29. data/lib/jekyll/deprecator.rb +1 -3
  30. data/lib/jekyll/document.rb +44 -41
  31. data/lib/jekyll/drops/collection_drop.rb +2 -3
  32. data/lib/jekyll/drops/document_drop.rb +2 -1
  33. data/lib/jekyll/drops/drop.rb +3 -6
  34. data/lib/jekyll/drops/excerpt_drop.rb +4 -0
  35. data/lib/jekyll/drops/site_drop.rb +4 -13
  36. data/lib/jekyll/drops/unified_payload_drop.rb +1 -0
  37. data/lib/jekyll/drops/url_drop.rb +1 -0
  38. data/lib/jekyll/entry_filter.rb +2 -1
  39. data/lib/jekyll/excerpt.rb +45 -34
  40. data/lib/jekyll/external.rb +10 -5
  41. data/lib/jekyll/filters/date_filters.rb +6 -3
  42. data/lib/jekyll/filters/grouping_filters.rb +1 -2
  43. data/lib/jekyll/filters/url_filters.rb +6 -1
  44. data/lib/jekyll/filters.rb +72 -31
  45. data/lib/jekyll/frontmatter_defaults.rb +35 -19
  46. data/lib/jekyll/hooks.rb +2 -3
  47. data/lib/jekyll/liquid_extensions.rb +0 -2
  48. data/lib/jekyll/liquid_renderer/file.rb +14 -3
  49. data/lib/jekyll/liquid_renderer/table.rb +67 -65
  50. data/lib/jekyll/liquid_renderer.rb +13 -1
  51. data/lib/jekyll/log_adapter.rb +5 -1
  52. data/lib/jekyll/mime.types +80 -195
  53. data/lib/jekyll/page.rb +10 -26
  54. data/lib/jekyll/page_without_a_file.rb +0 -4
  55. data/lib/jekyll/plugin.rb +5 -11
  56. data/lib/jekyll/plugin_manager.rb +2 -0
  57. data/lib/jekyll/reader.rb +38 -8
  58. data/lib/jekyll/readers/data_reader.rb +5 -5
  59. data/lib/jekyll/readers/layout_reader.rb +2 -12
  60. data/lib/jekyll/readers/post_reader.rb +29 -17
  61. data/lib/jekyll/readers/static_file_reader.rb +1 -1
  62. data/lib/jekyll/readers/theme_assets_reader.rb +7 -5
  63. data/lib/jekyll/regenerator.rb +4 -12
  64. data/lib/jekyll/renderer.rb +14 -25
  65. data/lib/jekyll/site.rb +78 -34
  66. data/lib/jekyll/static_file.rb +47 -11
  67. data/lib/jekyll/stevenson.rb +7 -5
  68. data/lib/jekyll/tags/highlight.rb +22 -52
  69. data/lib/jekyll/tags/include.rb +27 -48
  70. data/lib/jekyll/tags/link.rb +11 -7
  71. data/lib/jekyll/tags/post_url.rb +17 -16
  72. data/lib/jekyll/theme.rb +12 -23
  73. data/lib/jekyll/theme_builder.rb +91 -89
  74. data/lib/jekyll/url.rb +3 -2
  75. data/lib/jekyll/utils/ansi.rb +1 -1
  76. data/lib/jekyll/utils/exec.rb +0 -1
  77. data/lib/jekyll/utils/internet.rb +2 -4
  78. data/lib/jekyll/utils/platforms.rb +8 -8
  79. data/lib/jekyll/utils/thread_event.rb +1 -5
  80. data/lib/jekyll/utils/win_tz.rb +47 -18
  81. data/lib/jekyll/utils.rb +5 -4
  82. data/lib/jekyll/version.rb +1 -1
  83. data/lib/jekyll.rb +5 -0
  84. data/lib/site_template/.gitignore +2 -0
  85. data/lib/site_template/404.html +1 -0
  86. data/lib/site_template/_config.yml +17 -5
  87. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +5 -1
  88. data/lib/theme_template/gitignore.erb +1 -0
  89. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -0
  90. metadata +70 -71
  91. data/lib/jekyll/commands/serve/mime_types_charset.json +0 -71
  92. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +0 -37
  93. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +0 -112
  94. data/lib/jekyll/utils/rouge.rb +0 -22
  95. /data/lib/site_template/{about.md → about.markdown} +0 -0
  96. /data/lib/site_template/{index.md → index.markdown} +0 -0
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 4.0.0.pre.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
8
+ - Parker Moore
9
+ - Matt Rogers
8
10
  autorequire:
9
11
  bindir: exe
10
12
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
13
+ date: 2019-03-19 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: addressable
@@ -38,20 +40,6 @@ dependencies:
38
40
  - - "~>"
39
41
  - !ruby/object:Gem::Version
40
42
  version: '1.0'
41
- - !ruby/object:Gem::Dependency
42
- name: csv
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
43
  - !ruby/object:Gem::Dependency
56
44
  name: em-websocket
57
45
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +60,7 @@ dependencies:
72
60
  requirements:
73
61
  - - ">="
74
62
  - !ruby/object:Gem::Version
75
- version: '0.7'
63
+ version: 0.9.5
76
64
  - - "<"
77
65
  - !ruby/object:Gem::Version
78
66
  version: '2'
@@ -82,7 +70,7 @@ dependencies:
82
70
  requirements:
83
71
  - - ">="
84
72
  - !ruby/object:Gem::Version
85
- version: '0.7'
73
+ version: 0.9.5
86
74
  - - "<"
87
75
  - !ruby/object:Gem::Version
88
76
  version: '2'
@@ -115,117 +103,106 @@ dependencies:
115
103
  - !ruby/object:Gem::Version
116
104
  version: '2.0'
117
105
  - !ruby/object:Gem::Dependency
118
- name: liquid
106
+ name: kramdown
119
107
  requirement: !ruby/object:Gem::Requirement
120
108
  requirements:
121
109
  - - "~>"
122
110
  - !ruby/object:Gem::Version
123
- version: '4.0'
111
+ version: '2.1'
124
112
  type: :runtime
125
113
  prerelease: false
126
114
  version_requirements: !ruby/object:Gem::Requirement
127
115
  requirements:
128
116
  - - "~>"
129
117
  - !ruby/object:Gem::Version
130
- version: '4.0'
118
+ version: '2.1'
131
119
  - !ruby/object:Gem::Dependency
132
- name: mercenary
120
+ name: kramdown-parser-gfm
133
121
  requirement: !ruby/object:Gem::Requirement
134
122
  requirements:
135
123
  - - "~>"
136
124
  - !ruby/object:Gem::Version
137
- version: 0.3.3
125
+ version: '1.0'
138
126
  type: :runtime
139
127
  prerelease: false
140
128
  version_requirements: !ruby/object:Gem::Requirement
141
129
  requirements:
142
130
  - - "~>"
143
131
  - !ruby/object:Gem::Version
144
- version: 0.3.3
132
+ version: '1.0'
145
133
  - !ruby/object:Gem::Dependency
146
- name: pathutil
134
+ name: liquid
147
135
  requirement: !ruby/object:Gem::Requirement
148
136
  requirements:
149
137
  - - "~>"
150
138
  - !ruby/object:Gem::Version
151
- version: '0.9'
139
+ version: '4.0'
152
140
  type: :runtime
153
141
  prerelease: false
154
142
  version_requirements: !ruby/object:Gem::Requirement
155
143
  requirements:
156
144
  - - "~>"
157
145
  - !ruby/object:Gem::Version
158
- version: '0.9'
146
+ version: '4.0'
159
147
  - !ruby/object:Gem::Dependency
160
- name: rouge
148
+ name: mercenary
161
149
  requirement: !ruby/object:Gem::Requirement
162
150
  requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: '1.7'
166
- - - "<"
151
+ - - "~>"
167
152
  - !ruby/object:Gem::Version
168
- version: '4'
153
+ version: 0.3.3
169
154
  type: :runtime
170
155
  prerelease: false
171
156
  version_requirements: !ruby/object:Gem::Requirement
172
157
  requirements:
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- version: '1.7'
176
- - - "<"
158
+ - - "~>"
177
159
  - !ruby/object:Gem::Version
178
- version: '4'
160
+ version: 0.3.3
179
161
  - !ruby/object:Gem::Dependency
180
- name: safe_yaml
162
+ name: pathutil
181
163
  requirement: !ruby/object:Gem::Requirement
182
164
  requirements:
183
165
  - - "~>"
184
166
  - !ruby/object:Gem::Version
185
- version: '1.0'
167
+ version: '0.9'
186
168
  type: :runtime
187
169
  prerelease: false
188
170
  version_requirements: !ruby/object:Gem::Requirement
189
171
  requirements:
190
172
  - - "~>"
191
173
  - !ruby/object:Gem::Version
192
- version: '1.0'
174
+ version: '0.9'
193
175
  - !ruby/object:Gem::Dependency
194
- name: webrick
176
+ name: rouge
195
177
  requirement: !ruby/object:Gem::Requirement
196
178
  requirements:
197
- - - ">="
179
+ - - "~>"
198
180
  - !ruby/object:Gem::Version
199
- version: '1.0'
181
+ version: '3.0'
200
182
  type: :runtime
201
183
  prerelease: false
202
184
  version_requirements: !ruby/object:Gem::Requirement
203
185
  requirements:
204
- - - ">="
186
+ - - "~>"
205
187
  - !ruby/object:Gem::Version
206
- version: '1.0'
188
+ version: '3.0'
207
189
  - !ruby/object:Gem::Dependency
208
- name: kramdown
190
+ name: safe_yaml
209
191
  requirement: !ruby/object:Gem::Requirement
210
192
  requirements:
211
- - - ">="
212
- - !ruby/object:Gem::Version
213
- version: '1.17'
214
- - - "<"
193
+ - - "~>"
215
194
  - !ruby/object:Gem::Version
216
- version: '3'
195
+ version: '1.0'
217
196
  type: :runtime
218
197
  prerelease: false
219
198
  version_requirements: !ruby/object:Gem::Requirement
220
199
  requirements:
221
- - - ">="
222
- - !ruby/object:Gem::Version
223
- version: '1.17'
224
- - - "<"
200
+ - - "~>"
225
201
  - !ruby/object:Gem::Version
226
- version: '3'
202
+ version: '1.0'
227
203
  description: Jekyll is a simple, blog aware, static site generator.
228
- email: tom@mojombo.com
204
+ email:
205
+ - maintainers@jekyllrb.com
229
206
  executables:
230
207
  - jekyll
231
208
  extensions: []
@@ -237,7 +214,13 @@ files:
237
214
  - LICENSE
238
215
  - README.markdown
239
216
  - exe/jekyll
217
+ - lib/blank_template/_config.yml
218
+ - lib/blank_template/_layouts/default.html
219
+ - lib/blank_template/_sass/main.scss
220
+ - lib/blank_template/assets/css/main.scss
221
+ - lib/blank_template/index.md
240
222
  - lib/jekyll.rb
223
+ - lib/jekyll/cache.rb
241
224
  - lib/jekyll/cleaner.rb
242
225
  - lib/jekyll/collection.rb
243
226
  - lib/jekyll/command.rb
@@ -250,7 +233,6 @@ files:
250
233
  - lib/jekyll/commands/serve.rb
251
234
  - lib/jekyll/commands/serve/live_reload_reactor.rb
252
235
  - lib/jekyll/commands/serve/livereload_assets/livereload.js
253
- - lib/jekyll/commands/serve/mime_types_charset.json
254
236
  - lib/jekyll/commands/serve/servlet.rb
255
237
  - lib/jekyll/commands/serve/websockets.rb
256
238
  - lib/jekyll/configuration.rb
@@ -258,8 +240,6 @@ files:
258
240
  - lib/jekyll/converters/identity.rb
259
241
  - lib/jekyll/converters/markdown.rb
260
242
  - lib/jekyll/converters/markdown/kramdown_parser.rb
261
- - lib/jekyll/converters/markdown/rdiscount_parser.rb
262
- - lib/jekyll/converters/markdown/redcarpet_parser.rb
263
243
  - lib/jekyll/converters/smartypants.rb
264
244
  - lib/jekyll/convertible.rb
265
245
  - lib/jekyll/deprecator.rb
@@ -322,7 +302,6 @@ files:
322
302
  - lib/jekyll/utils/exec.rb
323
303
  - lib/jekyll/utils/internet.rb
324
304
  - lib/jekyll/utils/platforms.rb
325
- - lib/jekyll/utils/rouge.rb
326
305
  - lib/jekyll/utils/thread_event.rb
327
306
  - lib/jekyll/utils/win_tz.rb
328
307
  - lib/jekyll/version.rb
@@ -330,8 +309,8 @@ files:
330
309
  - lib/site_template/404.html
331
310
  - lib/site_template/_config.yml
332
311
  - lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb
333
- - lib/site_template/about.md
334
- - lib/site_template/index.md
312
+ - lib/site_template/about.markdown
313
+ - lib/site_template/index.markdown
335
314
  - lib/theme_template/CODE_OF_CONDUCT.md.erb
336
315
  - lib/theme_template/Gemfile
337
316
  - lib/theme_template/LICENSE.txt.erb
@@ -346,13 +325,33 @@ files:
346
325
  - lib/theme_template/gitignore.erb
347
326
  - lib/theme_template/theme.gemspec.erb
348
327
  - rubocop/jekyll.rb
328
+ - rubocop/jekyll/assert_equal_literal_actual.rb
349
329
  - rubocop/jekyll/no_p_allowed.rb
350
330
  - rubocop/jekyll/no_puts_allowed.rb
351
- homepage: https://github.com/jekyll/jekyll
331
+ homepage: https://jekyllrb.com
352
332
  licenses:
353
333
  - MIT
354
- metadata: {}
355
- post_install_message:
334
+ metadata:
335
+ bug_tracker_uri: https://github.com/jekyll/jekyll/issues
336
+ changelog_uri: https://github.com/jekyll/jekyll/releases
337
+ homepage_uri: https://jekyllrb.com
338
+ source_code_uri: https://github.com/jekyll/jekyll
339
+ post_install_message: |
340
+ ----------------------------------------------------------------------------------
341
+ This version of Jekyll comes with some major changes.
342
+
343
+ Most notably:
344
+ * Our `link` tag now comes with the `relative_url` filter incorporated into it.
345
+ You should no longer prepend `{{ site.baseurl }}` to `{% link foo.md %}`
346
+ For further details: https://github.com/jekyll/jekyll/pull/6727
347
+
348
+ * Our `highlight` tag no longer parses Liquid and Liquid-like constructs in the
349
+ tag's content body. While this means you no longer need to enclose the content
350
+ within a `{% raw %}{% endraw %}` block, it also means that you can no longer
351
+ do the following as well:
352
+ `{% highlight html %}{% include snippet.html %}{% endhighlight %}`
353
+ For further details: https://github.com/jekyll/jekyll/pull/6821
354
+ ----------------------------------------------------------------------------------
356
355
  rdoc_options:
357
356
  - "--charset=UTF-8"
358
357
  require_paths:
@@ -361,15 +360,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
361
360
  requirements:
362
361
  - - ">="
363
362
  - !ruby/object:Gem::Version
364
- version: 2.1.0
363
+ version: 2.4.0
365
364
  required_rubygems_version: !ruby/object:Gem::Requirement
366
365
  requirements:
367
366
  - - ">="
368
367
  - !ruby/object:Gem::Version
369
- version: '0'
368
+ version: 2.7.0
370
369
  requirements: []
371
- rubygems_version: 3.1.6
370
+ rubygems_version: 3.0.3
372
371
  signing_key:
373
- specification_version: 2
372
+ specification_version: 4
374
373
  summary: A simple, blog aware, static site generator.
375
374
  test_files: []
@@ -1,71 +0,0 @@
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
- }
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- module Converters
5
- class Markdown
6
- class RDiscountParser
7
- def initialize(config)
8
- unless defined?(RDiscount)
9
- Jekyll::External.require_with_graceful_fail "rdiscount"
10
- end
11
- @config = config
12
- @rdiscount_extensions = @config["rdiscount"]["extensions"].map(&:to_sym)
13
- end
14
-
15
- def convert(content)
16
- rd = RDiscount.new(content, *@rdiscount_extensions)
17
- html = rd.to_html
18
- if @config["rdiscount"]["toc_token"]
19
- html = replace_generated_toc(rd, html, @config["rdiscount"]["toc_token"])
20
- end
21
- html
22
- end
23
-
24
- private
25
- def replace_generated_toc(rd_instance, html, toc_token)
26
- if rd_instance.generate_toc && html.include?(toc_token)
27
- utf8_toc = rd_instance.toc_content
28
- utf8_toc.force_encoding("utf-8") if utf8_toc.respond_to?(:force_encoding)
29
- html.gsub(toc_token, utf8_toc)
30
- else
31
- html
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,112 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Jekyll::Converters::Markdown::RedcarpetParser
4
- module CommonMethods
5
- def add_code_tags(code, lang)
6
- code = code.to_s
7
- code = code.sub(
8
- %r!<pre>!,
9
- "<pre><code class=\"language-#{lang}\" data-lang=\"#{lang}\">"
10
- )
11
- code = code.sub(%r!</pre>!, "</code></pre>")
12
- code
13
- end
14
- end
15
-
16
- module WithPygments
17
- include CommonMethods
18
- def block_code(code, lang)
19
- unless defined?(Pygments)
20
- Jekyll::External.require_with_graceful_fail("pygments")
21
- end
22
- lang = lang && lang.split.first || "text"
23
- add_code_tags(
24
- Pygments.highlight(
25
- code,
26
- {
27
- :lexer => lang,
28
- :options => { :encoding => "utf-8" },
29
- }
30
- ),
31
- lang
32
- )
33
- end
34
- end
35
-
36
- module WithoutHighlighting
37
- require "cgi"
38
-
39
- include CommonMethods
40
-
41
- def code_wrap(code)
42
- "<figure class=\"highlight\"><pre>#{CGI.escapeHTML(code)}</pre></figure>"
43
- end
44
-
45
- def block_code(code, lang)
46
- lang = lang && lang.split.first || "text"
47
- add_code_tags(code_wrap(code), lang)
48
- end
49
- end
50
-
51
- module WithRouge
52
- def block_code(_code, lang)
53
- code = "<pre>#{super}</pre>"
54
-
55
- "<div class=\"highlight\">#{add_code_tags(code, lang)}</div>"
56
- end
57
-
58
- protected
59
- def rouge_formatter(_lexer)
60
- Jekyll::Utils::Rouge.html_formatter(:wrap => false)
61
- end
62
- end
63
-
64
- def initialize(config)
65
- unless defined?(Redcarpet)
66
- Jekyll::External.require_with_graceful_fail("redcarpet")
67
- end
68
- @config = config
69
- @redcarpet_extensions = {}
70
- @config["redcarpet"]["extensions"].each do |e|
71
- @redcarpet_extensions[e.to_sym] = true
72
- end
73
-
74
- @renderer ||= class_with_proper_highlighter(@config["highlighter"])
75
- end
76
-
77
- def class_with_proper_highlighter(highlighter)
78
- Class.new(Redcarpet::Render::HTML) do
79
- case highlighter
80
- when "pygments"
81
- include WithPygments
82
- when "rouge"
83
- Jekyll::External.require_with_graceful_fail(%w(
84
- rouge rouge/plugins/redcarpet
85
- ))
86
-
87
- unless Gem::Version.new(Rouge.version) > Gem::Version.new("1.3.0")
88
- abort "Please install Rouge 1.3.0 or greater and try running Jekyll again."
89
- end
90
-
91
- include Rouge::Plugins::Redcarpet
92
- include CommonMethods
93
- include WithRouge
94
- else
95
- include WithoutHighlighting
96
- end
97
- end
98
- end
99
-
100
- def convert(content)
101
- @redcarpet_extensions[:fenced_code_blocks] = \
102
- !@redcarpet_extensions[:no_fenced_code_blocks]
103
- if @redcarpet_extensions[:smart]
104
- @renderer.send :include, Redcarpet::Render::SmartyPants
105
- end
106
- markdown = Redcarpet::Markdown.new(
107
- @renderer.new(@redcarpet_extensions),
108
- @redcarpet_extensions
109
- )
110
- markdown.render(content)
111
- end
112
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Jekyll::External.require_with_graceful_fail("rouge")
4
-
5
- module Jekyll
6
- module Utils
7
- module Rouge
8
-
9
- def self.html_formatter(*args)
10
- if old_api?
11
- ::Rouge::Formatters::HTML.new(*args)
12
- else
13
- ::Rouge::Formatters::HTMLLegacy.new(*args)
14
- end
15
- end
16
-
17
- def self.old_api?
18
- ::Rouge.version.to_s < "2"
19
- end
20
- end
21
- end
22
- end
File without changes
File without changes