I’m using marked on the client side to render markdown code to html.
But now I need to do the same thing on the server side which is Java. In order to get the exact same html code, I have to use marked other than other java markdown libraries.
How can I load the “marked.js” file in java and run the javascript code?
marked.parser(marked.lexer("**hello,world**"));
2 options:
Rhinotutorial.OR:
Directly use the internal ScriptEngine in Java SE 6 and later, that comes bundled with Rhino for you. See the
RunMarkedexample below adapted to your needs.RunScript.java
RunMarked.java
Actually, I noticed Freewind’s answer, and I would have written exactly the same (except I’d load the lib directly with
Files.toString(File)using Google Guava). Please refer to his answer (and give him points if you find his answer helpful).