jekyll-webawesome 0.3.0 → 0.4.1
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 +8 -5
- data/README.md +40 -1
- data/lib/jekyll/webawesome/code_block_transformer.rb +49 -30
- data/lib/jekyll/webawesome/transformers/details_transformer.rb +38 -7
- data/lib/jekyll/webawesome/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b925e93ad2a43e360c982ac4fbc9c25ee0a0c4573039ecf2c182fa566377d60b
|
4
|
+
data.tar.gz: 32e0685f36e0c5a3532900ffb964aa15809ba2fb5fbc9d71240dba39d5612427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53d88906164176d32ad025c073d410c8d585f782643e0e3372ae5da51daf1fd5c65519dc77a9dd952aff2870c2c3a6453d454cd858cacefa4f0b19b993466258
|
7
|
+
data.tar.gz: 9cc2f919be3f5513ca7269f5d9f9c722ab9cd386a78be5f9e1dd968ffd699e7edab43546c4b099d9ebb8fa55f41e5dfa79b30bc39fa9b446f8d0c00806fb18c2
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
-
-
|
9
|
+
## [0.4.1] - 2025-10-02
|
10
|
+
|
11
|
+
- Code blocks inside custom elements (wa-details, wa-callout, etc.) are now properly protected from markdown processing
|
12
|
+
- Previously, code blocks would be corrupted with HTML entities and extra `<p>` tags when nested inside custom elements
|
13
|
+
|
14
|
+
## [0.4.0] - 2025-09-29
|
15
|
+
|
16
|
+
- Support for icon placement in wa-details component
|
10
17
|
|
11
18
|
## [0.3.0] - 2025-09-29
|
12
19
|
|
@@ -18,8 +25,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
18
25
|
|
19
26
|
## [0.2.0] - 2025-09-03
|
20
27
|
|
21
|
-
### Added
|
22
|
-
|
23
28
|
- Configuration options to control transformation scope
|
24
29
|
- `transform_pages` - Enable/disable transformations for pages (default: true)
|
25
30
|
- `transform_documents` - Enable/disable transformations for documents/posts (default: true)
|
@@ -30,8 +35,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
30
35
|
|
31
36
|
## [0.1.0] - 2025-08-09
|
32
37
|
|
33
|
-
### Added
|
34
|
-
|
35
38
|
- Initial release of jekyll-webawesome gem
|
36
39
|
- Support for Badge components (`!!!variant` or `:::wa-badge variant`)
|
37
40
|
- Support for Button components (`%%%variant` or `:::wa-button variant`)
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ This plugin focuses on the most commonly used Web Awesome components for Jekyll
|
|
18
18
|
| **Card** | `===` | `:::wa-card` | `<wa-card>content</wa-card>` |
|
19
19
|
| **Comparison** | `\|\|\|` or `\|\|\|25` | `:::wa-comparison` or `:::wa-comparison 25` | `<wa-comparison>` with before/after slots |
|
20
20
|
| **Copy Button** | `<<<` | `:::wa-copy-button` | `<wa-copy-button value="content">content</wa-copy-button>` |
|
21
|
-
| **Details** |
|
21
|
+
| **Details** | `^^^appearance? icon-placement?` | `:::wa-details appearance? icon-placement?` | `<wa-details appearance="..." icon-placement="...">content</wa-details>` |
|
22
22
|
| **Tab Group** | `++++++` | `:::wa-tabs` | `<wa-tab-group><wa-tab>content</wa-tab></wa-tab-group>` |
|
23
23
|
| **Tag** | `@@@brand` | `:::wa-tag brand` | `<wa-tag variant="brand">content</wa-tag>` |
|
24
24
|
|
@@ -372,6 +372,38 @@ Content goes here
|
|
372
372
|
^^^
|
373
373
|
```
|
374
374
|
|
375
|
+
You can also control icon placement (expand/collapse icon location):
|
376
|
+
|
377
|
+
```markdown
|
378
|
+
^^^start
|
379
|
+
Summary with icon on the start (left)
|
380
|
+
>>>
|
381
|
+
The expand/collapse icon appears on the left side
|
382
|
+
^^^
|
383
|
+
|
384
|
+
^^^end
|
385
|
+
Summary with icon on the end (right)
|
386
|
+
>>>
|
387
|
+
The expand/collapse icon appears on the right side (default)
|
388
|
+
^^^
|
389
|
+
```
|
390
|
+
|
391
|
+
You can combine appearance and icon placement:
|
392
|
+
|
393
|
+
```markdown
|
394
|
+
^^^filled start
|
395
|
+
Filled appearance with icon on the start
|
396
|
+
>>>
|
397
|
+
Content with both styling and icon positioning
|
398
|
+
^^^
|
399
|
+
|
400
|
+
^^^plain end
|
401
|
+
Plain appearance with icon on the end
|
402
|
+
>>>
|
403
|
+
Parameters can be in any order: start filled, filled start, etc.
|
404
|
+
^^^
|
405
|
+
```
|
406
|
+
|
375
407
|
### Tab Groups
|
376
408
|
|
377
409
|
Create tabbed content using the `++++++` syntax for tab groups and `+++` for tabs.
|
@@ -471,6 +503,13 @@ Cards automatically parse content into these slots:
|
|
471
503
|
| `plain` | plain |
|
472
504
|
| `filled-outlined` | filled outlined |
|
473
505
|
|
506
|
+
### Details Icon Placement
|
507
|
+
|
508
|
+
| Position | Description |
|
509
|
+
|----------|-------------|
|
510
|
+
| `end` (default) | Icon appears on the right side |
|
511
|
+
| `start` | Icon appears on the left side |
|
512
|
+
|
474
513
|
### Tab Placements
|
475
514
|
|
476
515
|
- `top` (default)
|
@@ -48,38 +48,38 @@ module Jekyll
|
|
48
48
|
content.match?(callout_pattern) || content.match?(details_pattern) || content.match?(tabs_pattern)
|
49
49
|
end
|
50
50
|
|
51
|
-
#
|
52
|
-
|
51
|
+
# Protect all code blocks by converting them to placeholders
|
52
|
+
# This prevents markdown processing from corrupting code blocks inside custom elements
|
53
|
+
def protect_all_code_blocks(content)
|
53
54
|
counter = @@protected_blocks.size
|
54
55
|
|
55
|
-
# First pass: protect markdown code blocks that contain WebAwesome syntax
|
56
|
-
content = content.gsub(CODE_BLOCK_PATTERN) do |match|
|
57
|
-
language = Regexp.last_match(1)
|
58
|
-
code_content = Regexp.last_match(2).strip
|
59
|
-
|
60
|
-
# If this is a markdown code block containing WebAwesome syntax, protect it
|
61
|
-
if language && language.downcase == 'markdown' && contains_webawesome_syntax?(code_content)
|
62
|
-
placeholder = "<!--PROTECTED_WEBAWESOME_EXAMPLE_#{counter}-->"
|
63
|
-
@@protected_blocks[placeholder] = match
|
64
|
-
counter += 1
|
65
|
-
placeholder
|
66
|
-
else
|
67
|
-
match # Leave other code blocks for normal processing
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# Second pass: transform remaining code blocks normally
|
72
56
|
content.gsub(CODE_BLOCK_PATTERN) do |match|
|
73
|
-
|
74
|
-
|
57
|
+
placeholder = "<!--PROTECTED_CODE_BLOCK_#{counter}-->"
|
58
|
+
@@protected_blocks[placeholder] = match
|
59
|
+
counter += 1
|
60
|
+
placeholder
|
61
|
+
end
|
62
|
+
end
|
75
63
|
|
76
|
-
|
77
|
-
|
78
|
-
|
64
|
+
# Transform code blocks from markdown syntax to Jekyll highlight tags
|
65
|
+
# This should be called AFTER WebAwesome transformers have processed the content
|
66
|
+
def transform_code_blocks(content)
|
67
|
+
# Transform code blocks that were previously protected
|
68
|
+
@@protected_blocks.transform_values! do |match|
|
69
|
+
if match =~ CODE_BLOCK_PATTERN
|
70
|
+
language = Regexp.last_match(1)
|
71
|
+
code_content = Regexp.last_match(2).strip
|
72
|
+
|
73
|
+
if language && language.downcase != 'plain'
|
74
|
+
"{% highlight #{language} %}\n#{code_content}\n{% endhighlight %}"
|
75
|
+
else
|
76
|
+
match # Return original block if no language or 'plain'
|
77
|
+
end
|
79
78
|
else
|
80
|
-
match
|
79
|
+
match
|
81
80
|
end
|
82
81
|
end
|
82
|
+
content
|
83
83
|
end
|
84
84
|
|
85
85
|
# Restore protected WebAwesome example blocks after WaElementTransformer processing
|
@@ -101,23 +101,42 @@ module Jekyll
|
|
101
101
|
CodeBlockTransformer.clear_protected_blocks
|
102
102
|
end
|
103
103
|
|
104
|
-
|
104
|
+
# STEP 1: Protect all code blocks BEFORE any transformations (highest priority)
|
105
|
+
Jekyll::Hooks.register :documents, :pre_render, priority: 50 do |document|
|
106
|
+
next unless document.relative_path =~ /.*\.md$/i
|
107
|
+
next unless CodeBlockTransformer.transform_documents_enabled?(document.site)
|
108
|
+
|
109
|
+
puts "Jekyll::WebAwesome::CodeBlockTransformer protecting code blocks in document: #{document.relative_path}\n"
|
110
|
+
document.content = CodeBlockTransformer.protect_all_code_blocks(document.content)
|
111
|
+
end
|
112
|
+
|
113
|
+
Jekyll::Hooks.register :pages, :pre_render, priority: 50 do |page|
|
114
|
+
next unless page.relative_path =~ /.*\.md$/i
|
115
|
+
next unless CodeBlockTransformer.transform_pages_enabled?(page.site)
|
116
|
+
|
117
|
+
puts "Jekyll::WebAwesome::CodeBlockTransformer protecting code blocks in page: #{page.relative_path}\n"
|
118
|
+
page.content = CodeBlockTransformer.protect_all_code_blocks(page.content)
|
119
|
+
end
|
120
|
+
|
121
|
+
# STEP 2: Transform protected code blocks to Jekyll highlight syntax
|
122
|
+
# This happens AFTER WebAwesome transformers (priority 20) but BEFORE restoration
|
123
|
+
Jekyll::Hooks.register :documents, :pre_render, priority: 15 do |document|
|
105
124
|
next unless document.relative_path =~ /.*\.md$/i
|
106
125
|
next unless CodeBlockTransformer.transform_documents_enabled?(document.site)
|
107
126
|
|
108
|
-
puts "Jekyll::WebAwesome::CodeBlockTransformer
|
127
|
+
puts "Jekyll::WebAwesome::CodeBlockTransformer transforming code blocks in document: #{document.relative_path}\n"
|
109
128
|
document.content = CodeBlockTransformer.transform_code_blocks(document.content)
|
110
129
|
end
|
111
130
|
|
112
|
-
Jekyll::Hooks.register :pages, :pre_render, priority:
|
131
|
+
Jekyll::Hooks.register :pages, :pre_render, priority: 15 do |page|
|
113
132
|
next unless page.relative_path =~ /.*\.md$/i
|
114
133
|
next unless CodeBlockTransformer.transform_pages_enabled?(page.site)
|
115
134
|
|
116
|
-
puts "Jekyll::WebAwesome::CodeBlockTransformer
|
135
|
+
puts "Jekyll::WebAwesome::CodeBlockTransformer transforming code blocks in page: #{page.relative_path}\n"
|
117
136
|
page.content = CodeBlockTransformer.transform_code_blocks(page.content)
|
118
137
|
end
|
119
138
|
|
120
|
-
#
|
139
|
+
# STEP 3: Restore protected blocks after transformation (lowest priority)
|
121
140
|
Jekyll::Hooks.register :documents, :pre_render, priority: 10 do |document|
|
122
141
|
next unless document.relative_path =~ /.*\.md$/i
|
123
142
|
next unless CodeBlockTransformer.transform_documents_enabled?(document.site)
|
@@ -5,25 +5,30 @@ require_relative 'base_transformer'
|
|
5
5
|
module Jekyll
|
6
6
|
module WebAwesome
|
7
7
|
# Transforms summary/details syntax into wa-details elements
|
8
|
-
# Primary syntax: ^^^appearance?\nsummary\n>>>\ndetails\n^^^
|
9
|
-
# Alternative syntax: :::wa-details appearance?\nsummary\n>>>\ndetails\n:::
|
8
|
+
# Primary syntax: ^^^appearance? icon-placement?\nsummary\n>>>\ndetails\n^^^
|
9
|
+
# Alternative syntax: :::wa-details appearance? icon-placement?\nsummary\n>>>\ndetails\n:::
|
10
10
|
# Appearances: outlined (default), filled, filled-outlined, plain
|
11
|
+
# Icon placement: start, end (default)
|
11
12
|
class DetailsTransformer < BaseTransformer
|
12
13
|
def self.transform(content)
|
13
|
-
# Define both regex patterns
|
14
|
-
primary_regex = /^\^\^\^?(
|
15
|
-
alternative_regex = /^:::wa-details\s*(
|
14
|
+
# Define both regex patterns - capture parameter string
|
15
|
+
primary_regex = /^\^\^\^?(.*?)\n(.*?)\n^>>>\n(.*?)\n^\^\^\^?/m
|
16
|
+
alternative_regex = /^:::wa-details\s*(.*?)\n(.*?)\n^>>>\n(.*?)\n:::/m
|
16
17
|
|
17
18
|
# Define shared transformation logic
|
18
|
-
transform_proc = proc do |
|
19
|
+
transform_proc = proc do |params_string, summary_content, details_content|
|
19
20
|
summary_content = summary_content.strip
|
20
21
|
details_content = details_content.strip
|
21
22
|
|
23
|
+
# Parse parameters from the params string
|
24
|
+
appearance_param, icon_placement_param = parse_parameters(params_string)
|
25
|
+
|
22
26
|
appearance_class = normalize_appearance(appearance_param)
|
27
|
+
icon_placement = normalize_icon_placement(icon_placement_param)
|
23
28
|
summary_html = markdown_to_html(summary_content)
|
24
29
|
details_html = markdown_to_html(details_content)
|
25
30
|
|
26
|
-
"<wa-details appearance='#{appearance_class}'>" \
|
31
|
+
"<wa-details appearance='#{appearance_class}' icon-placement='#{icon_placement}'>" \
|
27
32
|
"<span slot='summary'>#{summary_html}</span>" \
|
28
33
|
"#{details_html}</wa-details>"
|
29
34
|
end
|
@@ -36,6 +41,21 @@ module Jekyll
|
|
36
41
|
class << self
|
37
42
|
private
|
38
43
|
|
44
|
+
def parse_parameters(params_string)
|
45
|
+
return [nil, nil] if params_string.nil? || params_string.strip.empty?
|
46
|
+
|
47
|
+
# Split by whitespace and extract known parameters
|
48
|
+
tokens = params_string.strip.split(/\s+/)
|
49
|
+
|
50
|
+
appearance_options = %w[outlined filled filled-outlined plain]
|
51
|
+
placement_options = %w[start end]
|
52
|
+
|
53
|
+
appearance_param = tokens.find { |token| appearance_options.include?(token) }
|
54
|
+
icon_placement_param = tokens.find { |token| placement_options.include?(token) }
|
55
|
+
|
56
|
+
[appearance_param, icon_placement_param]
|
57
|
+
end
|
58
|
+
|
39
59
|
def normalize_appearance(appearance_param)
|
40
60
|
case appearance_param
|
41
61
|
when 'filled'
|
@@ -48,6 +68,17 @@ module Jekyll
|
|
48
68
|
'outlined'
|
49
69
|
end
|
50
70
|
end
|
71
|
+
|
72
|
+
def normalize_icon_placement(icon_placement_param)
|
73
|
+
case icon_placement_param
|
74
|
+
when 'start'
|
75
|
+
'start'
|
76
|
+
when 'end'
|
77
|
+
'end'
|
78
|
+
else
|
79
|
+
'end'
|
80
|
+
end
|
81
|
+
end
|
51
82
|
end
|
52
83
|
end
|
53
84
|
end
|