Search in sources :

Example 1 with ParsingTimeoutException

use of org.pegdown.ParsingTimeoutException in project gitblit by gitblit.

the class MarkdownUtils method transformMarkdown.

/**
	 * Returns the html version of the markdown source text.
	 *
	 * @param markdown
	 * @return html version of markdown text
	 * @throws java.text.ParseException
	 */
public static String transformMarkdown(String markdown, LinkRenderer linkRenderer) {
    try {
        PegDownProcessor pd = new PegDownProcessor(ALL & ~SMARTYPANTS & ~ANCHORLINKS);
        RootNode astRoot = pd.parseMarkdown(markdown.toCharArray());
        return new WorkaroundHtmlSerializer(linkRenderer == null ? new LinkRenderer() : linkRenderer).toHtml(astRoot);
    } catch (ParsingTimeoutException e) {
        return null;
    }
}
Also used : RootNode(org.pegdown.ast.RootNode) LinkRenderer(org.pegdown.LinkRenderer) WorkaroundHtmlSerializer(com.gitblit.wicket.MarkupProcessor.WorkaroundHtmlSerializer) ParsingTimeoutException(org.pegdown.ParsingTimeoutException) PegDownProcessor(org.pegdown.PegDownProcessor)

Aggregations

WorkaroundHtmlSerializer (com.gitblit.wicket.MarkupProcessor.WorkaroundHtmlSerializer)1 LinkRenderer (org.pegdown.LinkRenderer)1 ParsingTimeoutException (org.pegdown.ParsingTimeoutException)1 PegDownProcessor (org.pegdown.PegDownProcessor)1 RootNode (org.pegdown.ast.RootNode)1