public static String extractPlainText(String wikiMarkup) { MarkupParser parser = new MarkupParser(); parser.setMarkupLanguage(new MediaWikiLanguage()); PlaintextDocumentBuilder builder = new PlaintextDocumentBuilder(); parser.setBuilder(builder); parser.parse(wikiMarkup); return builder.getResult(); }
public static String convert(String contents) { StringWriter writer = new StringWriter(); HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer); builder.setEmitAsDocument(false); MarkupParser parser = new MarkupParser(new SlippLanguage()); parser.setBuilder(builder); parser.parse(contents); return writer.toString(); }
@Test public void parse() throws Exception { String source = "!1234!"; StringWriter writer = new StringWriter(); HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer); builder.setEmitAsDocument(false); MarkupParser parser = new MarkupParser(new SlippLanguage()); parser.setBuilder(builder); parser.parse(source); System.out.println(writer.toString()); }