html-pipeline 3.2.2 → 3.2.3
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 +4 -4
- data/.rubocop.yml +3 -0
- data/lib/html_pipeline/version.rb +1 -1
- data/lib/html_pipeline.rb +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ee767ba855fbce40027a79f0a7847c5455354efe01293d07dd5dfc4cf0ee915
|
4
|
+
data.tar.gz: 0210caf87e60730954c56005ef6cf372a1aad46b72f14554790799e9a3741ba3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcf817cc462caf0f082aac827c3959dba7aab1b988d072304c450415fdf763ee32d8e6974d95f856fa98bf1b2505115e9e75ee09b242fecb49db0d75dd7056a8
|
7
|
+
data.tar.gz: f4ba81e5b1acba6a6e22b799a2ac802a0ae67822371b9d351ae2d3e033f7495e93e1f64495a280104768453b5c9ed26be5bd7007a2bb95fe077274ce8b2fa524
|
data/.rubocop.yml
CHANGED
data/lib/html_pipeline.rb
CHANGED
@@ -122,7 +122,7 @@ class HTMLPipeline
|
|
122
122
|
|
123
123
|
@convert_filter = convert_filter
|
124
124
|
|
125
|
-
if @convert_filter.nil? &&
|
125
|
+
if @convert_filter.nil? && !@text_filters.empty? && !@node_filters.empty?
|
126
126
|
raise InvalidFilterError, "Must provide `convert_filter` if `text_filters` and `node_filters` are also provided"
|
127
127
|
elsif !@convert_filter.nil?
|
128
128
|
validate_filter(@convert_filter, HTMLPipeline::ConvertFilter)
|
@@ -154,13 +154,13 @@ class HTMLPipeline
|
|
154
154
|
if @text_filters.any?
|
155
155
|
payload = default_payload({
|
156
156
|
text_filters: @text_filters.map { |f| f.class.name },
|
157
|
-
context
|
158
|
-
result
|
157
|
+
context:,
|
158
|
+
result:,
|
159
159
|
})
|
160
160
|
instrument("call_text_filters.html_pipeline", payload) do
|
161
161
|
result[:output] =
|
162
162
|
@text_filters.inject(text) do |doc, filter|
|
163
|
-
perform_filter(filter, doc, context: (filter.context || {}).merge(context), result:
|
163
|
+
perform_filter(filter, doc, context: (filter.context || {}).merge(context), result:)
|
164
164
|
end
|
165
165
|
end
|
166
166
|
end
|
@@ -181,18 +181,18 @@ class HTMLPipeline
|
|
181
181
|
},
|
182
182
|
}
|
183
183
|
|
184
|
-
if @node_filters.empty?
|
184
|
+
if @node_filters.empty? && !@sanitization_config.nil?
|
185
185
|
instrument("sanitization.html_pipeline", payload) do
|
186
186
|
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, options: rewriter_options).rewrite(html)
|
187
187
|
end
|
188
|
-
|
188
|
+
elsif @node_filters.any?
|
189
189
|
instrument("call_node_filters.html_pipeline", payload) do
|
190
190
|
@node_filters.each { |filter| filter.context = (filter.context || {}).merge(context) }
|
191
191
|
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters, options: rewriter_options).rewrite(html)
|
192
192
|
payload = default_payload({
|
193
193
|
node_filters: @node_filters.map { |f| f.class.name },
|
194
|
-
context
|
195
|
-
result
|
194
|
+
context:,
|
195
|
+
result:,
|
196
196
|
})
|
197
197
|
end
|
198
198
|
end
|
@@ -211,18 +211,18 @@ class HTMLPipeline
|
|
211
211
|
def perform_filter(filter, doc, context: {}, result: {})
|
212
212
|
payload = default_payload({
|
213
213
|
filter: filter.class.name,
|
214
|
-
context
|
215
|
-
result
|
214
|
+
context:,
|
215
|
+
result:,
|
216
216
|
})
|
217
217
|
|
218
218
|
instrument("call_filter.html_pipeline", payload) do
|
219
|
-
filter.call(doc, context
|
219
|
+
filter.call(doc, context:, result:)
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
223
|
# Like call but guarantee the value returned is a string of HTML markup.
|
224
224
|
def to_html(input, context: {}, result: {})
|
225
|
-
result = call(input, context
|
225
|
+
result = call(input, context:, result:)
|
226
226
|
output = result[:output]
|
227
227
|
if output.respond_to?(:to_html)
|
228
228
|
output.to_html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selma
|