gjtorikian / html-pipeline

HTML processing filters and utilities
MIT License
2.26k stars 380 forks source link

[BREAKING] `TextFilter` now requires instantiation #398

Closed gjtorikian closed 4 months ago

gjtorikian commented 4 months ago

This shouldn't be too disruptive for folks using TextFilter, but is a breaking change nonetheless. Yes, SemVer dictates that I bump a major release, but I don't think many, if anybody, uses text filters, and I don't want to signal a major change for arguably the more important functions of this library, which is to take markup and turn it into safe HTML.

None of the behavior related to HTML manipulation or node filters are changing. Instead, TextFilters should now be instantiated just like node filters:

# before
MarkdownPipeline = HTMLPipeline.new (
  text_filters: [HTMLPipeline::TextFilter::ImageFilter],
  convert_filter: HTMLPipeline::ConvertFilter::MarkdownFilter.new,
  node_filters: [
    HTMLPipeline::NodeFilter::HttpsFilter.new,HTMLPipeline::NodeFilter::MentionFilter.new,
  ], context: context)

# after

MarkdownPipeline = HTMLPipeline.new (
  text_filters: [HTMLPipeline::TextFilter::ImageFilter.new],
  convert_filter: HTMLPipeline::ConvertFilter::MarkdownFilter.new,
  node_filters: [
    HTMLPipeline::NodeFilter::HttpsFilter.new,HTMLPipeline::NodeFilter::MentionFilter.new,
  ], context: context)

That's it.

dentarg commented 4 months ago

Why do you think not many (or none) uses text filters? Curious if I'm doing something wrong (https://github.com/Starkast/wikimum/pull/590/files#diff-f76e24ef86d4ffadf31658baddaf98cdf97a1186cfa61f2a41d735b3a878dac0)

Re: the breaking change, it's okay, I have tests. Promises about SemVer is not to be trusted :)

gjtorikian commented 4 months ago

Because they don’t really “do” anything special. They’re kind of just elaborately structured gsub statements! But obviously I use them too and I’m happy they work for you too!