Created
July 20, 2009 16:31
-
-
Save angerman/150429 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(ns survey.maruku | |
(:import javax.script.ScriptEngineManager javax.script.Invocable)) | |
;; setup jruby | |
(System/setProperty "jruby.base", "/Users/angerman/Library/JRuby") | |
(System/setProperty "jruby.home", "/Users/angerman/Library/JRuby") | |
(System/setProperty "jruby.lib", "/Users/angerman/Library/JRuby/lib") | |
(System/setProperty "jruby.script", "jruby") | |
(System/setProperty "jruby.shell", "/bin/sh") | |
(def maruku-wrapper-src "require 'rubygems' | |
require 'maruku' | |
require 'maruku/ext/math' | |
MaRuKu::Globals[:verbose] = true | |
MaRuKu::Globals[:html_math_engine] = 'blahtex' | |
MaRuKu::Globals[:html_png_engine] = 'blahtex' | |
MaRuKu::Globals[:html_math_output_mathml] = false | |
MaRuKu::Globals[:html_math_output_png] = true | |
MaRuKu::Globals[:math_png_dir] = '/tmp' | |
MaRuKu::Globals[:math_png_dir_url] = 'file:///tmp' | |
def render(text) | |
Maruku.new(text).to_html | |
end | |
def render_doc(text) | |
Maruku.new(text).to_html_document | |
end") | |
(def jruby (.getEngineByName (new ScriptEngineManager) "jruby")) | |
(.eval jruby maruku-wrapper-src) | |
(defn render [text] | |
"" | |
(.invokeFunction jruby "render" (to-array [text]))) | |
(defn render-to-document [text] | |
"" | |
(.invokeFunction jruby "render_doc" (to-array [text]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment