markawesome 0.6.0 → 0.7.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/README.md +40 -1
- data/lib/markawesome/transformers/icon_transformer.rb +41 -17
- data/lib/markawesome/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: bd4d3d594adb8f57319bfbb9b353d9e1557cf9949417a4da62bd2e8e5f736ed3
|
|
4
|
+
data.tar.gz: e1018086c23e3c38f24312fb5a16c5194260083253e17100c7d591a9c93de25f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f3934636dd055cd7e418b276a1eae04f06f4c5a7527213ea6e59cdfd907cd8e9db0874a71790255891a559b907360889202205b36c15d6fa6b2a8c9454ab9c73
|
|
7
|
+
data.tar.gz: 83627f19b8439b91f2e2ac241cab1061546b2d50b267aa1096c2a3b96b4ee7b561d3bb53628cbeed2f285a07205331653fd1b6200d746cc0c2362bcfa7333bef
|
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.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.7.0] - 2026-02-16
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **IconTransformer: Size support** — Append a size token to control icon font-size via inline style. Primary syntax uses `:` separator (`$$$settings:lg`), alternative syntax uses space (`:::wa-icon settings lg`). Available sizes: `xs` (0.75em), `sm` (0.875em), `lg` (1.25em), `xl` (1.5em), `2x` (2em), `3x` (3em), `4x` (4em)
|
|
12
|
+
- **IconTransformer: Custom SVG icons** — Use a file path starting with `/` or `./` to render `<wa-icon src="...">` instead of `<wa-icon name="...">`. Supports sizes too (`$$$/assets/icons/shoe.svg:2x`)
|
|
13
|
+
|
|
7
14
|
## [0.6.0] - 2026-02-14
|
|
8
15
|
|
|
9
16
|
### Changed
|
data/README.md
CHANGED
|
@@ -23,11 +23,50 @@ Used as the transformation engine for the [jekyll-webawesome](https://github.com
|
|
|
23
23
|
| **Copy Button** | `<<<` | `:::wa-copy-button` | `<wa-copy-button value="content">content</wa-copy-button>` |
|
|
24
24
|
| **Details** | `^^^appearance? icon-placement?` | `:::wa-details appearance? icon-placement?` | `<wa-details>content</wa-details>` |
|
|
25
25
|
| **Dialog** | `???params?` | `:::wa-dialog params?` | `<wa-dialog>` with trigger button and content |
|
|
26
|
-
| **Icon** | `$$$icon-name` | `:::wa-icon icon-name` | `<wa-icon name="icon-name"></wa-icon>` |
|
|
26
|
+
| **Icon** | `$$$icon-name` or `$$$icon-name:size` | `:::wa-icon icon-name [size]` | `<wa-icon name="icon-name"></wa-icon>` |
|
|
27
27
|
| **Image Dialog** | `` | — | Wraps images in clickable `<wa-dialog>` overlays |
|
|
28
28
|
| **Tab Group** | `++++++` | `:::wa-tabs` | `<wa-tab-group><wa-tab>content</wa-tab></wa-tab-group>` |
|
|
29
29
|
| **Tag** | `@@@brand` | `:::wa-tag brand` | `<wa-tag variant="brand">content</wa-tag>` |
|
|
30
30
|
|
|
31
|
+
## Icon
|
|
32
|
+
|
|
33
|
+
### Named icons
|
|
34
|
+
|
|
35
|
+
Use a Web Awesome icon name:
|
|
36
|
+
|
|
37
|
+
```markdown
|
|
38
|
+
Click $$$settings to configure.
|
|
39
|
+
A large $$$home:lg icon.
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Custom SVG icons
|
|
43
|
+
|
|
44
|
+
Point to a local SVG file by starting the path with `/` or `./`:
|
|
45
|
+
|
|
46
|
+
```markdown
|
|
47
|
+
$$$/assets/icons/shoe.svg
|
|
48
|
+
$$$/assets/icons/shoe.svg:2x
|
|
49
|
+
$$$./icons/logo.svg:xl
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This outputs `<wa-icon src="/assets/icons/shoe.svg"></wa-icon>` instead of using the `name` attribute.
|
|
53
|
+
|
|
54
|
+
### Sizes
|
|
55
|
+
|
|
56
|
+
Append a size token after `:` (primary syntax) or as a space-separated parameter (alternative syntax):
|
|
57
|
+
|
|
58
|
+
| Token | CSS `font-size` |
|
|
59
|
+
|-------|----------------|
|
|
60
|
+
| `xs` | 0.75em |
|
|
61
|
+
| `sm` | 0.875em |
|
|
62
|
+
| `lg` | 1.25em |
|
|
63
|
+
| `xl` | 1.5em |
|
|
64
|
+
| `2x` | 2em |
|
|
65
|
+
| `3x` | 3em |
|
|
66
|
+
| `4x` | 4em |
|
|
67
|
+
|
|
68
|
+
Without a size token, the icon inherits the surrounding font size.
|
|
69
|
+
|
|
31
70
|
## Layout Utilities
|
|
32
71
|
|
|
33
72
|
Layout utilities use `::::` (quadruple colon) syntax to wrap content in CSS layout containers. Inner content is not markdown-converted, so component `:::` syntax inside layouts works normally.
|
|
@@ -4,30 +4,46 @@ require_relative 'base_transformer'
|
|
|
4
4
|
|
|
5
5
|
module Markawesome
|
|
6
6
|
# Transforms icon syntax into wa-icon elements
|
|
7
|
-
# Primary syntax: $$$icon-name
|
|
8
|
-
#
|
|
7
|
+
# Primary syntax: $$$icon-name or $$$icon-name:size
|
|
8
|
+
# Custom SVG syntax: $$$/path/to/icon.svg or $$$/path/to/icon.svg:size
|
|
9
|
+
# Alternative syntax: :::wa-icon icon-name [size] or :::wa-icon /path/to/icon.svg [size]
|
|
9
10
|
#
|
|
10
11
|
# Examples:
|
|
11
12
|
# $$$settings -> <wa-icon name="settings"></wa-icon>
|
|
12
|
-
# $$$
|
|
13
|
-
#
|
|
13
|
+
# $$$settings:lg -> <wa-icon name="settings" style="font-size: 1.25em;"></wa-icon>
|
|
14
|
+
# $$$/assets/icons/shoe.svg -> <wa-icon src="/assets/icons/shoe.svg"></wa-icon>
|
|
15
|
+
# $$$/assets/icons/shoe.svg:2x -> <wa-icon src="/assets/icons/shoe.svg" style="font-size: 2em;"></wa-icon>
|
|
16
|
+
#
|
|
17
|
+
# Available sizes: xs (0.75em), sm (0.875em), lg (1.25em), xl (1.5em), 2x (2em), 3x (3em), 4x (4em)
|
|
14
18
|
class IconTransformer < BaseTransformer
|
|
19
|
+
SIZES = {
|
|
20
|
+
'xs' => '0.75em',
|
|
21
|
+
'sm' => '0.875em',
|
|
22
|
+
'lg' => '1.25em',
|
|
23
|
+
'xl' => '1.5em',
|
|
24
|
+
'2x' => '2em',
|
|
25
|
+
'3x' => '3em',
|
|
26
|
+
'4x' => '4em'
|
|
27
|
+
}.freeze
|
|
28
|
+
|
|
15
29
|
def self.transform(content)
|
|
16
30
|
# Protect code blocks first
|
|
17
31
|
protected_content, code_blocks = protect_code_blocks(content)
|
|
18
32
|
|
|
19
33
|
# Apply primary syntax transformation
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
build_icon_html(
|
|
34
|
+
# Supports named icons ($$$settings:lg) and custom SVG paths ($$$/path/to/icon.svg:2x)
|
|
35
|
+
result = protected_content.gsub(%r{\$\$\$(\.?/[a-zA-Z0-9\-_./]+|[a-zA-Z0-9\-_]+)(?::([a-zA-Z0-9]+))?(?![a-zA-Z0-9\-_]|\s+name\b)}) do
|
|
36
|
+
icon_ref = ::Regexp.last_match(1)
|
|
37
|
+
size = ::Regexp.last_match(2)
|
|
38
|
+
build_icon_html(icon_ref, size)
|
|
25
39
|
end
|
|
26
40
|
|
|
27
41
|
# Apply alternative syntax transformation
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
# Supports named icons and custom SVG paths with optional size
|
|
43
|
+
result = result.gsub(%r{:::wa-icon\s+(\.?/[a-zA-Z0-9\-_./]+|[a-zA-Z0-9\-_]+)(?:\s+([a-zA-Z0-9]+))?\s*\n:::}m) do
|
|
44
|
+
icon_ref = ::Regexp.last_match(1)
|
|
45
|
+
size = ::Regexp.last_match(2)
|
|
46
|
+
build_icon_html(icon_ref, size)
|
|
31
47
|
end
|
|
32
48
|
|
|
33
49
|
# Restore code blocks
|
|
@@ -37,12 +53,20 @@ module Markawesome
|
|
|
37
53
|
class << self
|
|
38
54
|
private
|
|
39
55
|
|
|
40
|
-
def build_icon_html(
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
def build_icon_html(icon_ref, size = nil)
|
|
57
|
+
clean_ref = icon_ref.strip
|
|
58
|
+
|
|
59
|
+
# Paths (starting with / or ./) use src attribute, otherwise use name
|
|
60
|
+
attr = if clean_ref.include?('/')
|
|
61
|
+
"src=\"#{clean_ref}\""
|
|
62
|
+
else
|
|
63
|
+
"name=\"#{clean_ref}\""
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Build style attribute for size
|
|
67
|
+
style = SIZES[size] ? " style=\"font-size: #{SIZES[size]};\"" : ''
|
|
43
68
|
|
|
44
|
-
#
|
|
45
|
-
"<wa-icon name=\"#{clean_name}\"></wa-icon>"
|
|
69
|
+
"<wa-icon #{attr}#{style}></wa-icon>"
|
|
46
70
|
end
|
|
47
71
|
|
|
48
72
|
def protect_code_blocks(content)
|
data/lib/markawesome/version.rb
CHANGED