jekyll-webawesome 0.1.0 → 0.2.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: 11da0d2da16359893d07591941d1dcca5184c7befcaa03c95adab45b4945e2c2
4
- data.tar.gz: e573335ac4e9caa1c46585593f1ab0718c58e58e03060dcb21a159a16324678a
3
+ metadata.gz: 6846bb6aa40dc02ccf27b7dc52b2d1c519450931c778319171a6f6ea1c3e80be
4
+ data.tar.gz: 74ff31a509f50c591f1a24e3d336d6f22ed6d2e941ce6843bd22fd1ccbd75a9f
5
5
  SHA512:
6
- metadata.gz: d90cc934527c25df1c8444cb1e193f383ae60f6a4a679c590cffa1fdf25606d10f728b5bd30ab41cb96c44d1053300d49c8fdb4943b5568ff47c20d2f23636eb
7
- data.tar.gz: 364c6eb910786df9e07ee90629c2a2af9fe8062d97e7837596f5ae320318eb2e65f25364c468995f79b70cbd65fd49a36628ee64aa009588349abd6ee0b39b9f
6
+ metadata.gz: 82adf1d1266bb4670410e0ac61cb3f245e83f18cf7a85477539f8ccd91e0ba31598aa5118a23bfd81e5008795c25378d842c2151753cabcf6a794bf8c318bed4
7
+ data.tar.gz: 3f0dfbb5db90f64b36e924e22b5ed0e979ee5faf180abda604bc29f28545653dcc1b60432bd9223a573ff11b12aba3624e260199be4e38db07b3643e4df0e18a
data/CHANGELOG.md CHANGED
@@ -6,12 +6,34 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.1] - 2025-09-23
10
+
11
+ - Fixed issues with icon transformation messing up code blocks and inline code
12
+
13
+ ## [0.2.0] - 2025-09-03
14
+
15
+ ### Added
16
+
17
+ - Configuration options to control transformation scope
18
+ - `transform_pages` - Enable/disable transformations for pages (default: true)
19
+ - `transform_documents` - Enable/disable transformations for documents/posts (default: true)
20
+ - Can be configured via `_config.yml` or programmatically
21
+ - Support for Comparison component (`|||` or `:::wa-comparison`)
22
+ - Optional position parameter to set initial slider position (`|||25` sets position to 25%)
23
+ - Requires exactly two images for before/after comparison
24
+
9
25
  ## [0.1.0] - 2025-08-09
10
26
 
11
27
  ### Added
12
28
 
13
29
  - Initial release of jekyll-webawesome gem
14
- - Support for callout components (:::info, :::success, :::warning, :::danger, :::neutral)
15
- - Support for details/summary components (^^^...>>>...^^^)
16
- - Support for tab group components (++++++...++++++)
30
+ - Support for Badge components (`!!!variant` or `:::wa-badge variant`)
31
+ - Support for Button components (`%%%variant` or `:::wa-button variant`)
32
+ - Support for Callout components (`:::info`, `:::success`, `:::warning`, `:::danger`, `:::neutral` or `:::wa-callout variant`)
33
+ - Support for Card components (`===` or `:::wa-card`)
34
+ - Support for Details/Summary components (`^^^...>>>...^^^` or `:::wa-details`)
35
+ - Support for Icon components (`$$$icon-name` or `:::wa-icon name`)
36
+ - Support for Tag components (`@@@variant` or `:::wa-tag variant`)
37
+ - Support for Tab Group components (`++++++...++++++` or `:::wa-tabs`)
17
38
  - Automatic Jekyll hooks integration
39
+ - Dual syntax support (primary shorthand and alternative explicit syntax) for all components
data/README.md CHANGED
@@ -16,6 +16,7 @@ This plugin focuses on the most commonly used Web Awesome components for Jekyll
16
16
  | **Button** | `%%%variant` | `:::wa-button variant` | `<wa-button variant="brand" href="url">text</wa-button>` or `<wa-button variant="brand">text</wa-button>` |
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
+ | **Comparison** | `\|\|\|` or `\|\|\|25` | `:::wa-comparison` or `:::wa-comparison 25` | `<wa-comparison>` with before/after slots |
19
20
  | **Details** | `^^^` | `:::wa-details` | `<wa-details><summary>summary</summary>content</wa-details>` |
20
21
  | **Tab Group** | `++++++` | `:::wa-tabs` | `<wa-tab-group><wa-tab>content</wa-tab></wa-tab-group>` |
21
22
  | **Tag** | `@@@brand` | `:::wa-tag brand` | `<wa-tag variant="brand">content</wa-tag>` |
@@ -27,7 +28,6 @@ These content-focused components will get dedicated syntax in future releases:
27
28
  | Component | Primary Syntax | Alternative syntax | HTML Output |
28
29
  |-----------|----------------------|-------------------|-------------|
29
30
  | **Copy Button** | `<<<` | `:::wa-copy-button` | `<wa-copy-button>content</wa-copy-button>` |
30
- | **Divider** | `\|\|\|` | `:::wa-divider` | `<wa-divider></wa-divider>` |
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>` |
@@ -62,6 +62,10 @@ And add configuration options as needed in `_config.yml`:
62
62
  webawesome:
63
63
  # Enable debug output to see which files are being processed
64
64
  debug: true
65
+
66
+ # Control which file types to transform (default: both true)
67
+ transform_pages: true # Transform pages (like index.md, about.md)
68
+ transform_documents: true # Transform documents (like blog posts in _posts)
65
69
  ```
66
70
 
67
71
  And then execute:
@@ -70,6 +74,20 @@ And then execute:
70
74
  bundle install
71
75
  ```
72
76
 
77
+ ### Programmatic Configuration
78
+
79
+ You can also configure the plugin programmatically in a `_plugins/` file or in your gem's initialization:
80
+
81
+ ```ruby
82
+ require 'jekyll-webawesome'
83
+
84
+ Jekyll::WebAwesome.configure do |config|
85
+ config.debug_mode = true
86
+ config.transform_pages = false # Don't transform pages
87
+ config.transform_documents = true # Only transform documents (posts)
88
+ end
89
+ ```
90
+
73
91
  ## Live Examples
74
92
 
75
93
  See the plugin in action with a complete Jekyll site showcasing all supported components:
@@ -112,7 +130,49 @@ This is a neutral callout.
112
130
  :::
113
131
  ```
114
132
 
115
- These transform into Web Awesome callout components with appropriate icons and styling.
133
+ These transform into Web Awesome callout components with appropriate icons and styling
134
+
135
+ ![Callout component example](readme_screenshots/callouts.png)
136
+
137
+ ### Comparison
138
+
139
+ Create before/after image comparisons using the `|||` syntax:
140
+
141
+ ```markdown
142
+ |||
143
+ ![Grayscale version](before.jpg)
144
+ ![Color version](after.jpg)
145
+ |||
146
+ ```
147
+
148
+ You can specify the initial position of the comparison slider (0-100):
149
+
150
+ ```markdown
151
+ |||25
152
+ ![Grayscale version](before.jpg)
153
+ ![Color version](after.jpg)
154
+ |||
155
+ ```
156
+
157
+ This transforms into a Web Awesome comparison component that lets users interactively compare two images:
158
+
159
+ ```html
160
+ <wa-comparison position="25">
161
+ <img slot="before" src="before.jpg" alt="Grayscale version" />
162
+ <img slot="after" src="after.jpg" alt="Color version" />
163
+ </wa-comparison>
164
+ ```
165
+
166
+ The comparison component requires exactly two images within the wrapper:
167
+
168
+ - The first image becomes the "before" slot
169
+ - The second image becomes the "after" slot
170
+ - Standard Markdown image syntax is preserved: `![alt text](image.url)`
171
+ - Optional position parameter (0-100) sets the initial slider position
172
+
173
+ > **Note**: If the comparison block doesn't contain exactly two images, it will be left unchanged rather than transformed.
174
+
175
+ ![Comparison component example](readme_screenshots/comparison.png)
116
176
 
117
177
  ### Cards
118
178
 
@@ -198,6 +258,8 @@ This card uses the accent appearance for emphasis.
198
258
  ===
199
259
  ```
200
260
 
261
+ ![Cards component example](readme_screenshots/cards.png)
262
+
201
263
  ### Tags
202
264
 
203
265
  Create tags using the `@@@` syntax:
@@ -228,17 +290,9 @@ Documentation
228
290
  @@@
229
291
  ```
230
292
 
231
- These transform into Web Awesome tag components with appropriate colors and styling. Tags support markdown formatting within the content:
293
+ These transform into Web Awesome tag components with appropriate colors and styling.
232
294
 
233
- ```markdown
234
- @@@brand
235
- **v3.0** Beta
236
- @@@
237
-
238
- @@@success
239
- [View Results](https://example.com)
240
- @@@
241
- ```
295
+ ![Tags component example](readme_screenshots/tags.png)
242
296
 
243
297
  ### Details/Summary (Collapsible Content)
244
298
 
@@ -282,7 +336,7 @@ Content goes here
282
336
 
283
337
  ### Tab Groups
284
338
 
285
- Create tabbed content using the `++++++` syntax:
339
+ Create tabbed content using the `++++++` syntax for tab groups and `+++` for tabs.
286
340
 
287
341
  ```markdown
288
342
  ++++++
@@ -300,6 +354,8 @@ Content for the third tab.
300
354
  ++++++
301
355
  ```
302
356
 
357
+ ![Tabs component example](readme_screenshots/tabs1.png)
358
+
303
359
  You can specify tab placement:
304
360
 
305
361
  ```markdown
@@ -322,6 +378,8 @@ More content
322
378
  ++++++
323
379
  ```
324
380
 
381
+ ![Tabs component example](readme_screenshots/tabs2.png)
382
+
325
383
  Supported placements: `top` (default), `bottom`, `start`, `end`.
326
384
 
327
385
  ## Component Reference
@@ -14,6 +14,30 @@ module Jekyll
14
14
  @@protected_blocks.clear
15
15
  end
16
16
 
17
+ # Check if pages transformation is enabled
18
+ def transform_pages_enabled?(site)
19
+ # Check plugin configuration first
20
+ return Jekyll::WebAwesome.configuration.transform_pages if Jekyll::WebAwesome.configuration
21
+
22
+ # Check site config
23
+ return site.config.dig('webawesome', 'transform_pages') if site.config.dig('webawesome', 'transform_pages') != nil
24
+
25
+ # Default to true
26
+ true
27
+ end
28
+
29
+ # Check if documents transformation is enabled
30
+ def transform_documents_enabled?(site)
31
+ # Check plugin configuration first
32
+ return Jekyll::WebAwesome.configuration.transform_documents if Jekyll::WebAwesome.configuration
33
+
34
+ # Check site config
35
+ return site.config.dig('webawesome', 'transform_documents') if site.config.dig('webawesome', 'transform_documents') != nil
36
+
37
+ # Default to true
38
+ true
39
+ end
40
+
17
41
  # Check if a code block contains WebAwesome syntax that should be preserved
18
42
  def contains_webawesome_syntax?(content)
19
43
  # Check for WebAwesome patterns
@@ -79,6 +103,7 @@ module Jekyll
79
103
 
80
104
  Jekyll::Hooks.register :documents, :pre_render, priority: 30 do |document|
81
105
  next unless document.relative_path =~ /.*\.md$/i
106
+ next unless CodeBlockTransformer.transform_documents_enabled?(document.site)
82
107
 
83
108
  puts "Jekyll::WebAwesome::CodeBlockTransformer processing document: #{document.relative_path}\n"
84
109
  document.content = CodeBlockTransformer.transform_code_blocks(document.content)
@@ -86,6 +111,7 @@ module Jekyll
86
111
 
87
112
  Jekyll::Hooks.register :pages, :pre_render, priority: 30 do |page|
88
113
  next unless page.relative_path =~ /.*\.md$/i
114
+ next unless CodeBlockTransformer.transform_pages_enabled?(page.site)
89
115
 
90
116
  puts "Jekyll::WebAwesome::CodeBlockTransformer processing page: #{page.relative_path}\n"
91
117
  page.content = CodeBlockTransformer.transform_code_blocks(page.content)
@@ -94,6 +120,7 @@ module Jekyll
94
120
  # Register hooks to restore protected blocks after WaElementTransformer
95
121
  Jekyll::Hooks.register :documents, :pre_render, priority: 10 do |document|
96
122
  next unless document.relative_path =~ /.*\.md$/i
123
+ next unless CodeBlockTransformer.transform_documents_enabled?(document.site)
97
124
 
98
125
  puts "Jekyll::WebAwesome::CodeBlockTransformer restoring code blocks in document: #{document.relative_path}\n"
99
126
  document.content = CodeBlockTransformer.restore_protected_blocks(document.content)
@@ -101,6 +128,7 @@ module Jekyll
101
128
 
102
129
  Jekyll::Hooks.register :pages, :pre_render, priority: 10 do |page|
103
130
  next unless page.relative_path =~ /.*\.md$/i
131
+ next unless CodeBlockTransformer.transform_pages_enabled?(page.site)
104
132
 
105
133
  puts "Jekyll::WebAwesome::CodeBlockTransformer restoring code blocks in page: #{page.relative_path}\n"
106
134
  page.content = CodeBlockTransformer.restore_protected_blocks(page.content)
@@ -16,6 +16,30 @@ module Jekyll
16
16
  false
17
17
  end
18
18
 
19
+ # Check if pages transformation is enabled
20
+ def self.transform_pages_enabled?(site)
21
+ # Check plugin configuration first
22
+ return Jekyll::WebAwesome.configuration.transform_pages if Jekyll::WebAwesome.configuration
23
+
24
+ # Check site config
25
+ return site.config.dig('webawesome', 'transform_pages') if site.config.dig('webawesome', 'transform_pages') != nil
26
+
27
+ # Default to true
28
+ true
29
+ end
30
+
31
+ # Check if documents transformation is enabled
32
+ def self.transform_documents_enabled?(site)
33
+ # Check plugin configuration first
34
+ return Jekyll::WebAwesome.configuration.transform_documents if Jekyll::WebAwesome.configuration
35
+
36
+ # Check site config
37
+ return site.config.dig('webawesome', 'transform_documents') if site.config.dig('webawesome', 'transform_documents') != nil
38
+
39
+ # Default to true
40
+ true
41
+ end
42
+
19
43
  # Check if a file is a markdown file
20
44
  def self.markdown_file?(filepath)
21
45
  filepath.to_s.match?(/\.md$/i)
@@ -24,6 +48,7 @@ module Jekyll
24
48
  # Register hooks for pre-render processing (before markdown conversion)
25
49
  Jekyll::Hooks.register :documents, :pre_render do |document|
26
50
  next unless markdown_file?(document.relative_path)
51
+ next unless transform_documents_enabled?(document.site)
27
52
 
28
53
  puts "Jekyll::WebAwesome Processing document (pre-render): #{document.relative_path}\n" if debug_enabled?(document.site)
29
54
  document.content = Transformer.process(document.content)
@@ -31,6 +56,7 @@ module Jekyll
31
56
 
32
57
  Jekyll::Hooks.register :pages, :pre_render do |page|
33
58
  next unless markdown_file?(page.relative_path)
59
+ next unless transform_pages_enabled?(page.site)
34
60
 
35
61
  puts "Jekyll::WebAwesome Processing page (pre-render): #{page.relative_path}\n" if debug_enabled?(page.site)
36
62
  page.content = Transformer.process(page.content)
@@ -13,6 +13,7 @@ module Jekyll
13
13
  content = ButtonTransformer.transform(content)
14
14
  content = CalloutTransformer.transform(content)
15
15
  content = CardTransformer.transform(content)
16
+ content = ComparisonTransformer.transform(content)
16
17
  content = DetailsTransformer.transform(content)
17
18
  content = IconTransformer.transform(content)
18
19
  content = TagTransformer.transform(content)
@@ -37,27 +37,27 @@ module Jekyll
37
37
  when 'info'
38
38
  {
39
39
  additional_params: ' variant="brand"',
40
- inner_prepend: '<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>'
40
+ inner_prepend: '<wa-icon slot="icon" name="circle-info" variant="solid"></wa-icon>'
41
41
  }
42
42
  when 'success'
43
43
  {
44
44
  additional_params: ' variant="success"',
45
- inner_prepend: '<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>'
45
+ inner_prepend: '<wa-icon slot="icon" name="circle-check" variant="solid"></wa-icon>'
46
46
  }
47
47
  when 'neutral'
48
48
  {
49
49
  additional_params: ' variant="neutral"',
50
- inner_prepend: '<wa-icon slot="icon" name="gear" variant="regular"></wa-icon>'
50
+ inner_prepend: '<wa-icon slot="icon" name="gear" variant="solid"></wa-icon>'
51
51
  }
52
52
  when 'warning'
53
53
  {
54
54
  additional_params: ' variant="warning"',
55
- inner_prepend: '<wa-icon slot="icon" name="triangle-exclamation" variant="regular"></wa-icon>'
55
+ inner_prepend: '<wa-icon slot="icon" name="triangle-exclamation" variant="solid"></wa-icon>'
56
56
  }
57
57
  when 'danger'
58
58
  {
59
59
  additional_params: ' variant="danger"',
60
- inner_prepend: '<wa-icon slot="icon" name="circle-exclamation" variant="regular"></wa-icon>'
60
+ inner_prepend: '<wa-icon slot="icon" name="circle-exclamation" variant="solid"></wa-icon>'
61
61
  }
62
62
  else
63
63
  {
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_transformer'
4
+
5
+ module Jekyll
6
+ module WebAwesome
7
+ # Transforms comparison syntax into wa-comparison elements
8
+ # Primary syntax: |||\n![before](before.jpg)\n![after](after.jpg)\n|||
9
+ # Primary syntax with position: |||50\n![before](before.jpg)\n![after](after.jpg)\n|||
10
+ # Alternative syntax: :::wa-comparison\n![before](before.jpg)\n![after](after.jpg)\n:::
11
+ # Alternative syntax with position: :::wa-comparison 50\n![before](before.jpg)\n![after](after.jpg)\n:::
12
+ # Expects exactly two image elements inside the wrapper
13
+ class ComparisonTransformer < BaseTransformer
14
+ def self.transform(content)
15
+ # Process primary syntax
16
+ content = content.gsub(/^\|\|\|(\d+)?\n(.*?)\n\|\|\|/m) do |match|
17
+ position = Regexp.last_match(1)
18
+ inner_content = Regexp.last_match(2).strip
19
+ images = extract_images(inner_content)
20
+
21
+ if images.length == 2
22
+ build_comparison_html(inner_content, position)
23
+ else
24
+ match # Return original match if not exactly 2 images
25
+ end
26
+ end
27
+
28
+ # Process alternative syntax
29
+ content.gsub(/^:::wa-comparison\s*(\d+)?\n(.*?)\n:::/m) do |match|
30
+ position = Regexp.last_match(1)
31
+ inner_content = Regexp.last_match(2).strip
32
+ images = extract_images(inner_content)
33
+
34
+ if images.length == 2
35
+ build_comparison_html(inner_content, position)
36
+ else
37
+ match # Return original match if not exactly 2 images
38
+ end
39
+ end
40
+ end
41
+
42
+ class << self
43
+ private
44
+
45
+ def build_comparison_html(content, position = nil)
46
+ images = extract_images(content)
47
+
48
+ before_image = build_image_html(images[0], 'before')
49
+ after_image = build_image_html(images[1], 'after')
50
+
51
+ position_attr = position ? " position=\"#{position}\"" : ''
52
+
53
+ "<wa-comparison#{position_attr}>#{before_image}#{after_image}</wa-comparison>"
54
+ end
55
+
56
+ def extract_images(content)
57
+ # Extract markdown image syntax: ![alt](url)
58
+ image_regex = /!\[([^\]]*)\]\(([^)]+)\)/
59
+ content.scan(image_regex)
60
+ end
61
+
62
+ def build_image_html(image_match, slot)
63
+ alt_text = image_match[0]
64
+ src = image_match[1]
65
+
66
+ # Escape HTML characters in alt text
67
+ escaped_alt = alt_text.gsub('&', '&amp;').gsub('"', '&quot;').gsub('<', '&lt;').gsub('>', '&gt;')
68
+
69
+ "<img slot=\"#{slot}\" src=\"#{src}\" alt=\"#{escaped_alt}\" />"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -52,7 +52,7 @@ module Jekyll
52
52
 
53
53
  # Protect fenced code blocks
54
54
  protected = content.gsub(/```.*?```/m) do |match|
55
- placeholder = "ICON_PROTECTED_CODE_BLOCK_#{counter}"
55
+ placeholder = "<!--ICON_PROTECTED_CODE_BLOCK_#{counter}-->"
56
56
  code_blocks[placeholder] = match
57
57
  counter += 1
58
58
  placeholder
@@ -60,7 +60,7 @@ module Jekyll
60
60
 
61
61
  # Protect inline code
62
62
  protected = protected.gsub(/`[^`]+`/) do |match|
63
- placeholder = "ICON_PROTECTED_INLINE_CODE_#{counter}"
63
+ placeholder = "<!--ICON_PROTECTED_INLINE_CODE_#{counter}-->"
64
64
  code_blocks[placeholder] = match
65
65
  counter += 1
66
66
  placeholder
@@ -8,6 +8,7 @@ require_relative 'transformers/badge_transformer'
8
8
  require_relative 'transformers/button_transformer'
9
9
  require_relative 'transformers/callout_transformer'
10
10
  require_relative 'transformers/card_transformer'
11
+ require_relative 'transformers/comparison_transformer'
11
12
  require_relative 'transformers/details_transformer'
12
13
  require_relative 'transformers/icon_transformer'
13
14
  require_relative 'transformers/tabs_transformer'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module WebAwesome
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
@@ -23,12 +23,14 @@ module Jekyll
23
23
 
24
24
  # Configuration class for future extensibility
25
25
  class Configuration
26
- attr_accessor :debug_mode, :callout_icons, :custom_components
26
+ attr_accessor :debug_mode, :callout_icons, :custom_components, :transform_pages, :transform_documents
27
27
 
28
28
  def initialize
29
29
  @debug_mode = false
30
30
  @callout_icons = default_callout_icons
31
31
  @custom_components = {}
32
+ @transform_pages = true
33
+ @transform_documents = true
32
34
  end
33
35
 
34
36
  private
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.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janne Waren
@@ -122,6 +122,7 @@ files:
122
122
  - lib/jekyll/webawesome/transformers/button_transformer.rb
123
123
  - lib/jekyll/webawesome/transformers/callout_transformer.rb
124
124
  - lib/jekyll/webawesome/transformers/card_transformer.rb
125
+ - lib/jekyll/webawesome/transformers/comparison_transformer.rb
125
126
  - lib/jekyll/webawesome/transformers/details_transformer.rb
126
127
  - lib/jekyll/webawesome/transformers/icon_transformer.rb
127
128
  - lib/jekyll/webawesome/transformers/tabs_transformer.rb