jekyll-uj-powertools 1.6.16 → 1.6.18

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: 3525305db3359ec2b34b99d69681a2189d744d10fb5185ff630a94cfd8b87c24
4
- data.tar.gz: 4d7141ef6612afdaddb25ff3638d1e0c0a3cd74efc7203803525e442cb2c1e69
3
+ metadata.gz: d5a95d2533971ede100996d4a58e143ab3ed3979240ef87c8bd77f633427ab8a
4
+ data.tar.gz: 296767e306a59dc4453ff79177a33c31ddf0a05b3bf4f39a5a76472072a96d35
5
5
  SHA512:
6
- metadata.gz: 88380af684a51309bd99960162fe1f5a058baf32692d5ad2329108982c9a36b3af01e7fe28e67106508d79f6f38fa0a1cc0fad9b8ae7deb6fd566bc30f71eb47
7
- data.tar.gz: ef8d56dd53a6bcdd604bdd4131ceef33f302dad416c55d703368f6c80b9784926652a8bebf7a33516c13e462b7f6b68b1daa51730ddd2a7c1b0546eb09a7bd84
6
+ metadata.gz: c82375ecc6c963b9893c61b963609d41d8ef4ee58f9583b41fbcfea079b29f710f1a825ba9f24f65b3f76b7fdd6ab258c3507415b7ff0e96f68b318026527803
7
+ data.tar.gz: a44445aa47cce16fd5b9f5f203ec58161ed334017acd8fce48c55f17a17e4fe974d8dc8cc7b92907dedaf0f38983fb30605c41859a2db23758b2915fe7533980
data/README.md CHANGED
@@ -71,7 +71,7 @@ Convert a string to title case.
71
71
  ```
72
72
 
73
73
  ### `uj_content_format` Filter
74
- Process content with Liquid templating and Markdown conversion, automatically transforming markdown images to responsive `uj_image` tags.
74
+ Process content with Liquid templating and Markdown conversion, automatically transforming markdown and liquid into HTML intelligently based on the file type.
75
75
 
76
76
  ```liquid
77
77
  {{ post.content | uj_content_format }}
@@ -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.6.16"
8
+ spec.version = "1.6.18"
9
9
 
10
10
  # Author info
11
11
  spec.authors = ["ITW Creative Works"]
data/lib/filters/main.rb CHANGED
@@ -77,21 +77,17 @@ module Jekyll
77
77
  def uj_content_format(input)
78
78
  # Return empty string if input is nil
79
79
  return '' unless input
80
-
80
+
81
81
  # Get the current page from context
82
82
  page = @context.registers[:page] if @context.respond_to?(:registers)
83
83
  page ||= @context[:registers][:page] if @context.is_a?(Hash)
84
-
84
+
85
85
  # Get site from context
86
86
  site = @context.registers[:site] if @context.respond_to?(:registers)
87
87
  site ||= @context[:registers][:site] if @context.is_a?(Hash)
88
88
 
89
- # Simply apply liquify first (markdown images are already converted to uj_image tags by the hook)
90
- liquified = if @context.respond_to?(:registers)
91
- Liquid::Template.parse(input).render(@context)
92
- else
93
- Liquid::Template.parse(input).render(@context[:registers] || {})
94
- end
89
+ # Apply recursive liquify (markdown images are already converted to uj_image tags by the hook)
90
+ liquified = uj_liquify(input)
95
91
 
96
92
  # Check if the page extension is .md
97
93
  if page && page['extension'] == '.md' && site
@@ -104,25 +100,61 @@ module Jekyll
104
100
  end
105
101
  end
106
102
 
103
+ # # Process Liquid template syntax within a string
104
+ # def liquify(input)
105
+ # return '' unless input
106
+
107
+ # if @context.respond_to?(:registers)
108
+ # Liquid::Template.parse(input).render(@context)
109
+ # else
110
+ # Liquid::Template.parse(input).render(@context[:registers] || {})
111
+ # end
112
+ # end
113
+
114
+ # Process Liquid template syntax within a string, recursively handling nested Liquid variables
115
+ def uj_liquify(input, max_depth = 10)
116
+ return '' unless input
117
+
118
+ depth = 0
119
+ result = input.to_s
120
+
121
+ # Keep processing while we detect Liquid syntax and haven't exceeded max depth
122
+ while (result.include?('{{') || result.include?('{%')) && depth < max_depth
123
+ new_result = if @context.respond_to?(:registers)
124
+ Liquid::Template.parse(result).render(@context)
125
+ else
126
+ Liquid::Template.parse(result).render(@context[:registers] || {})
127
+ end
128
+
129
+ # If nothing changed, we're done (prevents infinite loops)
130
+ break if new_result == result
131
+
132
+ result = new_result
133
+ depth += 1
134
+ end
135
+
136
+ result
137
+ end
138
+
107
139
  # Pretty print JSON with configurable indentation (default 2 spaces)
108
140
  def uj_jsonify(input, indent_size = 2)
109
141
  indent_string = ' ' * indent_size.to_i
110
142
  JSON.pretty_generate(input, indent: indent_string)
111
143
  end
112
-
144
+
113
145
  private
114
-
146
+
115
147
  # Helper method to safely dig through nested hashes
116
148
  def dig_value(hash, *keys)
117
149
  return nil unless hash
118
-
150
+
119
151
  value = hash
120
152
  keys.each do |key|
121
153
  return nil unless value.is_a?(Hash)
122
154
  value = value[key]
123
155
  return nil if value.nil?
124
156
  end
125
-
157
+
126
158
  value
127
159
  end
128
160
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-uj-powertools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.16
4
+ version: 1.6.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITW Creative Works
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-21 00:00:00.000000000 Z
11
+ date: 2025-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll