html-pipeline 3.2.2 → 3.2.4

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: 6e66a69a9e35bc5703f036d091740bdc654f98cfaf38870761797699ed28199b
4
- data.tar.gz: 7624bb08357fa9f358cb4947dbf5742916a3e620fa7db2d5296e9aba414e40f5
3
+ metadata.gz: fd951d54c89f057036db67e4d74dbca0de8e5ca07f27a89979d3b7814ec67a38
4
+ data.tar.gz: ef06eacc4b6eab0f53d207d873eb02fb0b61c4f746a621f0ad1c4800b5292bce
5
5
  SHA512:
6
- metadata.gz: 19083c1093cf8908028e8ea5233c97005a25072b5d77e9c28368570d477ff09cba5f6ae78e93e3633b766b9dcaeccc7bd746aacecbfdf480cd467306b230c1af
7
- data.tar.gz: 74e3afc29616225353448945af5a3ee516a8cea67924e865edf89a65b92cf77d56196b2be50ccd6fce6d5d343ed4cc7181b3b6b7d2a146dbb281a1165ba66ef3
6
+ metadata.gz: 4dc2bf7b6c312ee045c31df9fb48d76303563fffbc863c3cb70a3c0caf96e8040ae6fb3ff99c9c1e7c7aa8dddeae7cafeb7cc287c54d1b920cea44731fe39878
7
+ data.tar.gz: 8d0f26c1474af8a306b35659d4f4a3633922484fcd4ce6e97c3d4804684b195b67fe58bf42cb2c1ff95e6486c13932633365d3326db6bc071f6cf2d55b45660b
@@ -1,6 +1,7 @@
1
1
  name: PR auto-{approve,merge}
2
2
 
3
3
  on:
4
+ workflow_dispatch:
4
5
  pull_request_target:
5
6
 
6
7
  permissions:
@@ -8,6 +9,8 @@ permissions:
8
9
  contents: write
9
10
 
10
11
  jobs:
11
- dependabot:
12
- uses: yettoapp/actions/.github/workflows/automerge_dependabot.yml@main
13
- secrets: inherit
12
+ bot-check:
13
+ uses: gjtorikian/actions/.github/workflows/automerge.yml@main
14
+ secrets:
15
+ gh_token: ${{ secrets.GITHUB_TOKEN }}
16
+
@@ -4,19 +4,11 @@ on:
4
4
  pull_request:
5
5
 
6
6
  permissions:
7
- contents: read
7
+ contents: write
8
+ pull-requests: write
8
9
 
9
10
  jobs:
10
11
  test:
11
- runs-on: ubuntu-latest
12
-
13
- steps:
14
- - uses: actions/checkout@v4
15
-
16
- - name: Set up Ruby
17
- uses: yettoapp/actions/setup-languages@main
18
- with:
19
- ruby: true
20
-
21
- - name: Run tests
22
- run: bundle exec rake test
12
+ uses: gjtorikian/actions/.github/workflows/ruby_test_suite.yml@main
13
+ secrets:
14
+ gh_token: ${{ secrets.GITHUB_TOKEN }}
@@ -1,4 +1,4 @@
1
- name: Linting
1
+ name: Lint
2
2
 
3
3
  on:
4
4
  pull_request:
@@ -6,18 +6,11 @@ on:
6
6
  - "**/*.rb"
7
7
 
8
8
  permissions:
9
- contents: read
9
+ contents: write
10
10
 
11
11
  jobs:
12
- test:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v4
12
+ lint:
13
+ uses: gjtorikian/actions/.github/workflows/ruby_lint.yml@main
14
+ secrets:
15
+ gh_token: ${{ secrets.GITHUB_TOKEN }}
16
16
 
17
- - name: Set up Ruby
18
- uses: yettoapp/actions/setup-languages@main
19
- with:
20
- ruby: true
21
-
22
- - name: Rubocop
23
- run: bundle exec rake rubocop
@@ -11,14 +11,20 @@ on:
11
11
  types:
12
12
  - closed
13
13
 
14
+ permissions:
15
+ pull-requests: write
16
+ contents: write
17
+ id-token: write
18
+ actions: write
19
+
14
20
  jobs:
15
21
  ruby:
16
- uses: yettoapp/actions/.github/workflows/ruby_gem_release.yml@main
22
+ uses: gjtorikian/actions/.github/workflows/ruby_gem_release.yml@main
17
23
  secrets:
18
- rubygems_api_key: ${{ secrets.RUBYGEMS_API_BOT_KEY }}
19
24
  gh_token: ${{ secrets.GITHUB_TOKEN }}
20
25
  with:
21
26
  gem_name: html-pipeline
22
27
  version_filepath: lib/html_pipeline/version.rb
23
28
  prepare: ${{ github.event_name == 'push' }}
24
29
  release: ${{ github.event_name == 'workflow_dispatch' || ((github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'release'))) }}
30
+ oidc_role_to_assume: rg_oidc_akr_h9dt72ax2bswgewowdv7
data/.gitignore CHANGED
@@ -17,4 +17,6 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
  exec/*
20
+
20
21
  vendor/cache/
22
+ vendor/bundle/
data/.rubocop.yml CHANGED
@@ -15,3 +15,6 @@ AllCops:
15
15
  - "vendor/**/*"
16
16
  - "tmp/**/*"
17
17
  - "test/progit/**/*"
18
+
19
+ ThreadSafety/ClassAndModuleAttributes:
20
+ Enabled: false
@@ -4,5 +4,8 @@
4
4
  },
5
5
  "[ruby]": {
6
6
  "editor.defaultFormatter": "Shopify.ruby-lsp"
7
+ },
8
+ "[github-actions-workflow]": {
9
+ "editor.defaultFormatter": "redhat.vscode-yaml"
7
10
  }
8
11
  }
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ # [v3.2.4] - 06-01-2026
2
+ ## What's Changed
3
+ * [skip test] Release v3.2.3 by @github-actions[bot] in https://github.com/gjtorikian/html-pipeline/pull/419
4
+ * Bump actions/checkout from 4 to 5 in the github-actions group by @dependabot[bot] in https://github.com/gjtorikian/html-pipeline/pull/424
5
+ * Bump actions/checkout from 5 to 6 in the github-actions group by @dependabot[bot] in https://github.com/gjtorikian/html-pipeline/pull/426
6
+ * Support Ruby 4.0 by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/427
7
+ * Allow for completely nil sanitization by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/428
8
+
9
+
10
+ **Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.2.3...v3.2.4
11
+ # [v3.2.3] - 24-04-2025
12
+ ## What's Changed
13
+ * Allow for just text pipelines by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/418
14
+
15
+
16
+ **Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.2.2...v3.2.3
1
17
  # [v3.2.2] - 09-08-2024
2
18
  ## What's Changed
3
19
  * Add support for @ prefix on MentionFilter base_url by @jeremysmithco in https://github.com/gjtorikian/html-pipeline/pull/411
data/Gemfile CHANGED
@@ -25,12 +25,12 @@ group :development do
25
25
  end
26
26
 
27
27
  group :test do
28
- gem "commonmarker", "~> 2.0.1", require: false
28
+ gem "commonmarker", "~> 2.6", require: false
29
29
  gem "gemoji", "~> 4.1", require: false
30
30
  gem "gemojione", "~> 4.3", require: false
31
31
 
32
- gem "minitest"
33
-
32
+ gem "minitest", "~> 6.0"
33
+ gem "minitest-mock", "~> 5.27"
34
34
  gem "minitest-bisect", "~> 1.6"
35
35
 
36
36
  gem "nokogiri", "~> 1.13"
@@ -16,7 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.files = %x(git ls-files -z).split("\x0").reject { |f| f =~ %r{^(test|gemfiles|script)/} }
17
17
  gem.require_paths = ["lib"]
18
18
 
19
- gem.required_ruby_version = "~> 3.1"
19
+ gem.required_ruby_version = ">= 3.2"
20
+
20
21
  # https://github.com/rubygems/rubygems/pull/5852#issuecomment-1231118509
21
22
  gem.required_rubygems_version = ">= 3.3.22"
22
23
 
@@ -73,10 +73,10 @@ class HTMLPipeline
73
73
  default_img_attrs(name).transform_keys(&:to_sym)
74
74
  .merge!(context[:img_attrs] || {}).transform_keys(&:to_sym)
75
75
  .each_with_object([]) do |(attr, value), arr|
76
- next if value.nil?
76
+ next if value.nil?
77
77
 
78
- value = value.respond_to?(:call) && value.call(name) || value
79
- arr << %(#{attr}="#{value}")
78
+ value = value.respond_to?(:call) && value.call(name) || value
79
+ arr << %(#{attr}="#{value}")
80
80
  end.compact.join(" ")
81
81
 
82
82
  "<img #{html_attrs}>"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class HTMLPipeline
4
- VERSION = "3.2.2"
4
+ VERSION = "3.2.4"
5
5
  end
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? && (!@text_filters.empty? && !@node_filters.empty?)
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: context,
158
- result: 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: result)
163
+ perform_filter(filter, doc, context: (filter.context || {}).merge(context), result:)
164
164
  end
165
165
  end
166
166
  end
@@ -181,20 +181,22 @@ 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
- else
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: context,
195
- result: result,
194
+ context:,
195
+ result:,
196
196
  })
197
197
  end
198
+ else
199
+ result[:output] = html
198
200
  end
199
201
 
200
202
  result = result.merge(@node_filters.collect(&:result).reduce({}, :merge))
@@ -211,18 +213,18 @@ class HTMLPipeline
211
213
  def perform_filter(filter, doc, context: {}, result: {})
212
214
  payload = default_payload({
213
215
  filter: filter.class.name,
214
- context: context,
215
- result: result,
216
+ context:,
217
+ result:,
216
218
  })
217
219
 
218
220
  instrument("call_filter.html_pipeline", payload) do
219
- filter.call(doc, context: context, result: result)
221
+ filter.call(doc, context:, result:)
220
222
  end
221
223
  end
222
224
 
223
225
  # Like call but guarantee the value returned is a string of HTML markup.
224
226
  def to_html(input, context: {}, result: {})
225
- result = call(input, context: context, result: result)
227
+ result = call(input, context:, result:)
226
228
  output = result[:output]
227
229
  if output.respond_to?(:to_html)
228
230
  output.to_html
@@ -272,7 +274,7 @@ class HTMLPipeline
272
274
  invalid_filters = filters.reject { |f| correctly_ancestored?(f, klass) }
273
275
 
274
276
  unless invalid_filters.empty?
275
- verb = invalid_filters.count == 1 ? "does" : "do"
277
+ verb = invalid_filters.one? ? "does" : "do"
276
278
  raise InvalidFilterError, "All filters must inherit from `#{klass}`; #{invalid_filters.join(", ")} #{verb} not"
277
279
  end
278
280
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: selma
@@ -24,7 +23,6 @@ dependencies:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0.4'
27
- force_ruby_platform: false
28
26
  - !ruby/object:Gem::Dependency
29
27
  name: zeitwerk
30
28
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +37,6 @@ dependencies:
39
37
  - - "~>"
40
38
  - !ruby/object:Gem::Version
41
39
  version: '2.5'
42
- force_ruby_platform: false
43
40
  description: HTML processing filters and utilities
44
41
  email:
45
42
  - gjtorikian@gmail.com
@@ -102,17 +99,16 @@ require_paths:
102
99
  - lib
103
100
  required_ruby_version: !ruby/object:Gem::Requirement
104
101
  requirements:
105
- - - "~>"
102
+ - - ">="
106
103
  - !ruby/object:Gem::Version
107
- version: '3.1'
104
+ version: '3.2'
108
105
  required_rubygems_version: !ruby/object:Gem::Requirement
109
106
  requirements:
110
107
  - - ">="
111
108
  - !ruby/object:Gem::Version
112
109
  version: 3.3.22
113
110
  requirements: []
114
- rubygems_version: 3.4.6
115
- signing_key:
111
+ rubygems_version: 4.0.3
116
112
  specification_version: 4
117
113
  summary: Helpers for processing content through a chain of filters
118
114
  test_files: []