From 14abefbe611dcf5e5c1cba4479aa2abc642a5f29 Mon Sep 17 00:00:00 2001 From: Steve Hill Date: Thu, 28 Dec 2023 16:16:18 +0000 Subject: [PATCH 1/3] Handle odd numbers of NodeFilters to be configured The previous method of merging the results from the NodeFilter instances was breaking because Ruby was treating it as a series of 2-element arrays. If you had 0, 1 or 2 node filters configured, it would work fine; if you added a third, it would break with an `ArgumentError`. Adding a fourth makes it work again. Fixes #388 --- lib/html_pipeline.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/html_pipeline.rb b/lib/html_pipeline.rb index 0fb50fbc..bb890a29 100644 --- a/lib/html_pipeline.rb +++ b/lib/html_pipeline.rb @@ -178,7 +178,7 @@ def call(text, context: {}, result: {}) end end - result = result.merge(Hash[*@node_filters.collect(&:result).flatten]) + @node_filters.collect(&:result).reduce(result, :merge) @node_filters.each(&:reset!) result From a8fdac9379bd23c182c557d0d6cf569e669bec13 Mon Sep 17 00:00:00 2001 From: Steve Hill Date: Thu, 28 Dec 2023 16:23:11 +0000 Subject: [PATCH 2/3] Actually keep the results --- lib/html_pipeline.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/html_pipeline.rb b/lib/html_pipeline.rb index bb890a29..8f2afe1f 100644 --- a/lib/html_pipeline.rb +++ b/lib/html_pipeline.rb @@ -178,7 +178,7 @@ def call(text, context: {}, result: {}) end end - @node_filters.collect(&:result).reduce(result, :merge) + result = result.merge(@node_filters.collect(&:result).reduce({}, :merge)) @node_filters.each(&:reset!) result From 74ef05055279717c55d875d56d1f36c53659cdcd Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Thu, 28 Dec 2023 13:06:01 -0500 Subject: [PATCH 3/3] :gem 3.0.1 --- lib/html_pipeline/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/html_pipeline/version.rb b/lib/html_pipeline/version.rb index b029204b..3d2f1699 100644 --- a/lib/html_pipeline/version.rb +++ b/lib/html_pipeline/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class HTMLPipeline - VERSION = "3.0.0" + VERSION = "3.0.1" end