markawesome 0.8.0 → 0.9.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: 0ed0214570dcd6897e7433e6a2891a5f1d7fdc69650a7c0d11a0265924c5376b
4
- data.tar.gz: c44001d3a303f7c59eb0d29f8335a08ad52e82f6b1bdc613a2977a65b6279247
3
+ metadata.gz: f905b53dab8aa3e46a07e23a535027fdc95f290fa195ed7bc7e3700cb5b28434
4
+ data.tar.gz: 858f36fb5b797fddb06d9ce73b586a67088b9c41d48f58dd3e5755c537e7f6dc
5
5
  SHA512:
6
- metadata.gz: c374b8048b195255d1779d09efbd3de1a4e5fbbd0264b72940e75b73f9fd2a3517e0710a2414c4f0f411028064ea3f3b17066285a1c17d6558e57e533a9e1a85
7
- data.tar.gz: f362ad4bdcde37cf129dd5f9a83ef006d8eb11dd6f06a1bd2a6b410e22ee83b32c518909a0e3b083b8cded3c7b56d4b7f37e85cdb448f30517f68824d628eeae
6
+ metadata.gz: 33be24fab1f053e5c26f854d748c59b324b9c02e08a61622d89cd57674551865de9497cc67e8ecb736c04f999cb1ae6cde3924ff0a2f14e265565d2fe5e5cb46
7
+ data.tar.gz: fff7882f369664e224277d97599311e19c17c3308eb02dff69ade5b945b01cf5bca0d4ab1f0ccffe389ca939c8efc8e9595632121bf3efcaecfd8b80cbe4f5fa
data/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ 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.9.1] - 2026-03-12
8
+
9
+ ### Changed
10
+
11
+ - Link-style popover triggers now use dotted underline (`text-decoration-style: dotted`) to visually distinguish them from navigation links
12
+
13
+ ## [0.9.0] - 2026-03-12
14
+
15
+ ### Added
16
+
17
+ - **PopoverTransformer**: Inline syntax `&&&trigger text >>> popover content&&&` for use within sentences
18
+ - Always renders as link-styled trigger (underlined text button)
19
+ - Supports all parameters: placement, `without-arrow`, `distance:N`
20
+ - Parameters placed before trigger text, separated by spaces
21
+ - Plain text content (HTML-escaped, no markdown processing)
22
+ - Multiple inline popovers supported on the same line
23
+
7
24
  ## [0.8.0] - 2026-03-12
8
25
 
9
26
  ### Added
data/README.md CHANGED
@@ -25,7 +25,7 @@ Used as the transformation engine for the [jekyll-webawesome](https://github.com
25
25
  | **Dialog** | `???params?` | `:::wa-dialog params?` | `<wa-dialog>` with trigger button and content |
26
26
  | **Icon** | `$$$icon-name` | `:::wa-icon icon-name` | `<wa-icon name="icon-name"></wa-icon>` |
27
27
  | **Image Dialog** | `![alt](url)` | — | Wraps images in clickable `<wa-dialog>` overlays |
28
- | **Popover** | `&&&params?` | `:::wa-popover params?` | `<wa-popover>` with trigger button and content |
28
+ | **Popover** | `&&&params?` or inline `&&&trigger >>> content&&&` | `:::wa-popover params?` | `<wa-popover>` with trigger button and content |
29
29
  | **Tab Group** | `++++++` | `:::wa-tabs` | `<wa-tab-group><wa-tab>content</wa-tab></wa-tab-group>` |
30
30
  | **Tag** | `@@@brand` | `:::wa-tag brand` | `<wa-tag variant="brand">content</wa-tag>` |
31
31
 
@@ -8,6 +8,7 @@ module Markawesome
8
8
  # Transforms popover syntax into wa-popover elements with trigger buttons
9
9
  # Primary syntax: &&&params\ntrigger text\n>>>\ncontent\n&&&
10
10
  # Alternative syntax: :::wa-popover params\ntrigger text\n>>>\ncontent\n:::
11
+ # Inline syntax: &&&params? trigger text >>> popover content&&&
11
12
  #
12
13
  # Params: space-separated tokens (order doesn't matter)
13
14
  # Placement: top (default), bottom, left, right
@@ -21,9 +22,32 @@ module Markawesome
21
22
  }.freeze
22
23
 
23
24
  def self.transform(content)
25
+ # Inline regex (single-line, no newlines allowed)
26
+ inline_regex = /&&&[ \t]*([^\r\n]*?)[ \t]*>>>[ \t]*([^\r\n]+?)[ \t]*&&&/
27
+
28
+ # Block regexes (multiline)
24
29
  primary_regex = /^&&&([^\n]*)$\n(.*?)\n^>>>$\n(.*?)\n^&&&$/m
25
30
  alternative_regex = /^:::wa-popover([^\n]*)$\n(.*?)\n^>>>$\n(.*?)\n^:::$/m
26
31
 
32
+ # Inline transformation (always link style, plain text content)
33
+ inline_transform = {
34
+ regex: inline_regex,
35
+ block: proc do |_match, matchdata|
36
+ combined = matchdata[1]
37
+ popover_content = matchdata[2].strip
38
+
39
+ params_string, trigger_text = parse_inline_trigger_and_params(combined)
40
+ placement, without_arrow, distance, _link_style = parse_parameters(params_string)
41
+
42
+ popover_id = generate_popover_id(trigger_text, popover_content)
43
+
44
+ build_inline_popover_html(popover_id, trigger_text, popover_content,
45
+ { placement: placement, without_arrow: without_arrow,
46
+ distance: distance })
47
+ end
48
+ }
49
+
50
+ # Block transformation (existing)
27
51
  transform_proc = proc do |params_string, trigger_text, popover_content|
28
52
  trigger_text = trigger_text.strip
29
53
  popover_content = popover_content.strip
@@ -39,7 +63,11 @@ module Markawesome
39
63
  distance: distance, link_style: link_style })
40
64
  end
41
65
 
42
- patterns = dual_syntax_patterns(primary_regex, alternative_regex, transform_proc)
66
+ # Inline patterns first to avoid conflicts with block patterns
67
+ patterns = [
68
+ inline_transform,
69
+ *dual_syntax_patterns(primary_regex, alternative_regex, transform_proc)
70
+ ]
43
71
  apply_multiple_patterns(content, patterns)
44
72
  end
45
73
 
@@ -68,6 +96,50 @@ module Markawesome
68
96
  "popover-#{hash[0..7]}"
69
97
  end
70
98
 
99
+ def parse_inline_trigger_and_params(combined_string)
100
+ tokens = combined_string.strip.split(/\s+/)
101
+ param_tokens = []
102
+ trigger_tokens = []
103
+ found_content = false
104
+
105
+ tokens.each do |token|
106
+ if !found_content && popover_param?(token)
107
+ param_tokens << token
108
+ else
109
+ found_content = true
110
+ trigger_tokens << token
111
+ end
112
+ end
113
+
114
+ trigger_text = trigger_tokens.join(' ')
115
+
116
+ # If no trigger text remains, treat entire string as trigger (no params)
117
+ if trigger_text.empty?
118
+ ['', combined_string.strip]
119
+ else
120
+ [param_tokens.join(' '), trigger_text]
121
+ end
122
+ end
123
+
124
+ def popover_param?(token)
125
+ POPOVER_ATTRIBUTES.any? { |_attr, values| values.include?(token) } ||
126
+ token.match?(/^distance:\d+$/)
127
+ end
128
+
129
+ def build_inline_popover_html(popover_id, trigger_text, content_text, options)
130
+ trigger_content = escape_html(trigger_text)
131
+ content_escaped = escape_html(content_text)
132
+
133
+ popover_attrs = ["for='#{popover_id}'"]
134
+ popover_attrs << "placement='#{options[:placement]}'"
135
+ popover_attrs << 'without-arrow' if options[:without_arrow]
136
+ popover_attrs << "distance='#{options[:distance]}'" if options[:distance]
137
+
138
+ trigger = build_trigger(popover_id, trigger_content, true)
139
+
140
+ "#{trigger}<wa-popover #{popover_attrs.join(' ')}>#{content_escaped}</wa-popover>"
141
+ end
142
+
71
143
  def build_popover_html(popover_id, trigger_text, content_html, options)
72
144
  # Escape trigger text for security
73
145
  trigger_content = escape_html(trigger_text)
@@ -92,6 +164,7 @@ module Markawesome
92
164
  if link_style
93
165
  link_style_attr = 'background: none; border: none; padding: 0; ' \
94
166
  'color: inherit; text-decoration: underline; ' \
167
+ 'text-decoration-style: dotted; ' \
95
168
  'cursor: pointer; font: inherit;'
96
169
  "<button id='#{popover_id}' style='#{link_style_attr}'>#{trigger_content}</button>"
97
170
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Markawesome
4
- VERSION = '0.8.0'
4
+ VERSION = '0.9.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markawesome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janne Waren