jekyll-webawesome 0.2.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6846bb6aa40dc02ccf27b7dc52b2d1c519450931c778319171a6f6ea1c3e80be
4
- data.tar.gz: 74ff31a509f50c591f1a24e3d336d6f22ed6d2e941ce6843bd22fd1ccbd75a9f
3
+ metadata.gz: 248a4b65617851cba2e7b5cc7b1a14f9424fa38649b0efbe7f5af4417b71df7f
4
+ data.tar.gz: 157cfaef53cc8d38d1b7d3d0ddd6fc2c383a9a2989da6f5be9a62e9dc9d19bd0
5
5
  SHA512:
6
- metadata.gz: 82adf1d1266bb4670410e0ac61cb3f245e83f18cf7a85477539f8ccd91e0ba31598aa5118a23bfd81e5008795c25378d842c2151753cabcf6a794bf8c318bed4
7
- data.tar.gz: 3f0dfbb5db90f64b36e924e22b5ed0e979ee5faf180abda604bc29f28545653dcc1b60432bd9223a573ff11b12aba3624e260199be4e38db07b3643e4df0e18a
6
+ metadata.gz: fb931b98a57633b9924bbaf3143f4b3cda7bab15e3778f1d698775c95e349a3802d6f1d9fa537ebe8424e3e4debbf9d0d411101e2fd9481bbd9aee7224e86bc9
7
+ data.tar.gz: b0d50534280129717c3fa47445a66cf44313995b31061728679ad3324c05e9927934686e1b9a9343f7037f62fde575581c25571ebe437c2f1ed70c90cd8ba803
data/CHANGELOG.md CHANGED
@@ -6,14 +6,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ - Placeholder
10
+
11
+ ## [0.4.0] - 2025-09-29
12
+
13
+ - Support for icon placement in wa-details component
14
+
15
+ ## [0.3.0] - 2025-09-29
16
+
17
+ - Support for wa-copy-button component (`<<<...<<<` or `:::wa-copy-button`)
18
+
9
19
  ## [0.2.1] - 2025-09-23
10
20
 
11
21
  - Fixed issues with icon transformation messing up code blocks and inline code
12
22
 
13
23
  ## [0.2.0] - 2025-09-03
14
24
 
15
- ### Added
16
-
17
25
  - Configuration options to control transformation scope
18
26
  - `transform_pages` - Enable/disable transformations for pages (default: true)
19
27
  - `transform_documents` - Enable/disable transformations for documents/posts (default: true)
@@ -24,8 +32,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
24
32
 
25
33
  ## [0.1.0] - 2025-08-09
26
34
 
27
- ### Added
28
-
29
35
  - Initial release of jekyll-webawesome gem
30
36
  - Support for Badge components (`!!!variant` or `:::wa-badge variant`)
31
37
  - Support for Button components (`%%%variant` or `:::wa-button variant`)
data/README.md CHANGED
@@ -17,7 +17,8 @@ This plugin focuses on the most commonly used Web Awesome components for Jekyll
17
17
  | **Callouts** | `:::info` | `:::wa-callout info` | `<wa-callout variant="brand"><wa-icon name="circle-info"></wa-icon>content</wa-callout>` |
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
- | **Details** | `^^^` | `:::wa-details` | `<wa-details><summary>summary</summary>content</wa-details>` |
20
+ | **Copy Button** | `<<<` | `:::wa-copy-button` | `<wa-copy-button value="content">content</wa-copy-button>` |
21
+ | **Details** | `^^^appearance? icon-placement?` | `:::wa-details appearance? icon-placement?` | `<wa-details appearance="..." icon-placement="...">content</wa-details>` |
21
22
  | **Tab Group** | `++++++` | `:::wa-tabs` | `<wa-tab-group><wa-tab>content</wa-tab></wa-tab-group>` |
22
23
  | **Tag** | `@@@brand` | `:::wa-tag brand` | `<wa-tag variant="brand">content</wa-tag>` |
23
24
 
@@ -27,7 +28,6 @@ These content-focused components will get dedicated syntax in future releases:
27
28
 
28
29
  | Component | Primary Syntax | Alternative syntax | HTML Output |
29
30
  |-----------|----------------------|-------------------|-------------|
30
- | **Copy Button** | `<<<` | `:::wa-copy-button` | `<wa-copy-button>content</wa-copy-button>` |
31
31
  | **Icon** | `$$$icon-name` | `:::wa-icon name` | `<wa-icon name="icon-name"></wa-icon>` |
32
32
  | **Progress Bar** | `&&&value` | `:::wa-progress-bar value` | `<wa-progress-bar value="50"></wa-progress-bar>` |
33
33
  | **Rating** | `???value` | `:::wa-rating value` | `<wa-rating value="4"></wa-rating>` |
@@ -294,6 +294,44 @@ These transform into Web Awesome tag components with appropriate colors and styl
294
294
 
295
295
  ![Tags component example](readme_screenshots/tags.png)
296
296
 
297
+ ### Copy Buttons
298
+
299
+ Create copy-to-clipboard buttons using the `<<<` syntax:
300
+
301
+ ```markdown
302
+ <<<
303
+ Copy this simple text
304
+ <<<
305
+
306
+ <<<
307
+ npm install jekyll-webawesome
308
+ <<<
309
+ ```
310
+
311
+ Copy buttons support **markdown formatting** in the display text while preserving the original markdown in the clipboard value:
312
+
313
+ ```markdown
314
+ <<<
315
+ **Copy** this text with *markdown* formatting and `code`
316
+ <<<
317
+ ```
318
+
319
+ This transforms into a Web Awesome copy button component:
320
+
321
+ ```html
322
+ <wa-copy-button value="**Copy** this text with *markdown* formatting and `code`"></wa-copy-button>
323
+ ```
324
+
325
+ Copy buttons work well for:
326
+
327
+ - Code snippets and commands
328
+ - URLs and configuration values
329
+ - Installation instructions
330
+ - API keys or tokens
331
+ - Any text users might want to copy
332
+
333
+ > **Note**: The `value` attribute contains the raw text (including any markdown) that gets copied to the clipboard. The copy button displays the standard Web Awesome copy icon and handles the clipboard operation automatically.
334
+
297
335
  ### Details/Summary (Collapsible Content)
298
336
 
299
337
  Create collapsible content using the `^^^` syntax:
@@ -334,6 +372,38 @@ Content goes here
334
372
  ^^^
335
373
  ```
336
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
+
337
407
  ### Tab Groups
338
408
 
339
409
  Create tabbed content using the `++++++` syntax for tab groups and `+++` for tabs.
@@ -433,6 +503,13 @@ Cards automatically parse content into these slots:
433
503
  | `plain` | plain |
434
504
  | `filled-outlined` | filled outlined |
435
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
+
436
513
  ### Tab Placements
437
514
 
438
515
  - `top` (default)
@@ -14,6 +14,7 @@ module Jekyll
14
14
  content = CalloutTransformer.transform(content)
15
15
  content = CardTransformer.transform(content)
16
16
  content = ComparisonTransformer.transform(content)
17
+ content = CopyButtonTransformer.transform(content)
17
18
  content = DetailsTransformer.transform(content)
18
19
  content = IconTransformer.transform(content)
19
20
  content = TagTransformer.transform(content)
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_transformer'
4
+
5
+ module Jekyll
6
+ module WebAwesome
7
+ # Transforms copy button syntax into wa-copy-button elements
8
+ # Primary syntax: <<<\ncontent\n<<<
9
+ # Alternative syntax: :::wa-copy-button\ncontent\n:::
10
+ #
11
+ # Usage:
12
+ # <<<
13
+ # This text will be copied to clipboard
14
+ # <<<
15
+ #
16
+ # :::wa-copy-button
17
+ # Copy this text
18
+ # :::
19
+ class CopyButtonTransformer < BaseTransformer
20
+ def self.transform(content)
21
+ # Define both regex patterns
22
+ primary_regex = /^<<<\n(.*?)\n<<</m
23
+ alternative_regex = /^:::wa-copy-button\n(.*?)\n:::/m
24
+
25
+ # Define shared transformation logic
26
+ transform_proc = proc do |copy_content|
27
+ copy_content = copy_content.strip
28
+
29
+ build_copy_button_html(copy_content)
30
+ end
31
+
32
+ # Apply both patterns
33
+ patterns = dual_syntax_patterns(primary_regex, alternative_regex, transform_proc)
34
+ apply_multiple_patterns(content, patterns)
35
+ end
36
+
37
+ class << self
38
+ private
39
+
40
+ def build_copy_button_html(content)
41
+ # Escape the content for the value attribute
42
+ escaped_content = content.gsub('"', '&quot;').gsub("'", '&#39;')
43
+
44
+ "<wa-copy-button value=\"#{escaped_content}\"></wa-copy-button>"
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -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
@@ -9,6 +9,7 @@ require_relative 'transformers/button_transformer'
9
9
  require_relative 'transformers/callout_transformer'
10
10
  require_relative 'transformers/card_transformer'
11
11
  require_relative 'transformers/comparison_transformer'
12
+ require_relative 'transformers/copy_button_transformer'
12
13
  require_relative 'transformers/details_transformer'
13
14
  require_relative 'transformers/icon_transformer'
14
15
  require_relative 'transformers/tabs_transformer'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module WebAwesome
5
- VERSION = '0.2.1'
5
+ VERSION = '0.4.0'
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.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janne Waren
@@ -123,6 +123,7 @@ files:
123
123
  - lib/jekyll/webawesome/transformers/callout_transformer.rb
124
124
  - lib/jekyll/webawesome/transformers/card_transformer.rb
125
125
  - lib/jekyll/webawesome/transformers/comparison_transformer.rb
126
+ - lib/jekyll/webawesome/transformers/copy_button_transformer.rb
126
127
  - lib/jekyll/webawesome/transformers/details_transformer.rb
127
128
  - lib/jekyll/webawesome/transformers/icon_transformer.rb
128
129
  - lib/jekyll/webawesome/transformers/tabs_transformer.rb