html-pipeline 3.0.0 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/README.md +5 -5
- data/lib/html_pipeline/version.rb +1 -1
- data/lib/html_pipeline.rb +34 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad9e9991f181f9b708acdb8b5ba27537e759f3f87cd624c2587e248524747f0f
|
4
|
+
data.tar.gz: ffaa220bac349aedd97a240de688c6ef0abe44b947a8aedd9df804fc13057e71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41179127f775429b7de505c334d76a22771a903a9bcfb4fe6c47c344aae6fa94b92d15a66fb41bb61657924a5360548858ee7c7daac08476c2b72be73f355230
|
7
|
+
data.tar.gz: 1f937f9f2eee0ea99d5d8c1069648f10c8702da88524057e70aa1ca691be1a49bf645f249bdb07b6d4ccc8c9620ec463ca85f2285274cfee29a3f052368128c9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,40 @@
|
|
1
|
+
## [v3.0.1] - 28-12-2023
|
2
|
+
## What's Changed
|
3
|
+
* Handle odd numbers of NodeFilters to be configured by @stevehill1981 in https://github.com/gjtorikian/html-pipeline/pull/389
|
4
|
+
|
5
|
+
## New Contributors
|
6
|
+
* @stevehill1981 made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/389
|
7
|
+
|
8
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.0...v3.0.1
|
9
|
+
## [v3.0.0] - 24-12-2023
|
10
|
+
## What's Changed
|
11
|
+
* Switch to GitHub Actions by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/346
|
12
|
+
* add truffleruby-head by @gogainda in https://github.com/gjtorikian/html-pipeline/pull/348
|
13
|
+
* Add Rubocop by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/349
|
14
|
+
* Support multiple dependencies per filter by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/351
|
15
|
+
* Split filters up by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/360
|
16
|
+
* Migrate from Nokogiri to Selma by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/368
|
17
|
+
* You shall pass by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/369
|
18
|
+
* Update Selma signatures by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/370
|
19
|
+
* Close sanitization-related issues by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/371
|
20
|
+
* Drop SyntaxHighlightFilter by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/372
|
21
|
+
* V3 Release by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/347
|
22
|
+
* Use emoji from commonmarker by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/373
|
23
|
+
* req convert_filter if filter present by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/375
|
24
|
+
* Update selma requirement from ~> 0.0.1 to >= 0.0.1, < 0.2.0 by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/377
|
25
|
+
* Add the AssetProxyFilter by @digitalmoksha in https://github.com/gjtorikian/html-pipeline/pull/379
|
26
|
+
* Update rouge requirement from ~> 3.1 to ~> 4.1 by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/381
|
27
|
+
* Update gemoji requirement from ~> 3.0 to ~> 4.1 by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/382
|
28
|
+
* Have Zeitwerk not automatically load filters by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/383
|
29
|
+
* Bump the github-actions group with 1 update by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/384
|
30
|
+
* :gem: 3.0.0 by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/386
|
31
|
+
|
32
|
+
## New Contributors
|
33
|
+
* @gogainda made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/348
|
34
|
+
* @dependabot made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/377
|
35
|
+
* @digitalmoksha made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/379
|
36
|
+
|
37
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v2.14.3...v3.0.0
|
1
38
|
## [v3.0.0.pre6] - 16-08-2023
|
2
39
|
null
|
3
40
|
# Changelog
|
data/README.md
CHANGED
@@ -91,8 +91,8 @@ pipeline.call(user_supplied_text) # recommended: can call pipeline over and over
|
|
91
91
|
Filters can be custom ones you create (like `HelloJohnnyFilter`), and `HTMLPipeline` additionally provides several helpful ones (detailed below). If you only need a single filter, you can call one individually, too:
|
92
92
|
|
93
93
|
```ruby
|
94
|
-
filter = HTMLPipeline::ConvertFilter::MarkdownFilter.new
|
95
|
-
filter.call
|
94
|
+
filter = HTMLPipeline::ConvertFilter::MarkdownFilter.new
|
95
|
+
filter.call(text)
|
96
96
|
```
|
97
97
|
|
98
98
|
Filters combine into a sequential pipeline, and each filter hands its
|
@@ -104,9 +104,9 @@ used to pass around arguments and metadata between filters in a pipeline. For
|
|
104
104
|
example, if you want to disable footnotes in the `MarkdownFilter`, you can pass an option in the context hash:
|
105
105
|
|
106
106
|
```ruby
|
107
|
-
context = { markdown: extensions: { footnotes: false } }
|
108
|
-
filter = HTMLPipeline::ConvertFilter::MarkdownFilter.new(
|
109
|
-
filter.call
|
107
|
+
context = { markdown: { extensions: { footnotes: false } } }
|
108
|
+
filter = HTMLPipeline::ConvertFilter::MarkdownFilter.new(context: context)
|
109
|
+
filter.call("Hi **world**!")
|
110
110
|
```
|
111
111
|
|
112
112
|
Please refer to the documentation for each filter to understand what configuration options are available.
|
data/lib/html_pipeline.rb
CHANGED
@@ -114,10 +114,10 @@ class HTMLPipeline
|
|
114
114
|
def initialize(text_filters: [], convert_filter: nil, sanitization_config: SanitizationFilter::DEFAULT_CONFIG, node_filters: [], default_context: {}, result_class: Hash)
|
115
115
|
raise ArgumentError, "default_context cannot be nil" if default_context.nil?
|
116
116
|
|
117
|
-
@text_filters = text_filters.flatten.freeze
|
117
|
+
@text_filters = text_filters.flatten.freeze || []
|
118
118
|
validate_filters(@text_filters, HTMLPipeline::TextFilter)
|
119
119
|
|
120
|
-
@node_filters = node_filters.flatten.freeze
|
120
|
+
@node_filters = node_filters.flatten.freeze || []
|
121
121
|
validate_filters(@node_filters, HTMLPipeline::NodeFilter)
|
122
122
|
|
123
123
|
@convert_filter = convert_filter
|
@@ -151,34 +151,47 @@ class HTMLPipeline
|
|
151
151
|
context = context.freeze
|
152
152
|
result ||= {}
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
154
|
+
if @text_filters.any?
|
155
|
+
payload = default_payload({
|
156
|
+
text_filters: @text_filters.map(&:name),
|
157
|
+
context: context,
|
158
|
+
result: result,
|
159
|
+
})
|
160
|
+
instrument("call_text_filters.html_pipeline", payload) do
|
161
|
+
result[:output] =
|
162
|
+
@text_filters.inject(text) do |doc, filter|
|
163
|
+
perform_filter(filter, doc, context: context, result: result)
|
164
|
+
end
|
165
|
+
end
|
164
166
|
end
|
165
167
|
|
166
|
-
text = result[:output]
|
168
|
+
text = result[:output] || text
|
167
169
|
|
168
|
-
html =
|
170
|
+
html = if @convert_filter.nil?
|
171
|
+
text
|
172
|
+
else
|
173
|
+
instrument("call_convert_filter.html_pipeline", payload) do
|
174
|
+
html = @convert_filter.call(text)
|
175
|
+
end
|
176
|
+
end
|
169
177
|
|
170
178
|
unless @node_filters.empty?
|
171
|
-
payload = default_payload({
|
172
|
-
node_filters: @node_filters.map { |f| f.class.name },
|
173
|
-
context: context,
|
174
|
-
result: result,
|
175
|
-
})
|
176
179
|
instrument("call_node_filters.html_pipeline", payload) do
|
177
180
|
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
|
181
|
+
html = result[:output]
|
182
|
+
payload = default_payload({
|
183
|
+
node_filters: @node_filters.map { |f| f.class.name },
|
184
|
+
context: context,
|
185
|
+
result: result,
|
186
|
+
})
|
178
187
|
end
|
179
188
|
end
|
180
189
|
|
181
|
-
|
190
|
+
instrument("html_pipeline.sanitization", payload) do
|
191
|
+
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
|
192
|
+
end
|
193
|
+
|
194
|
+
result = result.merge(@node_filters.collect(&:result).reduce({}, :merge))
|
182
195
|
@node_filters.each(&:reset!)
|
183
196
|
|
184
197
|
result
|
@@ -195,6 +208,7 @@ class HTMLPipeline
|
|
195
208
|
context: context,
|
196
209
|
result: result,
|
197
210
|
})
|
211
|
+
|
198
212
|
instrument("call_filter.html_pipeline", payload) do
|
199
213
|
filter.call(doc, context: context, result: result)
|
200
214
|
end
|
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.0.
|
4
|
+
version: 3.0.2
|
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: 2024-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selma
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: 3.3.22
|
113
113
|
requirements: []
|
114
|
-
rubygems_version: 3.5.
|
114
|
+
rubygems_version: 3.5.4
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Helpers for processing content through a chain of filters
|