]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/urban.rb
Trap a possible exception when getting URL titles, even though nothing is actually...
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / urban.rb
index 36c390777509f66e47027e05ebbfe4ed84806b0e..95210b252460980d7918c9067327ce929685189e 100644 (file)
@@ -59,7 +59,21 @@ class UrbanPlugin < Plugin
   end
 
   def get_def(text)
-    Utils.decode_html_entities text.gsub(/(?:<a href.*?>prev<\/a> )?<a href.*?>home<\/a>(?: <a href.*?>next<\/a>)?/,'').gsub(/<\/?p>/, ' ').gsub(/<.*?>/, '').gsub("\n", ' ').strip
+    # Start by removing the prev/home/next links
+    t = text.gsub(/(?:<a href.*?>prev<\/a> )?<a href.*?>home<\/a>(?: <a href.*?>next<\/a>)?/,'')
+    # Close up paragraphs
+    t.gsub!(/<\/?p>/, ' ')
+    t.gsub!("\n", ' ')
+    # Reverse headings
+    t.gsub!(/<\/?b>/,"#{Reverse}")
+    # Enbolden links
+    t.gsub!(/<\/?a(?: .*?)?>/,"#{Bold}")
+    # Reverse examples
+    t.gsub!(/<\/?(?:i|em)>/,"#{Underline}")
+    # Clear anything else
+    t.gsub!(/<.*?>/, '')
+
+    Utils.decode_html_entities t.strip
   end
 
   def uotd(m, params)