jekyll-link-decorator 1.1.0 → 1.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-link-decorator.rb +14 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea2d97d68911bcc66b8fc4d96a008efc4c83862f7d9b4cb7a7e3beb09db30ff8
4
- data.tar.gz: 69048aacba831a96a6234cd29075b1056840ac75486c872ea82a6cfabc6b3ebe
3
+ metadata.gz: ff9d8d968a941fc6dc1788350c62c916145aa40a2b0bc1495013c527b8f4572e
4
+ data.tar.gz: 89135a31b61c3d9c6f378c36ba5ef89ebb008e7f9ceedbecf2b4f038bda39edf
5
5
  SHA512:
6
- metadata.gz: f2ac4e76db1455970d0f0b4a16d78a69acc44fb511c217790c00c4939ec59363505b0c454a41146e808c355a34360ca6ba7952ee22e9f9c5b6cd1b79dc1073fd
7
- data.tar.gz: 4204292972a14bf0c734c713bd2ab1dde5c65216239ef1c79ce67d2fbd297c44aa286a637bbebc89cc762efe16ea1d933ad4b19e4cce8349e52069267ff67b75
6
+ metadata.gz: 92bd0f66994b8eced13305a8ed07a0f389928e0efd4a60c0014b666d36cf64ed59659ac8ef155d0032637e88c1ffb8566099d881ba2153cd09249bcc51877f52
7
+ data.tar.gz: 128b172f33a1f53ce3542d1dbff596d4518d755855b9f808bc68b31d65caeb3e89b0374dc1aac80ebc9d594b13a61a319492d6c63fa52f9e9c8bfd045b7411de
@@ -36,6 +36,10 @@
36
36
  # .alert box. Example: `alert_link_classes: "text-decoration-underline"`
37
37
  # - `external_link_icon`: Boolean (default: true) that controls whether external-link
38
38
  # icons are added to cross-domain external links. Set to false to disable.
39
+ # - `external_link_icon_excluded_tags`: List of HTML child tag names (default: []) whose presence
40
+ # inside an anchor suppresses the external-link icon. Security attributes
41
+ # (target="_blank", rel="noopener noreferrer") are still applied.
42
+ # Example: `external_link_icon_excluded_tags: ["img", "svg"]`
39
43
  #
40
44
  # If no configuration is provided, the plugin will use default fallback classes
41
45
  # and enable external link icons.
@@ -48,6 +52,9 @@
48
52
  # default_link_classes: "link link-offset-3 link-offset-3-hover link-underline-primary link-underline-opacity-0 link-underline-opacity-100-hover"
49
53
  # alert_link_classes: "alert-link"
50
54
  # external_link_icon: true
55
+ # external_link_icon_excluded_tags:
56
+ # - img
57
+ # - svg
51
58
  # ```
52
59
 
53
60
  require 'nokogiri'
@@ -69,8 +76,9 @@ module Jekyll
69
76
  class LinkDecorator < Jekyll::Converters::Markdown
70
77
  DEFAULT_LINK_CLASSES = 'link link-offset-3 link-offset-3-hover link-underline-primary ' \
71
78
  'link-underline-opacity-0 link-underline-opacity-100-hover'
72
- DEFAULT_ALERT_CLASSES = 'alert-link'
79
+ DEFAULT_ALERT_LINK_CLASSES = 'alert-link'
73
80
  DEFAULT_EXTERNAL_LINK_ICON = true
81
+ DEFAULT_EXTERNAL_LINK_ICON_EXCLUDED_TAGS = [].freeze
74
82
 
75
83
  def self.name
76
84
  'LinkDecorator'
@@ -211,7 +219,7 @@ module Jekyll
211
219
  # Apply CSS classes to links based on their context (alert or default)
212
220
  def apply_link_styles(doc, config)
213
221
  default_classes = config.fetch('default_link_classes', DEFAULT_LINK_CLASSES)
214
- alert_classes = config.fetch('alert_link_classes', DEFAULT_ALERT_CLASSES)
222
+ alert_classes = config.fetch('alert_link_classes', DEFAULT_ALERT_LINK_CLASSES)
215
223
 
216
224
  # Apply alert classes to links inside p.alert
217
225
  doc.css('p.alert a:not(.btn)').each do |link|
@@ -252,6 +260,10 @@ module Jekyll
252
260
  external_link_icon = config.fetch('external_link_icon', DEFAULT_EXTERNAL_LINK_ICON)
253
261
 
254
262
  return unless external_link_icon
263
+
264
+ exclude_tags = config.fetch('external_link_icon_excluded_tags', DEFAULT_EXTERNAL_LINK_ICON_EXCLUDED_TAGS)
265
+ return if exclude_tags.any? { |tag| link.css(tag).any? }
266
+
255
267
  return unless is_external_different_domain_link?(link, site_domain)
256
268
 
257
269
  icon = Nokogiri::XML::Node.new('i', doc)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-link-decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ReleaseBot