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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f09b4ba8c46c0b7691411998aea6960e82dbe53654c95c777361b53876ecc19c
4
- data.tar.gz: 125a368ad99787b0dbec1901781bd1c7fa2fcfdc0c1b14fe2440f8cfe9ad119a
3
+ metadata.gz: b925e93ad2a43e360c982ac4fbc9c25ee0a0c4573039ecf2c182fa566377d60b
4
+ data.tar.gz: 32e0685f36e0c5a3532900ffb964aa15809ba2fb5fbc9d71240dba39d5612427
5
5
  SHA512:
6
- metadata.gz: bc8e69fcd0869698e5b9e8ce3225ab219be8b50eb781beab64a4b7ad0571d4e2580189a4607b6254f52ed7e1fa1cb776b44c7c7443f9e50785cd45fe7d75c83a
7
- data.tar.gz: a27a198436f697ff26959c06b73eba4f52e72164f400251517487f0242a3c959f126a15088f3c91b86ae3c6e3dcb6645c9fcaaf12f6ac1bfb5a084170b540a9d
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
- - Placeholder
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** | `^^^` | `:::wa-details` | `<wa-details><summary>summary</summary>content</wa-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
- # Transform code blocks from markdown syntax to Jekyll highlight tags
52
- def transform_code_blocks(content)
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
- language = Regexp.last_match(1)
74
- code_content = Regexp.last_match(2).strip
57
+ placeholder = "<!--PROTECTED_CODE_BLOCK_#{counter}-->"
58
+ @@protected_blocks[placeholder] = match
59
+ counter += 1
60
+ placeholder
61
+ end
62
+ end
75
63
 
76
- if language && language.downcase != 'plain'
77
- transformed = "{% highlight #{language} %}\n#{code_content}\n{% endhighlight %}"
78
- transformed
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 # Return original block if no language or 'plain'
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
- Jekyll::Hooks.register :documents, :pre_render, priority: 30 do |document|
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 processing document: #{document.relative_path}\n"
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: 30 do |page|
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 processing page: #{page.relative_path}\n"
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
- # Register hooks to restore protected blocks after WaElementTransformer
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 = /^\^\^\^?(outlined|filled|filled-outlined|plain)?\n(.*?)\n^>>>\n(.*?)\n^\^\^\^?/m
15
- alternative_regex = /^:::wa-details\s*(outlined|filled|filled-outlined|plain)?\n(.*?)\n^>>>\n(.*?)\n:::/m
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 |appearance_param, summary_content, details_content|
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module WebAwesome
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.1'
6
6
  end
7
7
  end
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.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janne Waren