Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
9.0
-
None
Description
CONTEXT:
Using the converter documented here :
- http://rendering.xwiki.org/xwiki/bin/view/Main/GettingStarted#HRenderXWikiSyntax2.0contentintoXHTML
- for confluence format
I've encountered an issue with code inside panel.
The Confluence syntax :
* {panel}{code}code{code}{panel}
Should convert to (with may be some CR/LF):
* {{panel}}{{code}}code{{/code}}{{/panel}}
But returns
* {{panel}}{code}code{code}{{/panel}}
The code:
public static String transformContent(String content) throws Exception { EmbeddableComponentManager ecm = new EmbeddableComponentManager(); ecm.initialize(Thread.currentThread().getContextClassLoader()); Converter converter = ecm.lookup(Converter.class); WikiPrinter printer = new DefaultWikiPrinter(); converter.convert(new StringReader(content), Syntax.CONFLUENCE_1_0, Syntax.XWIKI_2_0, printer); return printer.toString(); }
The test (JUnit 3.8):
import junit.framework.TestCase; public class SyntaxTransformerTest extends TestCase { public void testPanel() { assertTransformTest("{panel}panel{panel}", "{{panel}}\npanel\n{{/panel}}"); } public void testPanelAndCode() { assertTransformTest("{panel}panel{code}code{code}panel{panel}", "{{panel}}\npanel{{code}} code {{/code}}\n{{/panel}}"); } public void testCode() { assertTransformTest("{code}code{code}", "{{code}}\ncode\n{{/code}}"); } public void assertTransformTest(String content, String expected) { final String result = SyntaxTransformer.transformContent(content); assertEquals(expected, result); }