Created
May 5, 2011 16:12
-
-
Save ybenjo/957337 to your computer and use it in GitHub Desktop.
Convert 'hatena tex' to google chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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