I have been trying to use this class from tha JAVA API (https://docs.atlassian.com/atlassian-confluence/5.3.1/index.html?com/atlassian/confluence/), but I'm struggling because of the lack f proper documentation. My aim is to convert from a wiki markup format to the xhtml that Confluence uses:
Here is my code till now:
package org.myorg; import java.util.List; import java.util.ArrayList; import java.io.BufferedReader; import java.io.FileReader; import com.atlassian.renderer.RenderContext; import com.atlassian.confluence.content.render.xhtml.migration.WikiToXhtmlMigrator; import com.atlassian.confluence.content.render.xhtml.ConversionContext; import com.atlassian.confluence.content.render.xhtml.DefaultConversionContext; import com.atlassian.confluence.content.render.xhtml.storage.pagelayouts.StoragePageLayoutMarshaller; import com.atlassian.confluence.xhtml.api.MacroDefinition; import com.atlassian.confluence.content.render.xhtml.storage.macro.*; import com.atlassian.renderer.RendererConfiguration; import com.atlassian.renderer.links.LinkRenderer; import com.atlassian.renderer.v2.V2LinkRenderer; import com.atlassian.renderer.embedded.EmbeddedResourceRenderer; import com.atlassian.renderer.embedded.DefaultEmbeddedResourceRenderer; import com.atlassian.confluence.content.render.xhtml.migration.ErrorReportingV2Renderer; import com.atlassian.renderer.v2.V2Renderer; import com.atlassian.confluence.content.render.xhtml.storage.macro.StorageMacroV2Marshaller; import com.atlassian.renderer.v2.components.RendererComponent; public class Wiki2xhtml { public static class Rend implements RendererConfiguration { public String getCharacterEncoding() { return new String("UTF-8"); //Will return the character encoding for the current application. } public String getWebAppContextPath() { return ""; //Returns the context path of the running web application. } public boolean isAllowCamelCase() { return true; //If this method returns true then camelCase links will be allowed and generated. } public boolean isNofollowExternalLinks() { return false; //If this method returns true then external links will be generated with the rel=nofollow attribute. } } public static void main() { BufferedReader reader = new BufferedReader(new FileReader("C:\\Users\\arenu.CORP\\Desktop\\docs\\Engineering\\markupFile")); String wikiContent = new String(); String line = null; while ((line = reader.readLine()) != null) { wikiContent = wikiContent + line; } /* public WikiToXhtmlMigrator(com.atlassian.renderer.RendererConfiguration rendererConfiguration, com.atlassian.renderer.links.LinkRenderer defaultLinkRenderer, com.atlassian.renderer.embedded.EmbeddedResourceRenderer defaultEmbeddedRenderer, ErrorReportingV2Renderer renderer) */ RenderContext rE = new RenderContext(); DefaultConversionContext dCE = new DefaultConversionContext(rE); RendererConfiguration rC = new Rend(); LinkRenderer dLC = new V2LinkRenderer(); EmbeddedResourceRenderer dER = new DefaultEmbeddedResourceRenderer(); //ErrorReportingV2Renderer(java.util.List<com.atlassian.renderer.v2.components.RendererComponent> components, Marshaller<MacroDefinition> wikiMarkupMacroMarshaller) List<RendererComponent> rCList = new ArrayList<RendererComponent> (); MacroDefinition mD = new MacroDefinition(); ErrorReportingV2Renderer renderer = new ErrorReportingV2Renderer(rCList, whatshouldcomehere) ; WikiToXhtmlMigrator migr = new WikiToXhtmlMigrator(rC,dLC,dER,vR); //String migrated = new String(); //migrated = migrate(java.lang.String wiki, com.atlassian.renderer.RenderContext context, java.util.List<java.lang.RuntimeException> exceptions) //migrated = migrate(java.lang.String wiki, ConversionContext conversionContext) String migrated = (migr.migrate(wikiContent, dCE)).getContent(); System.out.println(migrated); } }
I'm not sure if this is the right way to do it, and I have no clue as to what each part means because of the abstract way in which everything is defined in the documentation.
Can someone help me with how to initialize ErrorReportingV2Renderer renderer?
Any help would be greatly appreciated.
Thanks
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.