Skip to content

Instantly share code, notes, and snippets.

@antimatter15
Created January 19, 2010 23:12
Show Gist options
  • Save antimatter15/281410 to your computer and use it in GitHub Desktop.
Save antimatter15/281410 to your computer and use it in GitHub Desktop.
body2 = ""
while $stdin.gets # reads from STDIN
body2 += "#{$_}"
end
body2.gsub!(/\r\n/m,"\n")
body2.gsub!(/\{\{([a-z]{3,10})\|([a-z]{3,20})\|(\d\d\d\d).*?\}\}/i){"#{$2} (#{$3})"}
body2.gsub!(/\{\{quote\|(.+?)\}\}/i){"<blockquote>"+"#{$1}".strip()+"</blockquote>"}
body2.gsub!(/^\|.+$/i,"\n") #get rid of lines starting with |
body2.gsub!(/\[\[Image:(.+)\|(.+)\]\]/i,"")
body2.gsub!(/\[\[File:(.+)\|(.+)\]\]/i,"")
body2.gsub!(/\[\[(.{7,25}:.{4,60})\|(.{4,30})\]\]/){"#{$2}"} #they wont be valid articles anyway
body2.gsub!(/\[\[(.{7,25}:.{4,60})\]\]/){"#{$1}"} #they wont be valid articles anyway
body2.gsub!(/\[\[(.{1,20}):(.*?)\]\]/,"")
body2.gsub!(/\[http(.+?):space:(.+?)\]/){"#{$2}"}
body2.gsub!(/\[http(.+?)\]/,"")
body2.gsub!(/\{\|(.+?)\|\}/m,"")
body2.gsub!(/style="(.+?)"/,"")
body2.gsub!(/class="(.+?)"/,"")
body2.gsub!(/border="(.+?)"/,"")
body2.gsub!(/col.{3,6}="(.+?)"/,"")
body2.gsub!(/<blockquote>(.+?)<\/blockquote>/im){"\n\n"+'"'+"#{$1}".strip()+'"'+"\n\n"}
body2.gsub!(/<math>/,"")
body2.gsub!(/<\/math>/,"")
body2.gsub!(/col.{3,6}="(.+?)"/,"")
body2.gsub!(/cell(.+?)ing="(.+?)"/,"")
body2.gsub!(/<ref(.*?)>(.*?)<\/ref>/m,"")
body2.gsub!(/<ref(.*?)\/>/,"")
body2.gsub!(/\{\{(.+?)\}\}/m,"")
body2.gsub!(/==(.?.?)eferences(.*?)==(.+)\Z/m,"")
body2.gsub!(/<gallery(.*?)>(.+?)<\/gallery>/m, "")
#body2.gsub!(/\[([^\][:space:]]+) ([^\]]+)\]/) {"#{$2}"}
#body2.gsub!(/\[([^\][:space:]]+)\]/) {"#{$1}"}
body2.gsub!(/<!--(.+?)-->/,"")
body2.gsub!(/<(rR)eferences(.*?)\/>/, "")
#body2.gsub!(/\n\n/,"\n")
body2.gsub!(/^\|.+$/i,"\n") #get rid of lines starting with |
body2.gsub!(/==.+?==\n+(==.+?==)/){"#{$1}"}
body2.gsub!(/^\*.{0,3}$/i,"\n")
body2.gsub!(/==(.{3,15})==.{0,5}\Z/m,"")
body2.gsub!(/\n{3,19}/m,"\n\n")
body2.gsub!(/\n{3,19}/m,"\n\n")
body2.gsub!(" >",">")
body2.gsub!("<div>","")
body2.gsub!("</div>","")
body2.gsub!(/ {2,49}/," ")
body2.gsub!("{|","")
body2.gsub!("|}","")
body2.gsub!("}}","")
body2.gsub!("{{","")
body2.gsub!("( ","(")
body2.gsub!(" )",")")
body2.gsub!("(;","(")
body2.gsub!("( ","(")
body2.strip!
#body2.gsub!(/==.+?==$/,"")
body2.strip!
puts body2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment