html-pipeline 3.0.3 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +91 -52
- data/Gemfile +0 -2
- data/README.md +23 -10
- data/UPGRADING.md +0 -2
- data/lib/html_pipeline/convert_filter/markdown_filter.rb +3 -3
- data/lib/html_pipeline/filter.rb +1 -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 +7 -7
- data/lib/html_pipeline/version.rb +1 -1
- data/lib/html_pipeline.rb +6 -5
- 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: e8252d2015129b2ee071b6c094a773afecd796a75d0ab3d24aaa18b997be8f1f
|
4
|
+
data.tar.gz: 3ace3231f84d7f5a82b4921d2ee600a4ae069440adb15e4ee527eda290b00637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be71b5590d6599b2a2c8d6dfdb98b27e61701a07bbc1a0aa14982459bfd65d8aec69228318834c939a6357dff03c982e739d2a39a83853e12016049e2ddd13e2
|
7
|
+
data.tar.gz: b90b25b60016557c21eef5ee431c21890f5580589fabfafbe36e530ff3dc63cd3e3a83cf835c757cf8b7398e58c2f290096cf7ef8173177a27457b15871fe5e9
|
data/CHANGELOG.md
CHANGED
@@ -1,51 +1,94 @@
|
|
1
|
+
## [v3.1.1] - 09-04-2024
|
2
|
+
## What's Changed
|
3
|
+
* Correct missing method implementation by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/401
|
4
|
+
|
5
|
+
|
6
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.1.0...v3.1.1
|
7
|
+
## [v3.1.0] - 28-02-2024
|
8
|
+
## What's Changed
|
9
|
+
* UPGRADING: not removed by @dentarg in https://github.com/gjtorikian/html-pipeline/pull/397
|
10
|
+
* [BREAKING] now requires instantiation by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/398
|
11
|
+
|
12
|
+
## New Contributors
|
13
|
+
* @dentarg made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/397
|
14
|
+
|
15
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.3...v3.1.0
|
16
|
+
## [v3.0.3] - 02-02-2024
|
17
|
+
|
18
|
+
## What's Changed
|
19
|
+
|
20
|
+
- Fix typo in README by @ppworks in https://github.com/gjtorikian/html-pipeline/pull/394
|
21
|
+
- Prevent exception by @ppworks in https://github.com/gjtorikian/html-pipeline/pull/395
|
22
|
+
- Cut 3.0.3 by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/396
|
23
|
+
|
24
|
+
## New Contributors
|
25
|
+
|
26
|
+
- @ppworks made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/394
|
27
|
+
|
28
|
+
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.2...v3.0.3
|
29
|
+
|
1
30
|
## [v3.0.2] - 08-01-2024
|
31
|
+
|
2
32
|
## What's Changed
|
3
|
-
|
4
|
-
|
33
|
+
|
34
|
+
- README.md: Fix example code by @grekko in https://github.com/gjtorikian/html-pipeline/pull/390
|
35
|
+
- Allow pipeline to run without node filters by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/392
|
5
36
|
|
6
37
|
## New Contributors
|
7
|
-
|
38
|
+
|
39
|
+
- @grekko made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/390
|
8
40
|
|
9
41
|
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.1...v3.0.2
|
42
|
+
|
10
43
|
## [v3.0.1] - 28-12-2023
|
44
|
+
|
11
45
|
## What's Changed
|
12
|
-
|
46
|
+
|
47
|
+
- Handle odd numbers of NodeFilters to be configured by @stevehill1981 in https://github.com/gjtorikian/html-pipeline/pull/389
|
13
48
|
|
14
49
|
## New Contributors
|
15
|
-
|
50
|
+
|
51
|
+
- @stevehill1981 made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/389
|
16
52
|
|
17
53
|
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.0.0...v3.0.1
|
54
|
+
|
18
55
|
## [v3.0.0] - 24-12-2023
|
56
|
+
|
19
57
|
## What's Changed
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
58
|
+
|
59
|
+
- Switch to GitHub Actions by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/346
|
60
|
+
- add truffleruby-head by @gogainda in https://github.com/gjtorikian/html-pipeline/pull/348
|
61
|
+
- Add Rubocop by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/349
|
62
|
+
- Support multiple dependencies per filter by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/351
|
63
|
+
- Split filters up by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/360
|
64
|
+
- Migrate from Nokogiri to Selma by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/368
|
65
|
+
- You shall pass by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/369
|
66
|
+
- Update Selma signatures by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/370
|
67
|
+
- Close sanitization-related issues by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/371
|
68
|
+
- Drop SyntaxHighlightFilter by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/372
|
69
|
+
- V3 Release by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/347
|
70
|
+
- Use emoji from commonmarker by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/373
|
71
|
+
- req convert_filter if filter present by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/375
|
72
|
+
- 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
|
73
|
+
- Add the AssetProxyFilter by @digitalmoksha in https://github.com/gjtorikian/html-pipeline/pull/379
|
74
|
+
- Update rouge requirement from ~> 3.1 to ~> 4.1 by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/381
|
75
|
+
- Update gemoji requirement from ~> 3.0 to ~> 4.1 by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/382
|
76
|
+
- Have Zeitwerk not automatically load filters by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/383
|
77
|
+
- Bump the github-actions group with 1 update by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/384
|
78
|
+
- :gem: 3.0.0 by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/386
|
40
79
|
|
41
80
|
## New Contributors
|
42
|
-
|
43
|
-
|
44
|
-
|
81
|
+
|
82
|
+
- @gogainda made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/348
|
83
|
+
- @dependabot made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/377
|
84
|
+
- @digitalmoksha made their first contribution in https://github.com/gjtorikian/html-pipeline/pull/379
|
45
85
|
|
46
86
|
**Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v2.14.3...v3.0.0
|
87
|
+
|
47
88
|
## [v3.0.0.pre6] - 16-08-2023
|
89
|
+
|
48
90
|
null
|
91
|
+
|
49
92
|
# Changelog
|
50
93
|
|
51
94
|
## [v3.0.0.pre5](https://github.com/gjtorikian/html-pipeline/tree/v3.0.0.pre5) (2023-06-05)
|
@@ -76,7 +119,7 @@ null
|
|
76
119
|
|
77
120
|
**Merged pull requests:**
|
78
121
|
|
79
|
-
- req
|
122
|
+
- req convert_filter if `text/node`filter present [\#375](https://github.com/gjtorikian/html-pipeline/pull/375) ([gjtorikian](https://github.com/gjtorikian))
|
80
123
|
|
81
124
|
## [v3.0.0.pre2](https://github.com/gjtorikian/html-pipeline/tree/v3.0.0.pre2) (2023-01-26)
|
82
125
|
|
@@ -137,7 +180,7 @@ null
|
|
137
180
|
|
138
181
|
**Merged pull requests:**
|
139
182
|
|
140
|
-
- Replace EscapeUtils.
|
183
|
+
- Replace EscapeUtils.escape_html with CGI.escape_html [\#365](https://github.com/gjtorikian/html-pipeline/pull/365) ([ramhoj](https://github.com/ramhoj))
|
141
184
|
|
142
185
|
## [v2.14.2](https://github.com/gjtorikian/html-pipeline/tree/v2.14.2) (2022-06-12)
|
143
186
|
|
@@ -309,7 +352,7 @@ null
|
|
309
352
|
|
310
353
|
**Closed issues:**
|
311
354
|
|
312
|
-
- New feature request for hashtags \# filter
|
355
|
+
- New feature request for hashtags \# filter [\#301](https://github.com/gjtorikian/html-pipeline/issues/301)
|
313
356
|
- Whitelist srcset for responsive images [\#233](https://github.com/gjtorikian/html-pipeline/issues/233)
|
314
357
|
|
315
358
|
**Merged pull requests:**
|
@@ -412,7 +455,7 @@ null
|
|
412
455
|
|
413
456
|
- Set instrumentation name [\#275](https://github.com/gjtorikian/html-pipeline/pull/275) ([gjtorikian](https://github.com/gjtorikian))
|
414
457
|
- Switch to CommonMark [\#274](https://github.com/gjtorikian/html-pipeline/pull/274) ([kivikakk](https://github.com/kivikakk))
|
415
|
-
-
|
458
|
+
- add korgi to 3rd party extensions \[ci skip\] [\#271](https://github.com/gjtorikian/html-pipeline/pull/271) ([jodeci](https://github.com/jodeci))
|
416
459
|
|
417
460
|
## [v2.5.0](https://github.com/gjtorikian/html-pipeline/tree/v2.5.0) (2017-01-13)
|
418
461
|
|
@@ -421,7 +464,7 @@ null
|
|
421
464
|
**Closed issues:**
|
422
465
|
|
423
466
|
- Add `<wbr>` to whitelist [\#265](https://github.com/gjtorikian/html-pipeline/issues/265)
|
424
|
-
- Missing context keys for HTML::Pipeline::EmojiFilter: :
|
467
|
+
- Missing context keys for HTML::Pipeline::EmojiFilter: :asset_root [\#262](https://github.com/gjtorikian/html-pipeline/issues/262)
|
425
468
|
- Emoji \<img\> tags does not pass W3C validationg [\#234](https://github.com/gjtorikian/html-pipeline/issues/234)
|
426
469
|
- Incompatible character encodings: ASCII-8BIT and UTF-8 in EmailReplyFilter [\#229](https://github.com/gjtorikian/html-pipeline/issues/229)
|
427
470
|
|
@@ -504,8 +547,8 @@ null
|
|
504
547
|
**Merged pull requests:**
|
505
548
|
|
506
549
|
- 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-
|
550
|
+
- Fix for calling mention_link_filter with only one argument [\#230](https://github.com/gjtorikian/html-pipeline/pull/230) ([benbalter](https://github.com/benbalter))
|
551
|
+
- 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
552
|
|
510
553
|
## [v2.2.1](https://github.com/gjtorikian/html-pipeline/tree/v2.2.1) (2015-10-01)
|
511
554
|
|
@@ -561,7 +604,7 @@ null
|
|
561
604
|
- Question - Can this work with Rouge? [\#166](https://github.com/gjtorikian/html-pipeline/issues/166)
|
562
605
|
- Question about github markdown filter \(low priority!\) [\#165](https://github.com/gjtorikian/html-pipeline/issues/165)
|
563
606
|
- Do not mention or emojify in a codeblock [\#163](https://github.com/gjtorikian/html-pipeline/issues/163)
|
564
|
-
- MentionFilter
|
607
|
+
- MentionFilter base_url config question [\#161](https://github.com/gjtorikian/html-pipeline/issues/161)
|
565
608
|
- Feature Request: Add "details" tag to whitelist [\#138](https://github.com/gjtorikian/html-pipeline/issues/138)
|
566
609
|
|
567
610
|
**Merged pull requests:**
|
@@ -573,10 +616,10 @@ null
|
|
573
616
|
- \[ci skip\] Fix CHANGELOG.md rendering. [\#177](https://github.com/gjtorikian/html-pipeline/pull/177) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
574
617
|
- Restrict nokogiri to specific versions [\#176](https://github.com/gjtorikian/html-pipeline/pull/176) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
575
618
|
- 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\#
|
619
|
+
- Add 3rd party gem: html-pipeline-rouge_filter. [\#174](https://github.com/gjtorikian/html-pipeline/pull/174) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
620
|
+
- 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
621
|
- Whitelist summary and details element. [\#171](https://github.com/gjtorikian/html-pipeline/pull/171) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
579
|
-
- Implement new context option:
|
622
|
+
- 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
623
|
- Support ~login for MentionFilter. [\#167](https://github.com/gjtorikian/html-pipeline/pull/167) ([JuanitoFatas](https://github.com/JuanitoFatas))
|
581
624
|
- Add GitHub flavor Markdown Task List extension [\#162](https://github.com/gjtorikian/html-pipeline/pull/162) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
582
625
|
- Drop support for gemoji ~\> 1.0 [\#159](https://github.com/gjtorikian/html-pipeline/pull/159) ([jch](https://github.com/jch))
|
@@ -593,14 +636,14 @@ null
|
|
593
636
|
|
594
637
|
**Closed issues:**
|
595
638
|
|
596
|
-
- @
|
639
|
+
- @mention_filter should not replace mentions in style blocks. [\#143](https://github.com/gjtorikian/html-pipeline/issues/143)
|
597
640
|
- EmojiFilter doesn't work on strings that don't contain HTML [\#133](https://github.com/gjtorikian/html-pipeline/issues/133)
|
598
641
|
|
599
642
|
**Merged pull requests:**
|
600
643
|
|
601
644
|
- Search for text nodes on DocumentFragments without root tags [\#146](https://github.com/gjtorikian/html-pipeline/pull/146) ([Razer6](https://github.com/Razer6))
|
602
645
|
- Don't filter @mentions in \<style\> tags [\#145](https://github.com/gjtorikian/html-pipeline/pull/145) ([jch](https://github.com/jch))
|
603
|
-
- Prefer
|
646
|
+
- Prefer http_url in HttpsFilter [\#142](https://github.com/gjtorikian/html-pipeline/pull/142) ([bkeepers](https://github.com/bkeepers))
|
604
647
|
- 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
648
|
|
606
649
|
## [v1.10.0](https://github.com/gjtorikian/html-pipeline/tree/v1.10.0) (2014-09-05)
|
@@ -632,7 +675,7 @@ null
|
|
632
675
|
**Merged pull requests:**
|
633
676
|
|
634
677
|
- Generalize https filter take 2 [\#131](https://github.com/gjtorikian/html-pipeline/pull/131) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
635
|
-
- Remove
|
678
|
+
- Remove RUBY_VERSION conditionals from gemspec [\#130](https://github.com/gjtorikian/html-pipeline/pull/130) ([mislav](https://github.com/mislav))
|
636
679
|
- Add compatibility with gemoji v2 [\#129](https://github.com/gjtorikian/html-pipeline/pull/129) ([mislav](https://github.com/mislav))
|
637
680
|
|
638
681
|
## [v1.8.0](https://github.com/gjtorikian/html-pipeline/tree/v1.8.0) (2014-04-04)
|
@@ -659,7 +702,7 @@ null
|
|
659
702
|
**Closed issues:**
|
660
703
|
|
661
704
|
- cut a 1.6.0 release [\#116](https://github.com/gjtorikian/html-pipeline/issues/116)
|
662
|
-
- AutolinkFilter
|
705
|
+
- AutolinkFilter link_attr doesn't seem to work [\#114](https://github.com/gjtorikian/html-pipeline/issues/114)
|
663
706
|
- Spaces inserted into code [\#109](https://github.com/gjtorikian/html-pipeline/issues/109)
|
664
707
|
|
665
708
|
**Merged pull requests:**
|
@@ -747,9 +790,9 @@ null
|
|
747
790
|
|
748
791
|
**Merged pull requests:**
|
749
792
|
|
750
|
-
- Add
|
793
|
+
- Add link_attr option to Autolink filter [\#89](https://github.com/gjtorikian/html-pipeline/pull/89) ([excid3](https://github.com/excid3))
|
751
794
|
- Update readme with link to asciidoc filter [\#87](https://github.com/gjtorikian/html-pipeline/pull/87) ([jch](https://github.com/jch))
|
752
|
-
- use
|
795
|
+
- use xml_mini extracted from activesupport [\#85](https://github.com/gjtorikian/html-pipeline/pull/85) ([mojavelinux](https://github.com/mojavelinux))
|
753
796
|
- Filters Manage Dependencies [\#80](https://github.com/gjtorikian/html-pipeline/pull/80) ([simeonwillbanks](https://github.com/simeonwillbanks))
|
754
797
|
|
755
798
|
## [v0.3.1](https://github.com/gjtorikian/html-pipeline/tree/v0.3.1) (2013-09-16)
|
@@ -817,7 +860,7 @@ null
|
|
817
860
|
- Improve to describe gem 'github-linguist' [\#69](https://github.com/gjtorikian/html-pipeline/pull/69) ([tricknotes](https://github.com/tricknotes))
|
818
861
|
- Bump version to 0.1.0. Follow semver. [\#68](https://github.com/gjtorikian/html-pipeline/pull/68) ([jch](https://github.com/jch))
|
819
862
|
- Scope gem versions for Travis CI [\#67](https://github.com/gjtorikian/html-pipeline/pull/67) ([jch](https://github.com/jch))
|
820
|
-
- Allow passing
|
863
|
+
- Allow passing skip_tags in autolink filter context [\#65](https://github.com/gjtorikian/html-pipeline/pull/65) ([pengwynn](https://github.com/pengwynn))
|
821
864
|
- Support non-English characters in anchor names [\#64](https://github.com/gjtorikian/html-pipeline/pull/64) ([jakedouglas](https://github.com/jakedouglas))
|
822
865
|
- Fix the `AutolinkFilter` constant name. [\#57](https://github.com/gjtorikian/html-pipeline/pull/57) ([envygeeks](https://github.com/envygeeks))
|
823
866
|
- 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 +913,7 @@ null
|
|
870
913
|
**Merged pull requests:**
|
871
914
|
|
872
915
|
- 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\[:
|
916
|
+
- add result\[:mentioned_usernames\] for MentionFilter [\#42](https://github.com/gjtorikian/html-pipeline/pull/42) ([fahchen](https://github.com/fahchen))
|
874
917
|
|
875
918
|
## [v0.0.8.1](https://github.com/gjtorikian/html-pipeline/tree/v0.0.8.1) (2013-03-03)
|
876
919
|
|
@@ -886,7 +929,7 @@ null
|
|
886
929
|
|
887
930
|
**Merged pull requests:**
|
888
931
|
|
889
|
-
- Bump
|
932
|
+
- Bump escape_utils [\#41](https://github.com/gjtorikian/html-pipeline/pull/41) ([brianmario](https://github.com/brianmario))
|
890
933
|
- Don't monkeypatch Nokogiri in 1.9 [\#40](https://github.com/gjtorikian/html-pipeline/pull/40) ([defunkt](https://github.com/defunkt))
|
891
934
|
|
892
935
|
## [v0.0.8](https://github.com/gjtorikian/html-pipeline/tree/v0.0.8) (2013-02-07)
|
@@ -978,7 +1021,3 @@ null
|
|
978
1021
|
- Ensure required context values are present [\#9](https://github.com/gjtorikian/html-pipeline/pull/9) ([juliamae](https://github.com/juliamae))
|
979
1022
|
- emoji filter requires the emoji gem [\#8](https://github.com/gjtorikian/html-pipeline/pull/8) ([atmos](https://github.com/atmos))
|
980
1023
|
- 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
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:
|
64
61
|
|
65
|
-
|
62
|
+
```
|
63
|
+
Hey there, @gjtorikian
|
64
|
+
```
|
65
|
+
|
66
|
+
With the content, we also want to:
|
67
|
+
|
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
|
@@ -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
|
@@ -375,7 +388,7 @@ you to add additional elements. You can either modify the constant's value, or
|
|
375
388
|
re-define your own config and pass that in, such as:
|
376
389
|
|
377
390
|
```ruby
|
378
|
-
config = HTMLPipeline::SanitizationFilter::DEFAULT_CONFIG.
|
391
|
+
config = HTMLPipeline::SanitizationFilter::DEFAULT_CONFIG.deep_dup
|
379
392
|
config[:elements] << "iframe" # sure, whatever you want
|
380
393
|
```
|
381
394
|
|
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
|
|
@@ -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:
|
@@ -16,8 +16,8 @@ class HTMLPipeline
|
|
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
|
@@ -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
|
-
raise TypeError, "text must be a String" unless text.is_a?(String)
|
9
|
-
|
10
|
-
# Ensure that this is always a string
|
11
|
-
@text = text.respond_to?(:to_str) ? text.to_str : text.to_s
|
7
|
+
def initialize(context: {}, result: {})
|
12
8
|
super(context: context, result: result)
|
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
@@ -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
|
156
|
+
text_filters: @text_filters.map { |f| f.class.name },
|
157
157
|
context: context,
|
158
158
|
result: 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: result)
|
163
|
+
perform_filter(filter, doc, context: (filter.context || {}).merge(context), result: result)
|
164
164
|
end
|
165
165
|
end
|
166
166
|
end
|
@@ -171,12 +171,13 @@ 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
|
unless @node_filters.empty?
|
179
179
|
instrument("call_node_filters.html_pipeline", payload) do
|
180
|
+
@node_filters.each { |filter| filter.context = (filter.context || {}).merge(context) }
|
180
181
|
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
|
181
182
|
html = result[:output]
|
182
183
|
payload = default_payload({
|
@@ -187,7 +188,7 @@ class HTMLPipeline
|
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
190
|
-
instrument("html_pipeline
|
191
|
+
instrument("sanitization.html_pipeline", payload) do
|
191
192
|
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
|
192
193
|
end
|
193
194
|
|
@@ -204,7 +205,7 @@ class HTMLPipeline
|
|
204
205
|
# Returns the result of the filter.
|
205
206
|
def perform_filter(filter, doc, context: {}, result: {})
|
206
207
|
payload = default_payload({
|
207
|
-
filter: filter.name,
|
208
|
+
filter: filter.class.name,
|
208
209
|
context: context,
|
209
210
|
result: result,
|
210
211
|
})
|
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.2.0
|
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: 2024-
|
11
|
+
date: 2024-04-30 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.
|
114
|
+
rubygems_version: 3.4.6
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Helpers for processing content through a chain of filters
|