]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
HTML IRCification: try to handle super and subscripts
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 5 Apr 2007 14:20:00 +0000 (14:20 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 5 Apr 2007 14:20:00 +0000 (14:20 +0000)
lib/rbot/core/utils/extends.rb

index ff9d0f353f0ae319f0718aa7caf522bbbff4081b..4b7e57f35da8675a4cdf2b4561ef11145ab29514 100644 (file)
@@ -61,6 +61,12 @@ class ::String
     txt.gsub!("\n", ' ')
     txt.gsub!("\r", ' ')
 
+    # Superscripts and subscripts are turned into ^{...} and _{...}
+    # where the {} are omitted for single characters
+    txt.gsub!(/<sup>(.*?)<\/sup>/, '^{\1}')
+    txt.gsub!(/<sub>(.*?)<\/sub>/, '_{\1}')
+    txt.gsub!(/(^|_)\{(.)\}/, '\1\2')
+
     # All other tags are just removed
     txt.gsub!(/<[^>]+>/, '')