jekyll-uj-powertools 1.7.7 → 1.7.8

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: b2bbc8c153db266e8ef63d1eb3a5223c4c84fe099623eb2ed8c525965a4583fc
4
- data.tar.gz: 404d483a3d63551ecf9cbb272b0c63afc6535050ec0b1688c4d2e176b2c8805d
3
+ metadata.gz: 6487d4258e4c8f8afe9d43a78898cdf73339924756f0d69f7ac19edb0f42a943
4
+ data.tar.gz: b0d0635fcd32cb3b9b78ffa4f0f1df976e573046d1b4fb19491d53d80ad83f1e
5
5
  SHA512:
6
- metadata.gz: 6caa4c4a8e3e30d8cb8f3c92d12e1b0480a4acd724c96f8e7ee833bd58e87057612f3f00525fbd2de40b9d26343c1d4117c80cbfd69a709a3e3fa5f7287d533e
7
- data.tar.gz: ed168cb35dad450d2adcad236f1810d2ffe76f0bc17d8589219758b13661b278199417cd8d3e6f1e0e18b1171664764eb4360741ffd1677f9855c8f60182910d
6
+ metadata.gz: 1030ea52ac7c9e11241602dc4b80a0c71e266ee1596735cf895e317e8566fc56adc29eeb6c94a28d398ca1fb372259aef8b81789442765079a50f09e7e5b9ff3
7
+ data.tar.gz: 186250ac81fdcc8756dc4b2ed6c9d7c62832ed384b70471efbacaab505c2905ec094b47bdb15b43cc1eadac503fb9d7a46fc0d318295ae1d772d7d3289f781a6
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  Gem::Specification.new do |spec|
6
6
  # Gem info
7
7
  spec.name = "jekyll-uj-powertools"
8
- spec.version = "1.7.7"
8
+ spec.version = "1.7.8"
9
9
 
10
10
  # Author info
11
11
  spec.authors = ["ITW Creative Works"]
@@ -18,11 +18,8 @@ module Jekyll
18
18
  # Get post ID for @post/ prefix resolution
19
19
  post_id = doc.data['post'] && doc.data['post']['id'] ? doc.data['post']['id'] : nil
20
20
 
21
- # Transform markdown images by parsing and rendering Liquid template
22
- doc.content = doc.content.gsub(/!\[([^\]]*)\]\(([^)]+)\)/) do
23
- alt_text = $1
24
- image_path = $2
25
-
21
+ # Shared transformer: convert ![alt](src) rendered <img> HTML
22
+ render_image = lambda do |alt_text, image_path|
26
23
  # Resolve @post/ prefix to full blog image path
27
24
  if image_path.start_with?('@post/')
28
25
  if post_id
@@ -33,19 +30,33 @@ module Jekyll
33
30
  end
34
31
  end
35
32
 
36
- # Build the Liquid tag string
37
33
  if image_class
38
34
  liquid_tag = "{% uj_image \"#{image_path}\", alt=\"#{alt_text}\", class=\"#{image_class}\" %}"
39
35
  else
40
36
  liquid_tag = "{% uj_image \"#{image_path}\", alt=\"#{alt_text}\" %}"
41
37
  end
42
38
 
43
- # Parse and render the Liquid template immediately
44
39
  template = Liquid::Template.parse(liquid_tag)
45
40
  context = doc.site.site_payload.merge({'page' => doc.to_liquid})
46
- result = template.render(Liquid::Context.new(context))
41
+ template.render(Liquid::Context.new(context))
42
+ end
47
43
 
48
- # Return the HTML with blank lines to ensure markdown treats it as raw HTML
44
+ # First pass: linked images [![alt](src)](href) <a href><img></a>
45
+ # Must run BEFORE the bare-image pass so the outer [](href) wrapper is preserved.
46
+ # Kramdown otherwise promotes the inner ![](src) to a block and discards the wrapping link.
47
+ # display:block on the anchor — otherwise an inline <a> has a 20px-tall hit
48
+ # box, and clicks on the (taller) image overflow miss the link entirely.
49
+ doc.content = doc.content.gsub(/\[!\[([^\]]*)\]\(([^)]+)\)\]\(([^)]+)\)/) do
50
+ alt_text = $1
51
+ image_path = $2
52
+ href = $3
53
+ img_html = render_image.call(alt_text, image_path)
54
+ "\n\n<a href=\"#{href}\" style=\"display:block\">#{img_html}</a>\n\n"
55
+ end
56
+
57
+ # Second pass: bare markdown images ![alt](src)
58
+ doc.content = doc.content.gsub(/!\[([^\]]*)\]\(([^)]+)\)/) do
59
+ result = render_image.call($1, $2)
49
60
  "\n\n#{result}\n\n"
50
61
  end
51
62
  end
data/lib/tags/iffile.rb CHANGED
@@ -16,11 +16,10 @@ module Jekyll
16
16
  # Get the site object
17
17
  site = context.registers[:site]
18
18
 
19
- # Use the helper to resolve input (handles both literals and variables)
20
- path = resolve_input(context, @path)
21
-
19
+ path = resolve_path(context)
20
+
22
21
  # Return empty if path couldn't be resolved
23
- return "" unless path
22
+ return "" if path.nil? || path.to_s.empty?
24
23
 
25
24
  # Ensure path starts with /
26
25
  path = "/#{path}" unless path.to_s.start_with?('/')
@@ -39,6 +38,27 @@ module Jekyll
39
38
  ""
40
39
  end
41
40
  end
41
+
42
+ private
43
+
44
+ # Resolve the path argument from context.
45
+ # Quoted strings are literals. Bare tokens are looked up as variables;
46
+ # if the root segment isn't defined in context, fall back to the literal markup.
47
+ def resolve_path(context)
48
+ return nil if @path.nil? || @path.empty?
49
+
50
+ # Quoted string literal
51
+ if @path.match(/^["'](.*)["']$/)
52
+ return $1
53
+ end
54
+
55
+ root = @path.split('.').first
56
+ resolved = resolve_variable(context, @path)
57
+ return resolved unless resolved.nil?
58
+
59
+ # Variable resolved to nil — fall back to literal only if root is also nil/undefined
60
+ context[root].nil? ? @path : nil
61
+ end
42
62
  end
43
63
  end
44
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-uj-powertools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.7
4
+ version: 1.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITW Creative Works