Skip to content

Instantly share code, notes, and snippets.

@yagays
Created October 19, 2012 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yagays/3915940 to your computer and use it in GitHub Desktop.
Save yagays/3915940 to your computer and use it in GitHub Desktop.
Convert tex formula into google chart API format (Jekyll/Octopress plugin)
# 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