markawesome 0.11.0 → 0.12.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: 7ff219b440ba6edf0b45bffa865e4ff4bf8516d5f3c214aa8bdff33c41133565
4
- data.tar.gz: b22df3f6875fcae4e9a98f0b86e384c2841ad14942f85832f70c5521c6a4058e
3
+ metadata.gz: 561615ddddb39ccde6417037237c2bc490d2ded75aba4b36faf77e1db0eac1cc
4
+ data.tar.gz: 10ce10fcf7a740754303363579558de85881b4a9e101c73525c7d6ce3ca674e4
5
5
  SHA512:
6
- metadata.gz: 84a1023e4464efd824f30f1612ede362a7469af9e47a3484b645dd921cad2c24aeda58f51ca4b00727ad5d327015e1cb68ed7892df00c97fdacee42ad3809c9a
7
- data.tar.gz: 883d44d1df8777343f2ff998ef95f8a832a6333066eca8d9e782c6c9026884c1e56f9459ecbd40b30f1f6be716bf22773c225eb0384867b6ad8d2fe1bef5c8a4
6
+ metadata.gz: 48b713e5d9b0cd1f182ce321923d02c59c85132c42b75ef2f58088dc5ed433101dac9049ea76abd5858f8f03779c7f56a25a7e2a2e21d484839f19bd8fd038f1
7
+ data.tar.gz: 034dda0ddfc5ca7c24d0107e10632dae1312d122170f65608a3b0bc224b3fe34289b829d68c306da39af08b0e62f16e963d92ad9c92d125ca91bebac06e321e9
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ 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.12.0] - 2026-06-19
8
+
9
+ ### Added
10
+
11
+ - `ButtonTransformer` link-form buttons now accept `target` (`_blank`, `_self`, `_parent`, `_top`) and a boolean `download` flag. When `target="_blank"` is set, `rel="noopener noreferrer"` is emitted automatically to guard against reverse tabnabbing. These attributes are emitted **only** on link-form buttons (markup wrapping a markdown link, e.g. `%%%brand _blank\n[Text](url)\n%%%`); written on a regular (non-link) button they are parsed but dropped, consistent with the existing unrecognized-token behavior. They are also absent from the plain-markdown degradation path (`render_as_markdown`), since a plain `[text](url)` can't express them. A `download:filename` value form is a possible future enhancement.
12
+
7
13
  ## [0.11.0] - 2026-06-16
8
14
 
9
15
  Aligns generated markup with Web Awesome 3.8.0 (latest). See `ROADMAP.md` for the remaining enhancement backlog from the same audit.
@@ -18,6 +18,11 @@ module Markawesome
18
18
  # - loading: loading (loading state)
19
19
  # - disabled: disabled (disabled state)
20
20
  #
21
+ # Link-form only (emitted only when content is a markdown link):
22
+ # - target: _blank, _self, _parent, _top (target="_blank" also emits
23
+ # rel="noopener noreferrer" automatically)
24
+ # - download: download (bare download attribute)
25
+ #
21
26
  # Link buttons: %%%brand\n[Text](url)\n%%%
22
27
  # Regular buttons: %%%brand large pill\nText\n%%%
23
28
  class ButtonTransformer < BaseTransformer
@@ -29,7 +34,9 @@ module Markawesome
29
34
  pill: %w[pill],
30
35
  caret: %w[caret],
31
36
  loading: %w[loading],
32
- disabled: %w[disabled]
37
+ disabled: %w[disabled],
38
+ target: %w[_blank _self _parent _top],
39
+ download: %w[download]
33
40
  }.freeze
34
41
 
35
42
  ICON_SLOTS = { default: 'start', slots: %w[start end] }.freeze
@@ -105,7 +112,9 @@ module Markawesome
105
112
  # Fix whitespace issues like in badges
106
113
  button_html = button_html.gsub(%r{(</\w+>)\s+}, '\1&nbsp;')
107
114
 
108
- "<wa-button#{attrs_string} href=\"#{link_url}\">#{icon_html}#{button_html}</wa-button>"
115
+ link_attrs_string = link_pass_through_attrs(attributes)
116
+
117
+ "<wa-button#{attrs_string} href=\"#{link_url}\"#{link_attrs_string}>#{icon_html}#{button_html}</wa-button>"
109
118
  else
110
119
  # It's a regular button
111
120
  button_html = markdown_to_html(content).strip
@@ -117,6 +126,17 @@ module Markawesome
117
126
  "<wa-button#{attrs_string}>#{icon_html}#{button_html}</wa-button>"
118
127
  end
119
128
  end
129
+
130
+ # Plain anchor pass-throughs, meaningful only on link-form buttons.
131
+ # Auto-emit rel="noopener noreferrer" with target="_blank" to guard
132
+ # against reverse tabnabbing.
133
+ def link_pass_through_attrs(attributes)
134
+ link_attrs = []
135
+ link_attrs << "target=\"#{attributes[:target]}\"" if attributes[:target]
136
+ link_attrs << 'rel="noopener noreferrer"' if attributes[:target] == '_blank'
137
+ link_attrs << 'download' if attributes[:download]
138
+ link_attrs.empty? ? '' : " #{link_attrs.join(' ')}"
139
+ end
120
140
  end
121
141
  end
122
142
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Markawesome
4
- VERSION = '0.11.0'
4
+ VERSION = '0.12.0'
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.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janne Waren