Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8216085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:00:39+00:00 2026-06-07T12:00:39+00:00

I’m using marked on the client side to render markdown code to html. But

  • 0

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**"));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:00:43+00:00Added an answer on June 7, 2026 at 12:00 pm

    2 options:

    1. Have a look at the Rhino tutorial.
    2. Then refer to the RunScript example, reproduced below and embed Rhino yourself.
    3. Then edit it to fit your needs

    OR:

    Directly use the internal ScriptEngine in Java SE 6 and later, that comes bundled with Rhino for you. See the RunMarked example below adapted to your needs.


    RunScript.java

    /*
     * Licensed under MPL 1.1/GPL 2.0
     */
    
    import org.mozilla.javascript.*;
    
    /**
     * RunScript: simplest example of controlling execution of Rhino.
     *
     * Collects its arguments from the command line, executes the
     * script, and prints the result.
     *
     * @author Norris Boyd
     */
    public class RunScript {
        public static void main(String args[])
        {
            // Creates and enters a Context. The Context stores information
            // about the execution environment of a script.
            Context cx = Context.enter();
            try {
                // Initialize the standard objects (Object, Function, etc.)
                // This must be done before scripts can be executed. Returns
                // a scope object that we use in later calls.
                Scriptable scope = cx.initStandardObjects();
    
                // Collect the arguments into a single string.
                String s = "";
                for (int i=0; i < args.length; i++) {
                    s += args[i];
                }
    
                // Now evaluate the string we've colected.
                Object result = cx.evaluateString(scope, s, "<cmd>", 1, null);
    
                // Convert the result to a string and print it.
                System.err.println(Context.toString(result));
    
            } finally {
                // Exit from the context.
                Context.exit();
            }
        }
    }
    

    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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I need to clean up various Word 'smart' characters in user input, including but
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.