diff --git a/_plugins/codecogs.rb b/_plugins/codecogs.rb new file mode 100644 index 0000000..6f35d8e --- /dev/null +++ b/_plugins/codecogs.rb @@ -0,0 +1,27 @@ +# Title: codecogs plugin +# Author: Carl Boettiger, @cboettig +# License: MIT +# +# A simple filter to replace mathjax-latex syntax with images of the +# equations as rendered by codecogs. This is useful to filter content +# entered into the atom feed, where javascript and css-based rendering +# of equations won't work. + +# Credits to Noam Ross http://www.noamross.net/blog/2012/4/4/math-in-rss-feeds.html for inspiring this approach and to +# helpful folks on SO for the regexpr: http://stackoverflow.com/questions/13166112/ruby-regexp-to-replace-equations + +# Example use: +# +# {{ post.content | codecogs }} +# + +module Jekyll + module ImageFilter + def codecogs(input) +# puts "generating images for equations in RSS feed with codecogs.rb" + desired = input.gsub(/\\\[\s*(.*?)\s*\\\]/, "
") + desired.gsub(/\\\(\s*(.*?)\s*\\\)/, "") + end + end +end +Liquid::Template.register_filter(Jekyll::ImageFilter) diff --git a/feed.xml b/feed.xml index ec361c0..45c1353 100755 --- a/feed.xml +++ b/feed.xml @@ -5,17 +5,17 @@ layout: null