How can I get html content of page when I heve page ID? I am writing plugin for confluence (java api) and I need content of page in html (source of page).
You need to use the PageManager API to retrieve the content of the page, and then use the WikiStyleRenderer API to convert the wiki markup into the HTML markup for the page.
Here's a code snippet:
public class MyExampleClass { private final PageManager pageManager; private final WikiStyleRenderer wikiStyleRenderer; public MyExampleClass(PageManager pageManager, WikiStyleRenderer wikiStyleRenderer) { this.pageManager = pageManager; this.wikiStyleRenderer = wikiStyleRenderer; } public String getHtmlForPage(long pageId) { Page page = pageManager.getPage(pageId); PageContext pageContext = page.toPageContext(); String contentToRender = page.getContent(); return wikiStyleRenderer.convertWikiToXHtml(pageContext, contentToRender); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Marcin,
I've been doing a lot of research on your question, and I've been struggling to find an inbuilt method to display HTML code for the page.
What I have found is the following: Wiki Markup Converters
The best one on there appears to be Wiky. It is written in Javascript and is bi-directional. It can convert your wiki markup to HTML, then convert the generated HTML back to wiki markup (should you need the function)
Hope this helps you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Marcin,
I hope I have understood your question correctly. Confluence has the ability to allow you to export a space or a page in HTML (usually so it can be used for a website), this will allow you to view a page in HTML.
Directions are as follows:
Go to a page in the space, open the 'Browse' menu and select 'Advanced'.
More detailed information can be viewed at: Confluence 3.5 Documentation - Export to HTML
Hope that answers your issue!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your answer!
I am writing confluence plugin and I want to take page as html code and process this string. I can use getContent() method (from Page class) but I get wiki markup. What class or method can I use in order to get html code page?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.