html-pipeline 3.2.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d505d0765630595363061d97d8f189a2712fc56b89371542a225d35421af386
4
- data.tar.gz: 9d10f5ad3c9d39fe65d6e3b22cd59070997e5774353806affde0a957a52f5812
3
+ metadata.gz: 4ee767ba855fbce40027a79f0a7847c5455354efe01293d07dd5dfc4cf0ee915
4
+ data.tar.gz: 0210caf87e60730954c56005ef6cf372a1aad46b72f14554790799e9a3741ba3
5
5
  SHA512:
6
- metadata.gz: 63b53387dfbb3bc7a9be29f0e6de9930daa773254dc885d0561b59a8d8ff50317ddabe62c364253b6da7142b3c4d169f72ce43f217ec50d18aee450513e88f13
7
- data.tar.gz: 948027919009faea3009e0e222491aeae865db4875602a40bbf5a458f8b712f633b6e66d386e95acadbb129bcba33f63afdddbc89b73758cc1b544855eb5b227
6
+ metadata.gz: bcf817cc462caf0f082aac827c3959dba7aab1b988d072304c450415fdf763ee32d8e6974d95f856fa98bf1b2505115e9e75ee09b242fecb49db0d75dd7056a8
7
+ data.tar.gz: f4ba81e5b1acba6a6e22b799a2ac802a0ae67822371b9d351ae2d3e033f7495e93e1f64495a280104768453b5c9ed26be5bd7007a2bb95fe077274ce8b2fa524
data/.gitignore CHANGED
@@ -17,4 +17,4 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
  exec/*
20
- vendor/gems
20
+ vendor/cache/
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
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [v3.2.2] - 09-08-2024
2
+ ## What's Changed
3
+ * Add support for @ prefix on MentionFilter base_url by @jeremysmithco in https://github.com/gjtorikian/html-pipeline/pull/411
4
+ * Bugfix: sanitization-only filters should still work by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/414
5
+
6
+ ## New Contributors
7
+ * @jeremysmithco made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/411
8
+
9
+ **Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.2.1...v3.2.2
1
10
  # [v3.2.1] - 16-07-2024
2
11
  ## What's Changed
3
12
  * Update commonmarker requirement from ~> 1.0.0.pre7 to ~> 1.1.2 in the bundler-dependencies group by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/404
data/Gemfile CHANGED
@@ -25,7 +25,7 @@ group :development do
25
25
  end
26
26
 
27
27
  group :test do
28
- gem "commonmarker", "~> 1.1.2", require: false
28
+ gem "commonmarker", "~> 2.0.1", require: false
29
29
  gem "gemoji", "~> 4.1", require: false
30
30
  gem "gemojione", "~> 4.3", require: false
31
31
 
data/README.md CHANGED
@@ -343,34 +343,6 @@ service.subscribe "call_text_filters.html_pipeline" do |event, start, ending, tr
343
343
  end
344
344
  ```
345
345
 
346
- ## Third Party Extensions
347
-
348
- If you have an idea for a filter, propose it as
349
- [an issue](https://github.com/gjtorikian/html-pipeline/issues) first. This allows us to discuss
350
- whether the filter is a common enough use case to belong in this gem, or should be
351
- built as an external gem.
352
-
353
- Here are some extensions people have built:
354
-
355
- - [html-pipeline-asciidoc_filter](https://github.com/asciidoctor/html-pipeline-asciidoc_filter)
356
- - [jekyll-html-pipeline](https://github.com/gjtorikian/jekyll-html-pipeline)
357
- - [nanoc-html-pipeline](https://github.com/burnto/nanoc-html-pipeline)
358
- - [html-pipeline-bitly](https://github.com/dewski/html-pipeline-bitly)
359
- - [html-pipeline-cite](https://github.com/lifted-studios/html-pipeline-cite)
360
- - [tilt-html-pipeline](https://github.com/bradgessler/tilt-html-pipeline)
361
- - [html-pipeline-wiki-link'](https://github.com/lifted-studios/html-pipeline-wiki-link) - WikiMedia-style wiki links
362
- - [task_list](https://github.com/github/task_list) - GitHub flavor Markdown Task List
363
- - [html-pipeline-nico_link](https://github.com/rutan/html-pipeline-nico_link) - An HTMLPipeline filter for [niconico](http://www.nicovideo.jp) description links
364
- - [html-pipeline-gitlab](https://gitlab.com/gitlab-org/html-pipeline-gitlab) - This gem implements various filters for html-pipeline used by GitLab
365
- - [html-pipeline-youtube](https://github.com/st0012/html-pipeline-youtube) - An HTMLPipeline filter for YouTube links
366
- - [html-pipeline-flickr](https://github.com/st0012/html-pipeline-flickr) - An HTMLPipeline filter for Flickr links
367
- - [html-pipeline-vimeo](https://github.com/dlackty/html-pipeline-vimeo) - An HTMLPipeline filter for Vimeo links
368
- - [html-pipeline-hashtag](https://github.com/mr-dxdy/html-pipeline-hashtag) - An HTMLPipeline filter for hashtags
369
- - [html-pipeline-linkify_github](https://github.com/jollygoodcode/html-pipeline-linkify_github) - An HTMLPipeline filter to autolink GitHub urls
370
- - [html-pipeline-redcarpet_filter](https://github.com/bmikol/html-pipeline-redcarpet_filter) - Render Markdown source text into Markdown HTML using Redcarpet
371
- - [html-pipeline-typogruby_filter](https://github.com/bmikol/html-pipeline-typogruby_filter) - Add Typogruby text filters to your HTMLPipeline
372
- - [korgi](https://github.com/jodeci/korgi) - HTMLPipeline filters for links to Rails resources
373
-
374
346
  ## FAQ
375
347
 
376
348
  ### 1. Why doesn't my pipeline work when there's no root element in the document?
@@ -115,7 +115,8 @@ class HTMLPipeline
115
115
  result[:mentioned_usernames] |= [login]
116
116
 
117
117
  url = base_url.dup
118
- url << "/" unless %r{[/~]\z}.match?(url)
118
+ excluded_prefixes = %r{[/(?:~|@]\z}
119
+ url << "/" unless excluded_prefixes.match?(url)
119
120
 
120
121
  "<a href=\"#{url << login}\" class=\"user-mention\">" \
121
122
  "@#{login}" \
@@ -94,7 +94,8 @@ class HTMLPipeline
94
94
  result[:mentioned_teams] |= [team]
95
95
 
96
96
  url = base_url.dup
97
- url << "/" unless %r{[/~]\z}.match?(url)
97
+ excluded_prefixes = %r{[/(?:~|@]\z}
98
+ url << "/" unless excluded_prefixes.match?(url)
98
99
 
99
100
  "<a href=\"#{url << org}/#{team}\" class=\"team-mention\">" \
100
101
  "@#{org}/#{team}" \
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class HTMLPipeline
4
- VERSION = "3.2.1"
4
+ VERSION = "3.2.3"
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,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
- result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters, options: rewriter_options).rewrite(html)
187
- end unless @convert_filter.nil? # no html, so no sanitization
188
- else
186
+ result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, options: rewriter_options).rewrite(html)
187
+ end
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
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: context,
215
- result: result,
214
+ context:,
215
+ result:,
216
216
  })
217
217
 
218
218
  instrument("call_filter.html_pipeline", payload) do
219
- filter.call(doc, context: context, result: result)
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: context, result: result)
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.1
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-31 00:00:00.000000000 Z
11
+ date: 2025-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selma
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: 3.3.22
113
113
  requirements: []
114
114
  rubygems_version: 3.4.6
115
- signing_key:
115
+ signing_key:
116
116
  specification_version: 4
117
117
  summary: Helpers for processing content through a chain of filters
118
118
  test_files: []