summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-25 19:30:29 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-25 19:30:29 +0000
commitc671bf49230781ed80d9fa80577fed9b1b655a99 (patch)
tree8f3c12c20d008c055d9b40045cb66863d7ffe1cd /lib/rbot
parentc513b0227a88b441500581cff9e7f3f954830d2e (diff)
Utils: try non-paragraphs if no paragraphs was found
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/core/utils/utils.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/rbot/core/utils/utils.rb b/lib/rbot/core/utils/utils.rb
index cf16b601..bbdd462b 100644
--- a/lib/rbot/core/utils/utils.rb
+++ b/lib/rbot/core/utils/utils.rb
@@ -432,7 +432,8 @@ module ::Irc
end
HX_REGEX = /<h(\d)(?:\s+[^>]*)?>.*?<\/h\1>/im
- PAR_REGEX = /<p(?:\s+[^>]*)?>.*?<\/?(?:p|(?:div|html|body|table|td|tr)(?:\s+[^>]*)?)>/im
+ PAR_REGEX = /<p(?:\s+[^>]*)?>.*?<\/?(?:p|div|html|body|table|td|tr)(?:\s+[^>]*)?>/im
+ AFTER_PAR1_REGEX = /<\w+\s+[^>]*body[^>]*>.*?<\/?(?:p|div|html|body|table|td|tr)(?:\s+[^>]*)?>/im
# Try to grab and IRCify the first HTML par (<p> tag) in the given string.
# If possible, grab the one after the first heading
#
@@ -471,6 +472,19 @@ module ::Irc
txt.sub!(strip, '') if strip
end
end
+
+ # Nothing yet ... let's get drastic: we ca
+ if txt.empty?
+ header_found = xml
+ while txt.empty?
+ candidate = header_found[AFTER_PAR1_REGEX]
+ break unless candidate
+ txt = candidate.ircify_html
+ header_found = $'
+ txt.sub!(strip, '') if strip
+ end
+ end
+
return txt
end