jekyll-webawesome 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/jekyll-webawesome.gemspec +1 -1
- data/lib/jekyll/webawesome/code_block_transformer.rb +35 -50
- data/lib/jekyll/webawesome/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: adeebc3995bb614e0c221f9424cf22200eb70c062f8c4d5500bc8e92f935b0f6
|
|
4
|
+
data.tar.gz: a49c3aec2dc3159b4f03854aa2646fd3410cbae910e4c060e0207f45fbe29a2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0eb010999a613a1cd9e58e29a852f6c479ce0d4e11c91e371f6406b2ee66ae4cf1d6a2d739ac0ffb6a85eb63dd7453d1e4b6798b165d5453bccec55a68b3798f
|
|
7
|
+
data.tar.gz: 15cbd4e4f50c414ac5ce11f9f34da33b6afae15edeb4a50ed9b894ef76215d4354dd1cc0b80847c954c137374aeeb9f0816146a6c4d709fa2b163d29f5a04ae4
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
6
|
|
|
7
|
+
## [0.16.0] - 2026-05-05
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Internal: code block protection (replacing fenced code blocks with placeholders before Markawesome transforms run, so `:::info`/`^^^`/`@@@` examples inside fenced code stay intact) is now delegated to `Markawesome::CodeBlockProtector` instead of being implemented locally. The Jekyll-specific `{% highlight %}` substitution at priority 15 stays in this gem. No behavior change for Jekyll users.
|
|
12
|
+
- Updated `markawesome` dependency to `~> 0.10`. The 0.10.0 release adds `Markawesome::PlainMarkdownRenderer` (an alternate renderer that emits clean GFM instead of HTML) and exposes `Markawesome::CodeBlockProtector` as a public helper.
|
|
13
|
+
|
|
7
14
|
## [0.15.0] - 2026-03-12
|
|
8
15
|
|
|
9
16
|
### Added
|
data/jekyll-webawesome.gemspec
CHANGED
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
spec.require_paths = ['lib']
|
|
34
34
|
|
|
35
35
|
spec.add_dependency 'jekyll', '>= 3.7', '< 5.0'
|
|
36
|
-
spec.add_dependency 'markawesome', '~> 0.
|
|
36
|
+
spec.add_dependency 'markawesome', '~> 0.10'
|
|
37
37
|
|
|
38
38
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
39
39
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
@@ -1,71 +1,61 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'markawesome/code_block_protector'
|
|
4
|
+
|
|
3
5
|
module Jekyll
|
|
4
6
|
module WebAwesome
|
|
5
|
-
#
|
|
7
|
+
# Protects markdown fenced code blocks before Markawesome transforms
|
|
8
|
+
# run, and substitutes them with Jekyll `{% highlight %}` tags after,
|
|
9
|
+
# so code examples containing `:::`/`^^^`/`@@@` survive intact and
|
|
10
|
+
# language-tagged blocks still render with Jekyll's syntax highlighter.
|
|
11
|
+
#
|
|
12
|
+
# Protection/restore is delegated to Markawesome::CodeBlockProtector;
|
|
13
|
+
# the `{% highlight %}` substitution at priority 15 is Jekyll-specific
|
|
14
|
+
# and stays here.
|
|
6
15
|
module CodeBlockTransformer
|
|
7
|
-
CODE_BLOCK_PATTERN =
|
|
16
|
+
CODE_BLOCK_PATTERN = Markawesome::CodeBlockProtector::CODE_BLOCK_PATTERN
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
@@protected_blocks = {}
|
|
18
|
+
@protected_blocks = {}
|
|
11
19
|
|
|
12
20
|
class << self
|
|
21
|
+
attr_reader :protected_blocks
|
|
22
|
+
|
|
13
23
|
def clear_protected_blocks
|
|
14
|
-
|
|
24
|
+
@protected_blocks.clear
|
|
15
25
|
end
|
|
16
26
|
|
|
17
27
|
# Check if pages transformation is enabled
|
|
18
28
|
def transform_pages_enabled?(site)
|
|
19
|
-
# Check plugin configuration first
|
|
20
29
|
return Jekyll::WebAwesome.configuration.transform_pages if Jekyll::WebAwesome.configuration
|
|
21
|
-
|
|
22
|
-
# Check site config
|
|
23
30
|
return site.config.dig('webawesome', 'transform_pages') if site.config.dig('webawesome', 'transform_pages') != nil
|
|
24
31
|
|
|
25
|
-
# Default to true
|
|
26
32
|
true
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
# Check if documents transformation is enabled
|
|
30
36
|
def transform_documents_enabled?(site)
|
|
31
|
-
# Check plugin configuration first
|
|
32
37
|
return Jekyll::WebAwesome.configuration.transform_documents if Jekyll::WebAwesome.configuration
|
|
33
|
-
|
|
34
|
-
# Check site config
|
|
35
38
|
return site.config.dig('webawesome', 'transform_documents') if site.config.dig('webawesome', 'transform_documents') != nil
|
|
36
39
|
|
|
37
|
-
# Default to true
|
|
38
40
|
true
|
|
39
41
|
end
|
|
40
42
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
details_pattern = /^\^\^\^/m
|
|
46
|
-
tabs_pattern = /^\+{6}/m
|
|
47
|
-
|
|
48
|
-
content.match?(callout_pattern) || content.match?(details_pattern) || content.match?(tabs_pattern)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Protect all code blocks by converting them to placeholders
|
|
52
|
-
# This prevents markdown processing from corrupting code blocks inside custom elements
|
|
43
|
+
# Protect all code blocks by converting them to placeholders via
|
|
44
|
+
# Markawesome::CodeBlockProtector. The resulting token map is
|
|
45
|
+
# merged into @protected_blocks so per-page placeholders survive
|
|
46
|
+
# across the pre_render priority chain (50 → 15 → 10).
|
|
53
47
|
def protect_all_code_blocks(content)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
placeholder = "<!--PROTECTED_CODE_BLOCK_#{counter}-->"
|
|
58
|
-
@@protected_blocks[placeholder] = match
|
|
59
|
-
counter += 1
|
|
60
|
-
placeholder
|
|
61
|
-
end
|
|
48
|
+
protected_content, tokens = Markawesome::CodeBlockProtector.protect(content)
|
|
49
|
+
@protected_blocks.merge!(tokens)
|
|
50
|
+
protected_content
|
|
62
51
|
end
|
|
63
52
|
|
|
64
|
-
#
|
|
65
|
-
#
|
|
53
|
+
# Rewrite each protected fenced block to a Jekyll `{% highlight %}`
|
|
54
|
+
# tag, except for blocks without a language or with `plain` — those
|
|
55
|
+
# are restored verbatim. Called at priority 15, i.e. after
|
|
56
|
+
# Markawesome transformers but before restore.
|
|
66
57
|
def transform_code_blocks(content)
|
|
67
|
-
|
|
68
|
-
@@protected_blocks.transform_values! do |match|
|
|
58
|
+
@protected_blocks.transform_values! do |match|
|
|
69
59
|
if match =~ CODE_BLOCK_PATTERN
|
|
70
60
|
language = Regexp.last_match(1)
|
|
71
61
|
code_content = Regexp.last_match(2).strip
|
|
@@ -73,7 +63,7 @@ module Jekyll
|
|
|
73
63
|
if language && language.downcase != 'plain'
|
|
74
64
|
"{% highlight #{language} %}\n#{code_content}\n{% endhighlight %}"
|
|
75
65
|
else
|
|
76
|
-
match
|
|
66
|
+
match
|
|
77
67
|
end
|
|
78
68
|
else
|
|
79
69
|
match
|
|
@@ -82,12 +72,14 @@ module Jekyll
|
|
|
82
72
|
content
|
|
83
73
|
end
|
|
84
74
|
|
|
85
|
-
# Restore protected
|
|
75
|
+
# Restore protected code blocks using Markawesome::CodeBlockProtector,
|
|
76
|
+
# then clear the per-page token map so the next page starts fresh.
|
|
77
|
+
# CodeBlockProtector.protect always restarts its counter at 0, so
|
|
78
|
+
# clearing between pages prevents placeholder-id collisions.
|
|
86
79
|
def restore_protected_blocks(content)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
content
|
|
80
|
+
restored = Markawesome::CodeBlockProtector.restore(content, @protected_blocks)
|
|
81
|
+
@protected_blocks.clear
|
|
82
|
+
restored
|
|
91
83
|
end
|
|
92
84
|
|
|
93
85
|
def process(content)
|
|
@@ -95,15 +87,11 @@ module Jekyll
|
|
|
95
87
|
end
|
|
96
88
|
end
|
|
97
89
|
|
|
98
|
-
# Register hooks directly in the transformer module
|
|
99
|
-
# Wrapped in conditional to prevent errors when Jekyll::Hooks is not fully loaded
|
|
100
90
|
if defined?(Jekyll::Hooks)
|
|
101
|
-
# Clear protected blocks at start of build
|
|
102
91
|
Jekyll::Hooks.register :site, :pre_render do |_site|
|
|
103
92
|
CodeBlockTransformer.clear_protected_blocks
|
|
104
93
|
end
|
|
105
94
|
|
|
106
|
-
# STEP 1: Protect all code blocks BEFORE any transformations (highest priority)
|
|
107
95
|
Jekyll::Hooks.register :documents, :pre_render, priority: 50 do |document|
|
|
108
96
|
next unless document.relative_path =~ /.*\.md$/i
|
|
109
97
|
next unless CodeBlockTransformer.transform_documents_enabled?(document.site)
|
|
@@ -120,8 +108,6 @@ module Jekyll
|
|
|
120
108
|
page.content = CodeBlockTransformer.protect_all_code_blocks(page.content)
|
|
121
109
|
end
|
|
122
110
|
|
|
123
|
-
# STEP 2: Transform protected code blocks to Jekyll highlight syntax
|
|
124
|
-
# This happens AFTER WebAwesome transformers (priority 20) but BEFORE restoration
|
|
125
111
|
Jekyll::Hooks.register :documents, :pre_render, priority: 15 do |document|
|
|
126
112
|
next unless document.relative_path =~ /.*\.md$/i
|
|
127
113
|
next unless CodeBlockTransformer.transform_documents_enabled?(document.site)
|
|
@@ -138,7 +124,6 @@ module Jekyll
|
|
|
138
124
|
page.content = CodeBlockTransformer.transform_code_blocks(page.content)
|
|
139
125
|
end
|
|
140
126
|
|
|
141
|
-
# STEP 3: Restore protected blocks after transformation (lowest priority)
|
|
142
127
|
Jekyll::Hooks.register :documents, :pre_render, priority: 10 do |document|
|
|
143
128
|
next unless document.relative_path =~ /.*\.md$/i
|
|
144
129
|
next unless CodeBlockTransformer.transform_documents_enabled?(document.site)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-webawesome
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.16.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Janne Waren
|
|
@@ -35,14 +35,14 @@ dependencies:
|
|
|
35
35
|
requirements:
|
|
36
36
|
- - "~>"
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: '0.
|
|
38
|
+
version: '0.10'
|
|
39
39
|
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - "~>"
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '0.
|
|
45
|
+
version: '0.10'
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: bundler
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|