gjtorikian / html-pipeline

HTML processing filters and utilities
MIT License
2.27k stars 383 forks source link

Error when passing instance of `TextFilter` class to `text_filters` option #400

Closed aki77 closed 7 months ago

aki77 commented 7 months ago

When passing an instance of the TextFilter class to the text_filters option as per the sample code, it results in a wrong number of arguments (given 2, expected 1) error.

Steps to Reproduce

pipeline = HTMLPipeline.new(text_filters: [ HTMLPipeline::TextFilter::PlainTextInputFilter.new])
pipeline.call('test')

Workaround

pipeline = HTMLPipeline.new(text_filters: [ HTMLPipeline::TextFilter::PlainTextInputFilter])
pipeline.call('test')

Additional Information https://github.com/gjtorikian/html-pipeline/blob/e1328b4763dd56a83abaa1746ba8555e0e80ec04/lib/html_pipeline.rb#L213

gjtorikian commented 7 months ago

Which version of html-pipeline is this? Recently there was a change to this exact behavior—the latest version is 3.1.0. Could you try your example with that?

aki77 commented 7 months ago

Thank you for your response. I'm using 3.1.0. The issue arises because although keyword arguments are being passed to the call method, the TextFilter class's call method only accepts the text argument.

https://github.com/gjtorikian/html-pipeline/blob/e1328b4763dd56a83abaa1746ba8555e0e80ec04/lib/html_pipeline.rb#L213

https://github.com/gjtorikian/html-pipeline/blob/e1328b4763dd56a83abaa1746ba8555e0e80ec04/lib/html_pipeline/text_filter/plain_text_input_filter.rb#L8

gjtorikian commented 7 months ago

Gah, thank you for noticing that. 3.1.1 is released, fixing this.