diff --git a/lib/html/pipeline/text_filter.rb b/lib/html/pipeline/text_filter.rb
index 3fc47afd..851b357c 100644
--- a/lib/html/pipeline/text_filter.rb
+++ b/lib/html/pipeline/text_filter.rb
@@ -5,8 +5,8 @@ class TextFilter < Filter
def initialize(text, context = nil, result = nil)
raise TypeError, "text cannot be HTML" if text.is_a?(DocumentFragment)
# Ensure that this is always a string
- @text = text.try(:to_str) || text.to_s
+ @text = text.respond_to?(:to_str) ? text.to_str : text.to_s
super nil, context, result
end
end
-end
\ No newline at end of file
+end