html-pipeline 3.0.3 → 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 +4 -4
- data/.github/workflows/automerge.yml +6 -3
- data/.github/workflows/ci.yml +5 -13
- data/.github/workflows/lint.yml +6 -13
- data/.github/workflows/publish.yml +15 -4
- data/.gitignore +3 -1
- data/.rubocop.yml +3 -0
- data/.vscode/settings.json +3 -0
- data/CHANGELOG.md +129 -52
- data/Gemfile +3 -5
- data/README.md +26 -41
- data/UPGRADING.md +0 -2
- data/html-pipeline.gemspec +3 -2
- data/lib/html_pipeline/convert_filter/markdown_filter.rb +4 -4
- data/lib/html_pipeline/convert_filter.rb +1 -1
- data/lib/html_pipeline/filter.rb +1 -1
- data/lib/html_pipeline/node_filter/emoji_filter.rb +3 -3
- 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/node_filter.rb +2 -0
- data/lib/html_pipeline/text_filter/image_filter.rb +2 -2
- data/lib/html_pipeline/text_filter/plain_text_input_filter.rb +2 -2
- data/lib/html_pipeline/text_filter.rb +8 -8
- data/lib/html_pipeline/version.rb +1 -1
- data/lib/html_pipeline.rb +29 -21
- metadata +7 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd951d54c89f057036db67e4d74dbca0de8e5ca07f27a89979d3b7814ec67a38
|
|
4
|
+
data.tar.gz: ef06eacc4b6eab0f53d207d873eb02fb0b61c4f746a621f0ad1c4800b5292bce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
12
|
-
uses:
|
|
13
|
-
secrets:
|
|
12
|
+
bot-check:
|
|
13
|
+
uses: gjtorikian/actions/.github/workflows/automerge.yml@main
|
|
14
|
+
secrets:
|
|
15
|
+
gh_token: ${{ secrets.GITHUB_TOKEN }}
|
|
16
|
+
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -4,19 +4,11 @@ on:
|
|
|
4
4
|
pull_request:
|
|
5
5
|
|
|
6
6
|
permissions:
|
|
7
|
-
contents:
|
|
7
|
+
contents: write
|
|
8
|
+
pull-requests: write
|
|
8
9
|
|
|
9
10
|
jobs:
|
|
10
11
|
test:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 }}
|
data/.github/workflows/lint.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name:
|
|
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:
|
|
9
|
+
contents: write
|
|
10
10
|
|
|
11
11
|
jobs:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name: Release
|
|
1
|
+
name: Tag and Release
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
workflow_dispatch:
|
|
@@ -7,13 +7,24 @@ on:
|
|
|
7
7
|
- main
|
|
8
8
|
paths:
|
|
9
9
|
- "lib/html_pipeline/version.rb"
|
|
10
|
+
pull_request_target:
|
|
11
|
+
types:
|
|
12
|
+
- closed
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
pull-requests: write
|
|
16
|
+
contents: write
|
|
17
|
+
id-token: write
|
|
18
|
+
actions: write
|
|
10
19
|
|
|
11
20
|
jobs:
|
|
12
21
|
ruby:
|
|
13
|
-
uses:
|
|
22
|
+
uses: gjtorikian/actions/.github/workflows/ruby_gem_release.yml@main
|
|
14
23
|
secrets:
|
|
15
|
-
|
|
16
|
-
gh_token: ${{ secrets.PUBLIC_PUSH_TO_PROTECTED_BRANCH }}
|
|
24
|
+
gh_token: ${{ secrets.GITHUB_TOKEN }}
|
|
17
25
|
with:
|
|
18
26
|
gem_name: html-pipeline
|
|
19
27
|
version_filepath: lib/html_pipeline/version.rb
|
|
28
|
+
prepare: ${{ github.event_name == 'push' }}
|
|
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
data/.rubocop.yml
CHANGED
data/.vscode/settings.json
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,51 +1,132 @@
|
|
|
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
|
|
17
|
+
# [v3.2.2] - 09-08-2024
|
|
18
|
+
## What's Changed
|
|
19
|
+
* Add support for @ prefix on MentionFilter base_url by @jeremysmithco in https://github.com/gjtorikian/html-pipeline/pull/411
|
|
20
|
+
* Bugfix: sanitization-only filters should still work by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/414
|
|
21
|
+
|
|
22
|
+
## New Contributors
|
|
23
|
+
* @jeremysmithco made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/411
|
|
24
|
+
|
|
25
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.2.1...v3.2.2
|
|
26
|
+
# [v3.2.1] - 16-07-2024
|
|
27
|
+
## What's Changed
|
|
28
|
+
* 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
|
|
29
|
+
* Remove superfluous sanitization by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/408
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.2.0...v3.2.1
|
|
33
|
+
## [v3.2.0] - 30-04-2024
|
|
34
|
+
## What's Changed
|
|
35
|
+
* Pass context along to every part of the pipeline by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/403
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.1.1...v3.2.0
|
|
39
|
+
## [v3.1.1] - 09-04-2024
|
|
40
|
+
## What's Changed
|
|
41
|
+
* Correct missing method implementation by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/401
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.1.0...v3.1.1
|
|
45
|
+
## [v3.1.0] - 28-02-2024
|
|
46
|
+
## What's Changed
|
|
47
|
+
* UPGRADING: not removed by @dentarg in https://github.com/gjtorikian/html-pipeline/pull/397
|
|
48
|
+
* [BREAKING] now requires instantiation by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/398
|
|
49
|
+
|
|
50
|
+
## New Contributors
|
|
51
|
+
* @dentarg made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/397
|
|
52
|
+
|
|
53
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.3...v3.1.0
|
|
54
|
+
## [v3.0.3] - 02-02-2024
|
|
55
|
+
|
|
56
|
+
## What's Changed
|
|
57
|
+
|
|
58
|
+
- Fix typo in README by @ppworks in https://github.com/gjtorikian/html-pipeline/pull/394
|
|
59
|
+
- Prevent exception by @ppworks in https://github.com/gjtorikian/html-pipeline/pull/395
|
|
60
|
+
- Cut 3.0.3 by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/396
|
|
61
|
+
|
|
62
|
+
## New Contributors
|
|
63
|
+
|
|
64
|
+
- @ppworks made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/394
|
|
65
|
+
|
|
66
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.2...v3.0.3
|
|
67
|
+
|
|
1
68
|
## [v3.0.2] - 08-01-2024
|
|
69
|
+
|
|
2
70
|
## What's Changed
|
|
3
|
-
|
|
4
|
-
|
|
71
|
+
|
|
72
|
+
- README.md: Fix example code by @grekko in https://github.com/gjtorikian/html-pipeline/pull/390
|
|
73
|
+
- Allow pipeline to run without node filters by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/392
|
|
5
74
|
|
|
6
75
|
## New Contributors
|
|
7
|
-
|
|
76
|
+
|
|
77
|
+
- @grekko made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/390
|
|
8
78
|
|
|
9
79
|
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.1...v3.0.2
|
|
80
|
+
|
|
10
81
|
## [v3.0.1] - 28-12-2023
|
|
82
|
+
|
|
11
83
|
## What's Changed
|
|
12
|
-
|
|
84
|
+
|
|
85
|
+
- Handle odd numbers of NodeFilters to be configured by @stevehill1981 in https://github.com/gjtorikian/html-pipeline/pull/389
|
|
13
86
|
|
|
14
87
|
## New Contributors
|
|
15
|
-
|
|
88
|
+
|
|
89
|
+
- @stevehill1981 made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/389
|
|
16
90
|
|
|
17
91
|
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.0...v3.0.1
|
|
92
|
+
|
|
18
93
|
## [v3.0.0] - 24-12-2023
|
|
94
|
+
|
|
19
95
|
## What's Changed
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
96
|
+
|
|
97
|
+
- Switch to GitHub Actions by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/346
|
|
98
|
+
- add truffleruby-head by @gogainda in https://github.com/gjtorikian/html-pipeline/pull/348
|
|
99
|
+
- Add Rubocop by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/349
|
|
100
|
+
- Support multiple dependencies per filter by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/351
|
|
101
|
+
- Split filters up by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/360
|
|
102
|
+
- Migrate from Nokogiri to Selma by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/368
|
|
103
|
+
- You shall pass by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/369
|
|
104
|
+
- Update Selma signatures by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/370
|
|
105
|
+
- Close sanitization-related issues by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/371
|
|
106
|
+
- Drop SyntaxHighlightFilter by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/372
|
|
107
|
+
- V3 Release by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/347
|
|
108
|
+
- Use emoji from commonmarker by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/373
|
|
109
|
+
- req convert_filter if filter present by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/375
|
|
110
|
+
- 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
|
|
111
|
+
- Add the AssetProxyFilter by @digitalmoksha in https://github.com/gjtorikian/html-pipeline/pull/379
|
|
112
|
+
- Update rouge requirement from ~> 3.1 to ~> 4.1 by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/381
|
|
113
|
+
- Update gemoji requirement from ~> 3.0 to ~> 4.1 by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/382
|
|
114
|
+
- Have Zeitwerk not automatically load filters by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/383
|
|
115
|
+
- Bump the github-actions group with 1 update by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/384
|
|
116
|
+
- :gem: 3.0.0 by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/386
|
|
40
117
|
|
|
41
118
|
## New Contributors
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
119
|
+
|
|
120
|
+
- @gogainda made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/348
|
|
121
|
+
- @dependabot made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/377
|
|
122
|
+
- @digitalmoksha made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/379
|
|
45
123
|
|
|
46
124
|
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v2.14.3...v3.0.0
|
|
125
|
+
|
|
47
126
|
## [v3.0.0.pre6] - 16-08-2023
|
|
127
|
+
|
|
48
128
|
null
|
|
129
|
+
|
|
49
130
|
# Changelog
|
|
50
131
|
|
|
51
132
|
## [v3.0.0.pre5](https://github.com/gjtorikian/html-pipeline/tree/v3.0.0.pre5) (2023-06-05)
|
|
@@ -76,7 +157,7 @@ null
|
|
|
76
157
|
|
|
77
158
|
**Merged pull requests:**
|
|
78
159
|
|
|
79
|
-
- req
|
|
160
|
+
- req convert_filter if `text/node`filter present [\#375](https://github.com/gjtorikian/html-pipeline/pull/375) ([gjtorikian](https://github.com/gjtorikian))
|
|
80
161
|
|
|
81
162
|
## [v3.0.0.pre2](https://github.com/gjtorikian/html-pipeline/tree/v3.0.0.pre2) (2023-01-26)
|
|
82
163
|
|
|
@@ -137,7 +218,7 @@ null
|
|
|
137
218
|
|
|
138
219
|
**Merged pull requests:**
|
|
139
220
|
|
|
140
|
-
- Replace EscapeUtils.
|
|
221
|
+
- Replace EscapeUtils.escape_html with CGI.escape_html [\#365](https://github.com/gjtorikian/html-pipeline/pull/365) ([ramhoj](https://github.com/ramhoj))
|
|
141
222
|
|
|
142
223
|
## [v2.14.2](https://github.com/gjtorikian/html-pipeline/tree/v2.14.2) (2022-06-12)
|
|
143
224
|
|
|
@@ -309,7 +390,7 @@ null
|
|
|
309
390
|
|
|
310
391
|
**Closed issues:**
|
|
311
392
|
|
|
312
|
-
- New feature request for hashtags \# filter
|
|
393
|
+
- New feature request for hashtags \# filter [\#301](https://github.com/gjtorikian/html-pipeline/issues/301)
|
|
313
394
|
- Whitelist srcset for responsive images [\#233](https://github.com/gjtorikian/html-pipeline/issues/233)
|
|
314
395
|
|
|
315
396
|
**Merged pull requests:**
|
|
@@ -412,7 +493,7 @@ null
|
|
|
412
493
|
|
|
413
494
|
- Set instrumentation name [\#275](https://github.com/gjtorikian/html-pipeline/pull/275) ([gjtorikian](https://github.com/gjtorikian))
|
|
414
495
|
- Switch to CommonMark [\#274](https://github.com/gjtorikian/html-pipeline/pull/274) ([kivikakk](https://github.com/kivikakk))
|
|
415
|
-
-
|
|
496
|
+
- add korgi to 3rd party extensions \[ci skip\] [\#271](https://github.com/gjtorikian/html-pipeline/pull/271) ([jodeci](https://github.com/jodeci))
|
|
416
497
|
|
|
417
498
|
## [v2.5.0](https://github.com/gjtorikian/html-pipeline/tree/v2.5.0) (2017-01-13)
|
|
418
499
|
|
|
@@ -421,7 +502,7 @@ null
|
|
|
421
502
|
**Closed issues:**
|
|
422
503
|
|
|
423
504
|
- Add `<wbr>` to whitelist [\#265](https://github.com/gjtorikian/html-pipeline/issues/265)
|
|
424
|
-
- Missing context keys for HTML::Pipeline::EmojiFilter: :
|
|
505
|
+
- Missing context keys for HTML::Pipeline::EmojiFilter: :asset_root [\#262](https://github.com/gjtorikian/html-pipeline/issues/262)
|
|
425
506
|
- Emoji \<img\> tags does not pass W3C validationg [\#234](https://github.com/gjtorikian/html-pipeline/issues/234)
|
|
426
507
|
- Incompatible character encodings: ASCII-8BIT and UTF-8 in EmailReplyFilter [\#229](https://github.com/gjtorikian/html-pipeline/issues/229)
|
|
427
508
|
|
|
@@ -504,8 +585,8 @@ null
|
|
|
504
585
|
**Merged pull requests:**
|
|
505
586
|
|
|
506
587
|
- Release 2.2.2 [\#231](https://github.com/gjtorikian/html-pipeline/pull/231) ([jch](https://github.com/jch))
|
|
507
|
-
- Fix for calling
|
|
508
|
-
- Add html-pipeline-
|
|
588
|
+
- Fix for calling mention_link_filter with only one argument [\#230](https://github.com/gjtorikian/html-pipeline/pull/230) ([benbalter](https://github.com/benbalter))
|
|
589
|
+
- Add html-pipeline-linkify_github to 3rd Party Extensions \[ci skip\] [\#228](https://github.com/gjtorikian/html-pipeline/pull/228) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
|
509
590
|
|
|
510
591
|
## [v2.2.1](https://github.com/gjtorikian/html-pipeline/tree/v2.2.1) (2015-10-01)
|
|
511
592
|
|
|
@@ -561,7 +642,7 @@ null
|
|
|
561
642
|
- Question - Can this work with Rouge? [\#166](https://github.com/gjtorikian/html-pipeline/issues/166)
|
|
562
643
|
- Question about github markdown filter \(low priority!\) [\#165](https://github.com/gjtorikian/html-pipeline/issues/165)
|
|
563
644
|
- Do not mention or emojify in a codeblock [\#163](https://github.com/gjtorikian/html-pipeline/issues/163)
|
|
564
|
-
- MentionFilter
|
|
645
|
+
- MentionFilter base_url config question [\#161](https://github.com/gjtorikian/html-pipeline/issues/161)
|
|
565
646
|
- Feature Request: Add "details" tag to whitelist [\#138](https://github.com/gjtorikian/html-pipeline/issues/138)
|
|
566
647
|
|
|
567
648
|
**Merged pull requests:**
|
|
@@ -573,10 +654,10 @@ null
|
|
|
573
654
|
- \[ci skip\] Fix CHANGELOG.md rendering. [\#177](https://github.com/gjtorikian/html-pipeline/pull/177) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
|
574
655
|
- Restrict nokogiri to specific versions [\#176](https://github.com/gjtorikian/html-pipeline/pull/176) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
|
575
656
|
- Use svg build badge. \[ci skip\] [\#175](https://github.com/gjtorikian/html-pipeline/pull/175) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
|
576
|
-
- Add 3rd party gem: html-pipeline-
|
|
577
|
-
- MentionFilter\#
|
|
657
|
+
- Add 3rd party gem: html-pipeline-rouge_filter. [\#174](https://github.com/gjtorikian/html-pipeline/pull/174) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
|
658
|
+
- MentionFilter\#link_to_mentioned_user: Replace String introspection with Regexp match [\#172](https://github.com/gjtorikian/html-pipeline/pull/172) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
|
578
659
|
- Whitelist summary and details element. [\#171](https://github.com/gjtorikian/html-pipeline/pull/171) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
|
579
|
-
- Implement new context option:
|
|
660
|
+
- Implement new context option: ignored_ancestor_tags to accept more ignored tags. [\#170](https://github.com/gjtorikian/html-pipeline/pull/170) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
|
580
661
|
- Support ~login for MentionFilter. [\#167](https://github.com/gjtorikian/html-pipeline/pull/167) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
|
581
662
|
- Add GitHub flavor Markdown Task List extension [\#162](https://github.com/gjtorikian/html-pipeline/pull/162) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
|
582
663
|
- Drop support for gemoji ~\> 1.0 [\#159](https://github.com/gjtorikian/html-pipeline/pull/159) ([jch](https://github.com/jch))
|
|
@@ -593,14 +674,14 @@ null
|
|
|
593
674
|
|
|
594
675
|
**Closed issues:**
|
|
595
676
|
|
|
596
|
-
- @
|
|
677
|
+
- @mention_filter should not replace mentions in style blocks. [\#143](https://github.com/gjtorikian/html-pipeline/issues/143)
|
|
597
678
|
- EmojiFilter doesn't work on strings that don't contain HTML [\#133](https://github.com/gjtorikian/html-pipeline/issues/133)
|
|
598
679
|
|
|
599
680
|
**Merged pull requests:**
|
|
600
681
|
|
|
601
682
|
- Search for text nodes on DocumentFragments without root tags [\#146](https://github.com/gjtorikian/html-pipeline/pull/146) ([Razer6](https://github.com/Razer6))
|
|
602
683
|
- Don't filter @mentions in \<style\> tags [\#145](https://github.com/gjtorikian/html-pipeline/pull/145) ([jch](https://github.com/jch))
|
|
603
|
-
- Prefer
|
|
684
|
+
- Prefer http_url in HttpsFilter [\#142](https://github.com/gjtorikian/html-pipeline/pull/142) ([bkeepers](https://github.com/bkeepers))
|
|
604
685
|
- Don't check twice if there is a ':' in content \(EmojiFilter\) [\#141](https://github.com/gjtorikian/html-pipeline/pull/141) ([Razer6](https://github.com/Razer6))
|
|
605
686
|
|
|
606
687
|
## [v1.10.0](https://github.com/gjtorikian/html-pipeline/tree/v1.10.0) (2014-09-05)
|
|
@@ -632,7 +713,7 @@ null
|
|
|
632
713
|
**Merged pull requests:**
|
|
633
714
|
|
|
634
715
|
- Generalize https filter take 2 [\#131](https://github.com/gjtorikian/html-pipeline/pull/131) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
|
635
|
-
- Remove
|
|
716
|
+
- Remove RUBY_VERSION conditionals from gemspec [\#130](https://github.com/gjtorikian/html-pipeline/pull/130) ([mislav](https://github.com/mislav))
|
|
636
717
|
- Add compatibility with gemoji v2 [\#129](https://github.com/gjtorikian/html-pipeline/pull/129) ([mislav](https://github.com/mislav))
|
|
637
718
|
|
|
638
719
|
## [v1.8.0](https://github.com/gjtorikian/html-pipeline/tree/v1.8.0) (2014-04-04)
|
|
@@ -659,7 +740,7 @@ null
|
|
|
659
740
|
**Closed issues:**
|
|
660
741
|
|
|
661
742
|
- cut a 1.6.0 release [\#116](https://github.com/gjtorikian/html-pipeline/issues/116)
|
|
662
|
-
- AutolinkFilter
|
|
743
|
+
- AutolinkFilter link_attr doesn't seem to work [\#114](https://github.com/gjtorikian/html-pipeline/issues/114)
|
|
663
744
|
- Spaces inserted into code [\#109](https://github.com/gjtorikian/html-pipeline/issues/109)
|
|
664
745
|
|
|
665
746
|
**Merged pull requests:**
|
|
@@ -747,9 +828,9 @@ null
|
|
|
747
828
|
|
|
748
829
|
**Merged pull requests:**
|
|
749
830
|
|
|
750
|
-
- Add
|
|
831
|
+
- Add link_attr option to Autolink filter [\#89](https://github.com/gjtorikian/html-pipeline/pull/89) ([excid3](https://github.com/excid3))
|
|
751
832
|
- Update readme with link to asciidoc filter [\#87](https://github.com/gjtorikian/html-pipeline/pull/87) ([jch](https://github.com/jch))
|
|
752
|
-
- use
|
|
833
|
+
- use xml_mini extracted from activesupport [\#85](https://github.com/gjtorikian/html-pipeline/pull/85) ([mojavelinux](https://github.com/mojavelinux))
|
|
753
834
|
- Filters Manage Dependencies [\#80](https://github.com/gjtorikian/html-pipeline/pull/80) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
|
754
835
|
|
|
755
836
|
## [v0.3.1](https://github.com/gjtorikian/html-pipeline/tree/v0.3.1) (2013-09-16)
|
|
@@ -817,7 +898,7 @@ null
|
|
|
817
898
|
- Improve to describe gem 'github-linguist' [\#69](https://github.com/gjtorikian/html-pipeline/pull/69) ([tricknotes](https://github.com/tricknotes))
|
|
818
899
|
- Bump version to 0.1.0. Follow semver. [\#68](https://github.com/gjtorikian/html-pipeline/pull/68) ([jch](https://github.com/jch))
|
|
819
900
|
- Scope gem versions for Travis CI [\#67](https://github.com/gjtorikian/html-pipeline/pull/67) ([jch](https://github.com/jch))
|
|
820
|
-
- Allow passing
|
|
901
|
+
- Allow passing skip_tags in autolink filter context [\#65](https://github.com/gjtorikian/html-pipeline/pull/65) ([pengwynn](https://github.com/pengwynn))
|
|
821
902
|
- Support non-English characters in anchor names [\#64](https://github.com/gjtorikian/html-pipeline/pull/64) ([jakedouglas](https://github.com/jakedouglas))
|
|
822
903
|
- Fix the `AutolinkFilter` constant name. [\#57](https://github.com/gjtorikian/html-pipeline/pull/57) ([envygeeks](https://github.com/envygeeks))
|
|
823
904
|
- resolves \#54 allow table section elements \(thead, tfoot, tbody\) [\#55](https://github.com/gjtorikian/html-pipeline/pull/55) ([mojavelinux](https://github.com/mojavelinux))
|
|
@@ -870,7 +951,7 @@ null
|
|
|
870
951
|
**Merged pull requests:**
|
|
871
952
|
|
|
872
953
|
- Add an html-pipeline executable to the gem [\#44](https://github.com/gjtorikian/html-pipeline/pull/44) ([indirect](https://github.com/indirect))
|
|
873
|
-
- add result\[:
|
|
954
|
+
- add result\[:mentioned_usernames\] for MentionFilter [\#42](https://github.com/gjtorikian/html-pipeline/pull/42) ([fahchen](https://github.com/fahchen))
|
|
874
955
|
|
|
875
956
|
## [v0.0.8.1](https://github.com/gjtorikian/html-pipeline/tree/v0.0.8.1) (2013-03-03)
|
|
876
957
|
|
|
@@ -886,7 +967,7 @@ null
|
|
|
886
967
|
|
|
887
968
|
**Merged pull requests:**
|
|
888
969
|
|
|
889
|
-
- Bump
|
|
970
|
+
- Bump escape_utils [\#41](https://github.com/gjtorikian/html-pipeline/pull/41) ([brianmario](https://github.com/brianmario))
|
|
890
971
|
- Don't monkeypatch Nokogiri in 1.9 [\#40](https://github.com/gjtorikian/html-pipeline/pull/40) ([defunkt](https://github.com/defunkt))
|
|
891
972
|
|
|
892
973
|
## [v0.0.8](https://github.com/gjtorikian/html-pipeline/tree/v0.0.8) (2013-02-07)
|
|
@@ -978,7 +1059,3 @@ null
|
|
|
978
1059
|
- Ensure required context values are present [\#9](https://github.com/gjtorikian/html-pipeline/pull/9) ([juliamae](https://github.com/juliamae))
|
|
979
1060
|
- emoji filter requires the emoji gem [\#8](https://github.com/gjtorikian/html-pipeline/pull/8) ([atmos](https://github.com/atmos))
|
|
980
1061
|
- De-Github and opensource [\#6](https://github.com/gjtorikian/html-pipeline/pull/6) ([jch](https://github.com/jch))
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
|
@@ -10,8 +10,6 @@ gem "awesome_print"
|
|
|
10
10
|
gem "rubocop"
|
|
11
11
|
gem "rubocop-standard"
|
|
12
12
|
|
|
13
|
-
gem "github_changelog_generator", "~> 1.16"
|
|
14
|
-
|
|
15
13
|
gem "sorbet-runtime"
|
|
16
14
|
|
|
17
15
|
group :development, :test do
|
|
@@ -27,12 +25,12 @@ group :development do
|
|
|
27
25
|
end
|
|
28
26
|
|
|
29
27
|
group :test do
|
|
30
|
-
gem "commonmarker", "~>
|
|
28
|
+
gem "commonmarker", "~> 2.6", require: false
|
|
31
29
|
gem "gemoji", "~> 4.1", require: false
|
|
32
30
|
gem "gemojione", "~> 4.3", require: false
|
|
33
31
|
|
|
34
|
-
gem "minitest"
|
|
35
|
-
|
|
32
|
+
gem "minitest", "~> 6.0"
|
|
33
|
+
gem "minitest-mock", "~> 5.27"
|
|
36
34
|
gem "minitest-bisect", "~> 1.6"
|
|
37
35
|
|
|
38
36
|
gem "nokogiri", "~> 1.13"
|
data/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# HTML-Pipeline
|
|
2
2
|
|
|
3
|
-
> **Note**
|
|
4
|
-
> This README refers to the behavior in the new 3.0.0.pre gem.
|
|
5
|
-
|
|
6
3
|
HTML processing filters and utilities. This module is a small
|
|
7
4
|
framework for defining CSS-based content filters and applying them to user
|
|
8
5
|
provided content.
|
|
@@ -60,9 +57,15 @@ results tothe next filter. A pipeline has several kinds of filters available to
|
|
|
60
57
|
|
|
61
58
|
You can assemble each sequence into a single pipeline, or choose to call each filter individually.
|
|
62
59
|
|
|
63
|
-
As an example, suppose we want to transform Commonmark source text into Markdown HTML
|
|
60
|
+
As an example, suppose we want to transform Commonmark source text into Markdown HTML:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Hey there, @gjtorikian
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
With the content, we also want to:
|
|
64
67
|
|
|
65
|
-
- change every instance of
|
|
68
|
+
- change every instance of `Hey` to `Hello`
|
|
66
69
|
- strip undesired HTML
|
|
67
70
|
- linkify @mention
|
|
68
71
|
|
|
@@ -73,7 +76,7 @@ require 'html_pipeline'
|
|
|
73
76
|
|
|
74
77
|
class HelloJohnnyFilter < HTMLPipelineFilter
|
|
75
78
|
def call
|
|
76
|
-
text.gsub("
|
|
79
|
+
text.gsub("Hey", "Hello")
|
|
77
80
|
end
|
|
78
81
|
end
|
|
79
82
|
|
|
@@ -104,11 +107,21 @@ used to pass around arguments and metadata between filters in a pipeline. For
|
|
|
104
107
|
example, if you want to disable footnotes in the `MarkdownFilter`, you can pass an option in the context hash:
|
|
105
108
|
|
|
106
109
|
```ruby
|
|
107
|
-
context =
|
|
110
|
+
context = { markdown: { extensions: { footnotes: false } } }
|
|
108
111
|
filter = HTMLPipeline::ConvertFilter::MarkdownFilter.new(context: context)
|
|
109
112
|
filter.call("Hi **world**!")
|
|
110
113
|
```
|
|
111
114
|
|
|
115
|
+
Alternatively, you can construct a pipeline, and pass in a context during the call:
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
pipeline = HTMLPipeline.new(
|
|
119
|
+
convert_filter: HTMLPipeline::ConvertFilter::MarkdownFilter.new,
|
|
120
|
+
node_filters: [HTMLPipeline::NodeFilter::MentionFilter.new]
|
|
121
|
+
)
|
|
122
|
+
pipeline.call(user_supplied_text, context: { markdown: { extensions: { footnotes: false } } })
|
|
123
|
+
```
|
|
124
|
+
|
|
112
125
|
Please refer to the documentation for each filter to understand what configuration options are available.
|
|
113
126
|
|
|
114
127
|
### More Examples
|
|
@@ -158,9 +171,9 @@ The `ConvertFilter` takes text and turns it into HTML. `@text`, `@config`, and `
|
|
|
158
171
|
|
|
159
172
|
### Sanitization
|
|
160
173
|
|
|
161
|
-
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.
|
|
162
175
|
|
|
163
|
-
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.
|
|
164
177
|
|
|
165
178
|
A default sanitization config is provided by this library (`HTMLPipeline::SanitizationFilter::DEFAULT_CONFIG`). A sample custom sanitization allowlist might look like this:
|
|
166
179
|
|
|
@@ -171,7 +184,7 @@ ALLOWLIST = {
|
|
|
171
184
|
|
|
172
185
|
pipeline = HTMLPipeline.new \
|
|
173
186
|
text_filters: [
|
|
174
|
-
HTMLPipeline::
|
|
187
|
+
HTMLPipeline::TextFilter::ImageFilter.new,
|
|
175
188
|
],
|
|
176
189
|
convert_filter: HTMLPipeline::ConvertFilter::MarkdownFilter.new,
|
|
177
190
|
sanitization_config: ALLOWLIST
|
|
@@ -199,7 +212,7 @@ the config:
|
|
|
199
212
|
```ruby
|
|
200
213
|
pipeline = HTMLPipeline.new \
|
|
201
214
|
text_filters: [
|
|
202
|
-
HTMLPipeline::
|
|
215
|
+
HTMLPipeline::TextFilter::ImageFilter.new,
|
|
203
216
|
],
|
|
204
217
|
convert_filter: HTMLPipeline::ConvertFilter::MarkdownFilter.new,
|
|
205
218
|
sanitization_config: nil
|
|
@@ -211,7 +224,7 @@ For more examples of customizing the sanitization process to include the tags yo
|
|
|
211
224
|
|
|
212
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.
|
|
213
226
|
|
|
214
|
-
`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.
|
|
215
228
|
|
|
216
229
|
Here's an example `NodeFilter` that adds a base url to images that are root relative:
|
|
217
230
|
|
|
@@ -330,34 +343,6 @@ service.subscribe "call_text_filters.html_pipeline" do |event, start, ending, tr
|
|
|
330
343
|
end
|
|
331
344
|
```
|
|
332
345
|
|
|
333
|
-
## Third Party Extensions
|
|
334
|
-
|
|
335
|
-
If you have an idea for a filter, propose it as
|
|
336
|
-
[an issue](https://github.com/gjtorikian/html-pipeline/issues) first. This allows us to discuss
|
|
337
|
-
whether the filter is a common enough use case to belong in this gem, or should be
|
|
338
|
-
built as an external gem.
|
|
339
|
-
|
|
340
|
-
Here are some extensions people have built:
|
|
341
|
-
|
|
342
|
-
- [html-pipeline-asciidoc_filter](https://github.com/asciidoctor/html-pipeline-asciidoc_filter)
|
|
343
|
-
- [jekyll-html-pipeline](https://github.com/gjtorikian/jekyll-html-pipeline)
|
|
344
|
-
- [nanoc-html-pipeline](https://github.com/burnto/nanoc-html-pipeline)
|
|
345
|
-
- [html-pipeline-bitly](https://github.com/dewski/html-pipeline-bitly)
|
|
346
|
-
- [html-pipeline-cite](https://github.com/lifted-studios/html-pipeline-cite)
|
|
347
|
-
- [tilt-html-pipeline](https://github.com/bradgessler/tilt-html-pipeline)
|
|
348
|
-
- [html-pipeline-wiki-link'](https://github.com/lifted-studios/html-pipeline-wiki-link) - WikiMedia-style wiki links
|
|
349
|
-
- [task_list](https://github.com/github/task_list) - GitHub flavor Markdown Task List
|
|
350
|
-
- [html-pipeline-nico_link](https://github.com/rutan/html-pipeline-nico_link) - An HTMLPipeline filter for [niconico](http://www.nicovideo.jp) description links
|
|
351
|
-
- [html-pipeline-gitlab](https://gitlab.com/gitlab-org/html-pipeline-gitlab) - This gem implements various filters for html-pipeline used by GitLab
|
|
352
|
-
- [html-pipeline-youtube](https://github.com/st0012/html-pipeline-youtube) - An HTMLPipeline filter for YouTube links
|
|
353
|
-
- [html-pipeline-flickr](https://github.com/st0012/html-pipeline-flickr) - An HTMLPipeline filter for Flickr links
|
|
354
|
-
- [html-pipeline-vimeo](https://github.com/dlackty/html-pipeline-vimeo) - An HTMLPipeline filter for Vimeo links
|
|
355
|
-
- [html-pipeline-hashtag](https://github.com/mr-dxdy/html-pipeline-hashtag) - An HTMLPipeline filter for hashtags
|
|
356
|
-
- [html-pipeline-linkify_github](https://github.com/jollygoodcode/html-pipeline-linkify_github) - An HTMLPipeline filter to autolink GitHub urls
|
|
357
|
-
- [html-pipeline-redcarpet_filter](https://github.com/bmikol/html-pipeline-redcarpet_filter) - Render Markdown source text into Markdown HTML using Redcarpet
|
|
358
|
-
- [html-pipeline-typogruby_filter](https://github.com/bmikol/html-pipeline-typogruby_filter) - Add Typogruby text filters to your HTMLPipeline
|
|
359
|
-
- [korgi](https://github.com/jodeci/korgi) - HTMLPipeline filters for links to Rails resources
|
|
360
|
-
|
|
361
346
|
## FAQ
|
|
362
347
|
|
|
363
348
|
### 1. Why doesn't my pipeline work when there's no root element in the document?
|
|
@@ -375,7 +360,7 @@ you to add additional elements. You can either modify the constant's value, or
|
|
|
375
360
|
re-define your own config and pass that in, such as:
|
|
376
361
|
|
|
377
362
|
```ruby
|
|
378
|
-
config = HTMLPipeline::SanitizationFilter::DEFAULT_CONFIG.
|
|
363
|
+
config = HTMLPipeline::SanitizationFilter::DEFAULT_CONFIG.deep_dup
|
|
379
364
|
config[:elements] << "iframe" # sure, whatever you want
|
|
380
365
|
```
|
|
381
366
|
|
data/UPGRADING.md
CHANGED
|
@@ -14,10 +14,8 @@ The following filters were removed:
|
|
|
14
14
|
|
|
15
15
|
- `AutolinkFilter`: this is handled by [Commonmarker](https://www.github.com/gjtorikian/commonmarker) and can be disabled/enabled through the `MarkdownFilter`'s `context` hash
|
|
16
16
|
- `SanitizationFilter`: this is handled by [Selma](https://www.github.com/gjtorikian/selma); configuration can be done through the `sanitization_config` hash
|
|
17
|
-
|
|
18
17
|
- `EmailReplyFilter`
|
|
19
18
|
- `CamoFilter`
|
|
20
|
-
- `TextFilter`
|
|
21
19
|
|
|
22
20
|
### Changed API
|
|
23
21
|
|
data/html-pipeline.gemspec
CHANGED
|
@@ -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 = "
|
|
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
|
|
|
@@ -25,7 +26,7 @@ Gem::Specification.new do |gem|
|
|
|
25
26
|
"rubygems_mfa_required" => "true",
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
gem.add_dependency("selma", "~> 0.
|
|
29
|
+
gem.add_dependency("selma", "~> 0.4")
|
|
29
30
|
gem.add_dependency("zeitwerk", "~> 2.5")
|
|
30
31
|
|
|
31
32
|
gem.post_install_message = <<~MSG
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
HTMLPipeline.require_dependency("commonmarker", "MarkdownFilter")
|
|
4
4
|
|
|
5
5
|
class HTMLPipeline
|
|
6
|
-
class ConvertFilter
|
|
6
|
+
class ConvertFilter < Filter
|
|
7
7
|
# HTML Filter that converts Markdown text into HTML.
|
|
8
8
|
#
|
|
9
9
|
# Context options:
|
|
@@ -12,12 +12,12 @@ 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.
|
|
19
|
-
def call(text)
|
|
20
|
-
options =
|
|
19
|
+
def call(text, context: @context)
|
|
20
|
+
options = context.fetch(:markdown, {})
|
|
21
21
|
plugins = options.fetch(:plugins, {})
|
|
22
22
|
Commonmarker.to_html(text, options: options, plugins: plugins).rstrip!
|
|
23
23
|
end
|
data/lib/html_pipeline/filter.rb
CHANGED
|
@@ -27,7 +27,7 @@ class HTMLPipeline
|
|
|
27
27
|
# Public: Returns a simple Hash used to pass extra information into filters
|
|
28
28
|
# and also to allow filters to make extracted information available to the
|
|
29
29
|
# caller.
|
|
30
|
-
|
|
30
|
+
attr_accessor :context
|
|
31
31
|
|
|
32
32
|
# Public: Returns a Hash used to allow filters to pass back information
|
|
33
33
|
# to callers of the various Pipelines. This can be used for
|
|
@@ -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
|
-
|
|
76
|
+
next if value.nil?
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
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}>"
|
|
@@ -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}" \
|
|
@@ -9,8 +9,8 @@ class HTMLPipeline
|
|
|
9
9
|
# <img src="http://example.com/test.jpg" alt=""/>.
|
|
10
10
|
|
|
11
11
|
class ImageFilter < TextFilter
|
|
12
|
-
def call
|
|
13
|
-
|
|
12
|
+
def call(text, context: {}, result: {})
|
|
13
|
+
text.gsub(%r{(https|http)?://.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?}i) do |match|
|
|
14
14
|
%(<img src="#{match}" alt=""/>)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -5,8 +5,8 @@ class HTMLPipeline
|
|
|
5
5
|
# Simple filter for plain text input. HTML escapes the text input and wraps it
|
|
6
6
|
# in a div.
|
|
7
7
|
class PlainTextInputFilter < TextFilter
|
|
8
|
-
def call
|
|
9
|
-
"<div>#{CGI.escapeHTML(
|
|
8
|
+
def call(text, context: {}, result: {})
|
|
9
|
+
"<div>#{CGI.escapeHTML(text)}</div>"
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
end
|
|
@@ -4,17 +4,17 @@ class HTMLPipeline
|
|
|
4
4
|
class TextFilter < Filter
|
|
5
5
|
attr_reader :text
|
|
6
6
|
|
|
7
|
-
def initialize(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Ensure that this is always a string
|
|
11
|
-
@text = text.respond_to?(:to_str) ? text.to_str : text.to_s
|
|
12
|
-
super(context: context, result: result)
|
|
7
|
+
def initialize(context: {}, result: {})
|
|
8
|
+
super
|
|
13
9
|
end
|
|
14
10
|
|
|
15
11
|
class << self
|
|
16
|
-
def call(
|
|
17
|
-
|
|
12
|
+
def call(text, context: {}, result: {})
|
|
13
|
+
raise TypeError, "text must be a String" unless text.is_a?(String)
|
|
14
|
+
|
|
15
|
+
# Ensure that this is always a string
|
|
16
|
+
text = text.respond_to?(:to_str) ? text.to_str : text.to_s
|
|
17
|
+
new(context: context, result: result).call(text)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
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? &&
|
|
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)
|
|
@@ -153,14 +153,14 @@ class HTMLPipeline
|
|
|
153
153
|
|
|
154
154
|
if @text_filters.any?
|
|
155
155
|
payload = default_payload({
|
|
156
|
-
text_filters: @text_filters.map
|
|
157
|
-
context
|
|
158
|
-
result
|
|
156
|
+
text_filters: @text_filters.map { |f| f.class.name },
|
|
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: context, result:
|
|
163
|
+
perform_filter(filter, doc, context: (filter.context || {}).merge(context), result:)
|
|
164
164
|
end
|
|
165
165
|
end
|
|
166
166
|
end
|
|
@@ -171,24 +171,32 @@ class HTMLPipeline
|
|
|
171
171
|
text
|
|
172
172
|
else
|
|
173
173
|
instrument("call_convert_filter.html_pipeline", payload) do
|
|
174
|
-
html = @convert_filter.call(text)
|
|
174
|
+
html = @convert_filter.call(text, context: (@convert_filter.context || {}).merge(context))
|
|
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? && !@sanitization_config.nil?
|
|
185
|
+
instrument("sanitization.html_pipeline", payload) do
|
|
186
|
+
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, options: rewriter_options).rewrite(html)
|
|
187
|
+
end
|
|
188
|
+
elsif @node_filters.any?
|
|
179
189
|
instrument("call_node_filters.html_pipeline", payload) do
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
@node_filters.each { |filter| filter.context = (filter.context || {}).merge(context) }
|
|
191
|
+
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters, options: rewriter_options).rewrite(html)
|
|
182
192
|
payload = default_payload({
|
|
183
193
|
node_filters: @node_filters.map { |f| f.class.name },
|
|
184
|
-
context
|
|
185
|
-
result
|
|
194
|
+
context:,
|
|
195
|
+
result:,
|
|
186
196
|
})
|
|
187
197
|
end
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
instrument("html_pipeline.sanitization", payload) do
|
|
191
|
-
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
|
|
198
|
+
else
|
|
199
|
+
result[:output] = html
|
|
192
200
|
end
|
|
193
201
|
|
|
194
202
|
result = result.merge(@node_filters.collect(&:result).reduce({}, :merge))
|
|
@@ -204,19 +212,19 @@ class HTMLPipeline
|
|
|
204
212
|
# Returns the result of the filter.
|
|
205
213
|
def perform_filter(filter, doc, context: {}, result: {})
|
|
206
214
|
payload = default_payload({
|
|
207
|
-
filter: filter.name,
|
|
208
|
-
context
|
|
209
|
-
result
|
|
215
|
+
filter: filter.class.name,
|
|
216
|
+
context:,
|
|
217
|
+
result:,
|
|
210
218
|
})
|
|
211
219
|
|
|
212
220
|
instrument("call_filter.html_pipeline", payload) do
|
|
213
|
-
filter.call(doc, context
|
|
221
|
+
filter.call(doc, context:, result:)
|
|
214
222
|
end
|
|
215
223
|
end
|
|
216
224
|
|
|
217
225
|
# Like call but guarantee the value returned is a string of HTML markup.
|
|
218
226
|
def to_html(input, context: {}, result: {})
|
|
219
|
-
result = call(input, context
|
|
227
|
+
result = call(input, context:, result:)
|
|
220
228
|
output = result[:output]
|
|
221
229
|
if output.respond_to?(:to_html)
|
|
222
230
|
output.to_html
|
|
@@ -266,7 +274,7 @@ class HTMLPipeline
|
|
|
266
274
|
invalid_filters = filters.reject { |f| correctly_ancestored?(f, klass) }
|
|
267
275
|
|
|
268
276
|
unless invalid_filters.empty?
|
|
269
|
-
verb = invalid_filters.
|
|
277
|
+
verb = invalid_filters.one? ? "does" : "do"
|
|
270
278
|
raise InvalidFilterError, "All filters must inherit from `#{klass}`; #{invalid_filters.join(", ")} #{verb} not"
|
|
271
279
|
end
|
|
272
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.
|
|
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:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: selma
|
|
@@ -16,15 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.
|
|
18
|
+
version: '0.4'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0.
|
|
27
|
-
force_ruby_platform: false
|
|
25
|
+
version: '0.4'
|
|
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.
|
|
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:
|
|
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: []
|