html-pipeline 3.2.0 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish.yml +7 -2
- data/.gitignore +1 -1
- data/CHANGELOG.md +22 -0
- data/Gemfile +1 -1
- data/README.md +3 -31
- data/html-pipeline.gemspec +1 -1
- data/lib/html_pipeline/convert_filter/markdown_filter.rb +1 -1
- data/lib/html_pipeline/convert_filter.rb +1 -1
- data/lib/html_pipeline/node_filter/mention_filter.rb +2 -1
- data/lib/html_pipeline/node_filter/syntax_highlight_filter.rb +1 -1
- data/lib/html_pipeline/node_filter/team_mention_filter.rb +2 -1
- data/lib/html_pipeline/text_filter.rb +1 -1
- data/lib/html_pipeline/version.rb +1 -1
- data/lib/html_pipeline.rb +12 -7
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e66a69a9e35bc5703f036d091740bdc654f98cfaf38870761797699ed28199b
|
4
|
+
data.tar.gz: 7624bb08357fa9f358cb4947dbf5742916a3e620fa7db2d5296e9aba414e40f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19083c1093cf8908028e8ea5233c97005a25072b5d77e9c28368570d477ff09cba5f6ae78e93e3633b766b9dcaeccc7bd746aacecbfdf480cd467306b230c1af
|
7
|
+
data.tar.gz: 74e3afc29616225353448945af5a3ee516a8cea67924e865edf89a65b92cf77d56196b2be50ccd6fce6d5d343ed4cc7181b3b6b7d2a146dbb281a1165ba66ef3
|
@@ -1,4 +1,4 @@
|
|
1
|
-
name: Release
|
1
|
+
name: Tag and Release
|
2
2
|
|
3
3
|
on:
|
4
4
|
workflow_dispatch:
|
@@ -7,13 +7,18 @@ on:
|
|
7
7
|
- main
|
8
8
|
paths:
|
9
9
|
- "lib/html_pipeline/version.rb"
|
10
|
+
pull_request_target:
|
11
|
+
types:
|
12
|
+
- closed
|
10
13
|
|
11
14
|
jobs:
|
12
15
|
ruby:
|
13
16
|
uses: yettoapp/actions/.github/workflows/ruby_gem_release.yml@main
|
14
17
|
secrets:
|
15
18
|
rubygems_api_key: ${{ secrets.RUBYGEMS_API_BOT_KEY }}
|
16
|
-
gh_token: ${{ secrets.
|
19
|
+
gh_token: ${{ secrets.GITHUB_TOKEN }}
|
17
20
|
with:
|
18
21
|
gem_name: html-pipeline
|
19
22
|
version_filepath: lib/html_pipeline/version.rb
|
23
|
+
prepare: ${{ github.event_name == 'push' }}
|
24
|
+
release: ${{ github.event_name == 'workflow_dispatch' || ((github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'release'))) }}
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
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
|
10
|
+
# [v3.2.1] - 16-07-2024
|
11
|
+
## What's Changed
|
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
|
13
|
+
* Remove superfluous sanitization by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/408
|
14
|
+
|
15
|
+
|
16
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.2.0...v3.2.1
|
17
|
+
## [v3.2.0] - 30-04-2024
|
18
|
+
## What's Changed
|
19
|
+
* Pass context along to every part of the pipeline by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/403
|
20
|
+
|
21
|
+
|
22
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.1.1...v3.2.0
|
1
23
|
## [v3.1.1] - 09-04-2024
|
2
24
|
## What's Changed
|
3
25
|
* Correct missing method implementation by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/401
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -171,9 +171,9 @@ The `ConvertFilter` takes text and turns it into HTML. `@text`, `@config`, and `
|
|
171
171
|
|
172
172
|
### Sanitization
|
173
173
|
|
174
|
-
Because the web can be a scary place, HTML is automatically sanitized after the `ConvertFilter` runs and before the `NodeFilter`s are processed. This is to prevent malicious or unexpected input from entering the pipeline.
|
174
|
+
Because the web can be a scary place, **HTML is automatically sanitized** after the `ConvertFilter` runs and before the `NodeFilter`s are processed. This is to prevent malicious or unexpected input from entering the pipeline.
|
175
175
|
|
176
|
-
The sanitization process takes a hash configuration of settings. See the [Selma](https://www.github.com/gjtorikian/selma) documentation for more information on how to configure these settings.
|
176
|
+
The sanitization process takes a hash configuration of settings. See the [Selma](https://www.github.com/gjtorikian/selma) documentation for more information on how to configure these settings. Note that users must correctly configure the sanitization configuration if they expect to use it correctly in conjunction with handlers which manipulate HTML.
|
177
177
|
|
178
178
|
A default sanitization config is provided by this library (`HTMLPipeline::SanitizationFilter::DEFAULT_CONFIG`). A sample custom sanitization allowlist might look like this:
|
179
179
|
|
@@ -224,7 +224,7 @@ For more examples of customizing the sanitization process to include the tags yo
|
|
224
224
|
|
225
225
|
`NodeFilters`s can operate either on HTML elements or text nodes using CSS selectors. Each `NodeFilter` must define a method named `selector` which provides an instance of `Selma::Selector`. If elements are being manipulated, `handle_element` must be defined, taking one argument, `element`; if text nodes are being manipulated, `handle_text_chunk` must be defined, taking one argument, `text_chunk`. `@config`, and `@result` are available to use, and any changes made to these ivars are passed on to the next filter.
|
226
226
|
|
227
|
-
`NodeFilter` also has an optional method, `after_initialize`, which is run after the filter initializes. This can be useful in setting up a custom state for `result` to
|
227
|
+
`NodeFilter` also has an optional method, `after_initialize`, which is run after the filter initializes. This can be useful in setting up a fresh custom state for `result` to start from each time the pipeline is called.
|
228
228
|
|
229
229
|
Here's an example `NodeFilter` that adds a base url to images that are root relative:
|
230
230
|
|
@@ -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?
|
data/html-pipeline.gemspec
CHANGED
@@ -12,7 +12,7 @@ class HTMLPipeline
|
|
12
12
|
# :markdown[:extensions] => Commonmarker extensions options
|
13
13
|
class MarkdownFilter < ConvertFilter
|
14
14
|
def initialize(context: {}, result: {})
|
15
|
-
super
|
15
|
+
super
|
16
16
|
end
|
17
17
|
|
18
18
|
# Convert Commonmark to HTML using the best available implementation.
|
@@ -115,7 +115,8 @@ class HTMLPipeline
|
|
115
115
|
result[:mentioned_usernames] |= [login]
|
116
116
|
|
117
117
|
url = base_url.dup
|
118
|
-
|
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}" \
|
@@ -15,7 +15,7 @@ class HTMLPipeline
|
|
15
15
|
# This filter does not write any additional information to the context hash.
|
16
16
|
class SyntaxHighlightFilter < NodeFilter
|
17
17
|
def initialize(context: {}, result: {})
|
18
|
-
super
|
18
|
+
super
|
19
19
|
# TODO: test the optionality of this
|
20
20
|
@formatter = context[:formatter] || Rouge::Formatters::HTML.new
|
21
21
|
end
|
@@ -94,7 +94,8 @@ class HTMLPipeline
|
|
94
94
|
result[:mentioned_teams] |= [team]
|
95
95
|
|
96
96
|
url = base_url.dup
|
97
|
-
|
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}" \
|
data/lib/html_pipeline.rb
CHANGED
@@ -175,11 +175,20 @@ class HTMLPipeline
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
|
178
|
+
rewriter_options = {
|
179
|
+
memory: {
|
180
|
+
max_allowed_memory_usage: 5242880, # arbitrary limit of 5MB
|
181
|
+
},
|
182
|
+
}
|
183
|
+
|
184
|
+
if @node_filters.empty?
|
185
|
+
instrument("sanitization.html_pipeline", payload) do
|
186
|
+
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, options: rewriter_options).rewrite(html)
|
187
|
+
end
|
188
|
+
else
|
179
189
|
instrument("call_node_filters.html_pipeline", payload) do
|
180
190
|
@node_filters.each { |filter| filter.context = (filter.context || {}).merge(context) }
|
181
|
-
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
|
182
|
-
html = result[:output]
|
191
|
+
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters, options: rewriter_options).rewrite(html)
|
183
192
|
payload = default_payload({
|
184
193
|
node_filters: @node_filters.map { |f| f.class.name },
|
185
194
|
context: context,
|
@@ -188,10 +197,6 @@ class HTMLPipeline
|
|
188
197
|
end
|
189
198
|
end
|
190
199
|
|
191
|
-
instrument("sanitization.html_pipeline", payload) do
|
192
|
-
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
|
193
|
-
end
|
194
|
-
|
195
200
|
result = result.merge(@node_filters.collect(&:result).reduce({}, :merge))
|
196
201
|
@node_filters.each(&:reset!)
|
197
202
|
|
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.2
|
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-
|
11
|
+
date: 2024-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selma
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.4'
|
27
27
|
force_ruby_platform: false
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: zeitwerk
|
@@ -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: []
|