Skip to content

Instantly share code, notes, and snippets.

@ybenjo
Created January 1, 2011 15:31
Show Gist options
  • Select an option

  • Save ybenjo/761809 to your computer and use it in GitHub Desktop.

Select an option

Save ybenjo/761809 to your computer and use it in GitHub Desktop.
convert hatena-tex to google chart api's tex
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