Skip to content

Instantly share code, notes, and snippets.

@ybenjo
Created May 5, 2011 16:12
Show Gist options
  • Save ybenjo/957337 to your computer and use it in GitHub Desktop.
Save ybenjo/957337 to your computer and use it in GitHub Desktop.
Convert 'hatena tex' to google chart
require 'cgi'
google_url = "http://chart.apis.google.com/chart?cht=tx&chl="
$<.each{|l|
l.chomp!
l.scan(/(\[tex:(.*?)\]){1,}/).each do |e|
math = e[1]
url_math = CGI.escape(math)
l.sub!(/#{Regexp.quote(e[0])}/,"<img src=\"#{google_url}#{url_math}\">")
end
puts l
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment