diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-03-25 19:30:29 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-03-25 19:30:29 +0000 |
commit | c671bf49230781ed80d9fa80577fed9b1b655a99 (patch) | |
tree | 8f3c12c20d008c055d9b40045cb66863d7ffe1cd /lib | |
parent | c513b0227a88b441500581cff9e7f3f954830d2e (diff) |
Utils: try non-paragraphs if no paragraphs was found
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/core/utils/utils.rb | 16 |
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 |