Created
October 19, 2012 02:35
-
-
Save yagays/3915940 to your computer and use it in GitHub Desktop.
Convert tex formula into google chart API format (Jekyll/Octopress plugin)
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
# Convert tex formula into google chart API format (Jekyll/Octopress plugin) | |
# | |
# Usage: {% gctex tex_formula %} | |
# | |
# Author: yag_ays (yanagi.ayase [at] gmail.com) | |
# blog: http://yagays.github.com/ | |
# | |
# Ref: http://d.hatena.ne.jp/repose/20110506/1304612242 | |
require "cgi" | |
module Jekyll | |
class GoogleChartTexTag < Liquid::Tag | |
def initialize(tag_name, text, tokens) | |
super | |
@text = text | |
end | |
def render(context) | |
"![#{@text}](http://chart.apis.google.com/chart?cht=tx&chl=#{CGI.escape(@text)})" | |
end | |
end | |
end | |
Liquid::Template.register_tag('gctex', Jekyll::GoogleChartTexTag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment