How do I convert wiki text to HTML?

How do I convert wiki text to HTML?

This depends on where you want to do it:

In a macro...

You will need the SubRenderer (see how to retrieve it).

The SubRenderer has two render methods: one that allows you to specify a specific RenderMode for the rendered content, and another that uses the current RenderMode from the RenderContext.

If you just want the body of your macro rendered, you can have this done for you by the macro subsystem by having your macro's getBodyRenderMode method return the appropriate RenderMode.

In some other component...

You will need the WikiStyleRenderer (see how to retrieve a component).

The WikiStyleRenderer has a convertWikiToHtml method that takes the wiki text you wish to convert, and a RenderContext. If you are converting the text in the context of some ContentEntityObject (for example within a page or blog post), then you can call contentEntityObject.toPageContext() to retrieve its RenderContext. Otherwise pass in a new PageContext().

Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport