@Test public void escapeNewLines() throws Exception { assertEquals("\\a\\\n\\b", this.mocker.getComponentUnderTest().escape("a\nb", Syntax.XWIKI_1_0)); assertEquals("~a~\n~b", this.mocker.getComponentUnderTest().escape("a\nb", Syntax.XWIKI_2_0)); assertEquals("~a~\n~b", this.mocker.getComponentUnderTest().escape("a\nb", Syntax.XWIKI_2_1)); }
public String escape(String content, Syntax syntax) { if (content == null || syntax == null) { return null; } char escapeChar; try { escapeChar = getEscapeCharacter(syntax); } catch (Exception e) { return null; } char[] result = new char[content.length() * 2]; for (int i = 0; i < content.length(); i++) { result[2 * i] = escapeChar; result[2 * i + 1] = content.charAt(i); } return String.valueOf(result); }
RenderingScriptService implements ScriptService { public String escape(String content, Syntax syntax) { if (content == null || syntax == null) { return null; } char escapeChar; try { escapeChar = getEscapeCharacter(syntax); } catch (Exception e) { return null; } char[] result = new char[content.length() * 2]; for (int i = 0; i < content.length(); i++) { result[2 * i] = escapeChar; result[2 * i + 1] = content.charAt(i); } return String.valueOf(result); } }
RenderingScriptService implements ScriptService { public String escape(String content, Syntax syntax) { if (content == null || syntax == null) { return null; } char escapeChar; try { escapeChar = getEscapeCharacter(syntax); } catch (Exception e) { return null; } char[] result = new char[content.length() * 2]; for (int i = 0; i < content.length(); i++) { result[2 * i] = escapeChar; result[2 * i + 1] = content.charAt(i); } return String.valueOf(result); }  }
RenderingScriptService implements ScriptService { public String escape(String content, Syntax syntax) { if (content == null || syntax == null) { return null; } char escapeChar; try { escapeChar = getEscapeCharacter(syntax); } catch (Exception e) { return null; } char[] result = new char[content.length() * 2]; for (int i = 0; i < content.length(); i++) { result[2 * i] = escapeChar; result[2 * i + 1] = content.charAt(i); } return String.valueOf(result); }  List<Syntax> getAvailableParserSyntaxes(); List<Syntax> getAvailableRendererSyntaxes(); List<String> getDefaultTransformationNames(); XDOM parse(String text, String syntaxId); String render(Block block, String outputSyntaxId); Syntax resolveSyntax(String syntaxId); String escape(String content, Syntax syntax); List<Syntax> getConfiguredSyntaxes(); List<Syntax> getDisabledSyntaxes(); List<MacroDescriptor> getMacroDescriptors(Syntax syntax); MacroId resolveMacroId(String macroIdAsString); MacroDescriptor getMacroDescriptor(MacroId macroId); }
RenderingScriptService implements ScriptService { public String escape(String content, Syntax syntax) { if (content == null || syntax == null) { return null; } char escapeChar; try { escapeChar = getEscapeCharacter(syntax); } catch (Exception e) { return null; } char[] result = new char[content.length() * 2]; for (int i = 0; i < content.length(); i++) { result[2 * i] = escapeChar; result[2 * i + 1] = content.charAt(i); } return String.valueOf(result); }  List<Syntax> getAvailableParserSyntaxes(); List<Syntax> getAvailableRendererSyntaxes(); List<String> getDefaultTransformationNames(); XDOM parse(String text, String syntaxId); String render(Block block, String outputSyntaxId); Syntax resolveSyntax(String syntaxId); String escape(String content, Syntax syntax); List<Syntax> getConfiguredSyntaxes(); List<Syntax> getDisabledSyntaxes(); List<MacroDescriptor> getMacroDescriptors(Syntax syntax); MacroId resolveMacroId(String macroIdAsString); MacroDescriptor getMacroDescriptor(MacroId macroId);  }