Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 1.08 KB

README.md

File metadata and controls

44 lines (33 loc) · 1.08 KB

showdown4j

Showdown.js for Java

There are several markdown libraries for Java, but we needed 100% exact output in our backend (Java) as Showdown.js which we use at the frontend.

This tool simply starts Rhino (JavaScript engine for Java), loads Showdown.js and passes your markdown content to it.

##Use default showdown.js shipped with this library

    @Test
    public void defaultConstructor() throws Exception
    {
//        Given
        final Showdown showdown = new Showdown();

//        When
        final String result = showdown.makeHtml("#abc");

//        Then
        assertEquals("<h1 id=\"abc\">abc</h1>", result);
    }

##Use your own version of showdown.js

    @Test
    public void yourOwnShowdownJS() throws Exception
    {
//        Given
        final Showdown showdown = new new Showdown(getClass().getResourceAsStream("/pl/itcrowd/showdown4j/showdown.js"));

//        When
        final String result = showdown.makeHtml("#abc");

//        Then
        assertEquals("<h1 id=\"abc\">abc</h1>", result);
    }