gjtorikian / html-pipeline

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

v3: Question regarding requiring a ConvertFilter if there are NodeFilters #374

Closed digitalmoksha closed 1 year ago

digitalmoksha commented 1 year ago

Taking a look at https://github.com/gjtorikian/html-pipeline/blob/main/lib/html_pipeline.rb#L118-L123

    @convert_filter = convert_filter
    if @convert_filter.nil? && !@node_filters.empty?
      raise InvalidFilterError, "Must provide `convert_filter` if `node_filter`s is also provided"
    elsif !@convert_filter.nil?
      validate_filter(@convert_filter, HTMLPipeline::ConvertFilter)
    end

It looks like a ConvertFilter is required if any NodeFilters are specified. It seems like having a pipeline that can operate on an initial input of HTML is useful.

For example, coming from V2, chaining multiple pipelines together. One pipeline might do the markdown conversion (which in our case requires a preprocessing text filter, followed by the markdown conversion, and then a post processing HTML filter). Then depending on the context, we'll chain another pipeline of HTML filters that handle more specific transformations. With even another post processing pipeline for handling redactions, that happens only on cached html that is going to be displayed.

wdyt about requiring a convert filter if there are text filters and node filters - then you would definitely need a conversion step from text to HTML.

gjtorikian commented 1 year ago

Oh, I like that suggestion very much. Thanks, good idea!