From ef60325fc646625ace71030b7ed2b55ff911a9f0 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 18 Sep 2007 13:24:55 +0000 Subject: extends: String#ircify_html now has an option to obey non-breakable spaces or turn them into normal spaces This option is used e.g. by the dict plugin to reduce the excessive whitespace in oxford entries. --- lib/rbot/core/utils/extends.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/rbot') diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb index dcc257a2..4e5459d8 100644 --- a/lib/rbot/core/utils/extends.rb +++ b/lib/rbot/core/utils/extends.rb @@ -144,6 +144,14 @@ class ::String # such as   txt = Utils.decode_html_entities(txt) + # Keep unbreakable spaces or conver them to plain spaces? + case val = opts[:nbsp] + when :space, ' ' + txt.gsub!([160].pack('U'), ' ') + else + warning "unknown :nbsp option #{val} passed to ircify_html" if val + end + # Remove double formatting options, since they only waste bytes txt.gsub!(/#{Bold}(\s*)#{Bold}/, '\1') txt.gsub!(/#{Underline}(\s*)#{Underline}/, '\1') -- cgit v1.2.3