I have the following code:
StringWriter writer = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);
builder.setEmitAsDocument(false);
MediaWikiLanguage lang = new MediaWikiLanguage();
lang.configure(conf);
lang.setInternalLinkPattern("{0}");
MarkupParser parser = new MarkupParser(lang, builder);
parser.parse("''text1''");
System.out.println(writer.toString());
writer.flush();
parser.parse("'''text2'''");
System.out.println(writer.toString());
When parsing second text I get NullPointerException:
Exception in thread "main" java.lang.NullPointerException
at org.eclipse.mylyn.wikitext.core.util.DefaultXmlStreamWriter.writeStartElement(DefaultXmlStreamWriter.java:322)
at org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder.beginBlock(HtmlDocumentBuilder.java:798)
at org.eclipse.mylyn.internal.wikitext.mediawiki.core.block.ParagraphBlock.processLineContent(ParagraphBlock.java:66)
at org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage.processContent(MarkupLanguage.java:184)
at org.eclipse.mylyn.internal.wikitext.mediawiki.core.AbstractMediaWikiLanguage.processContent(AbstractMediaWikiLanguage.java:97)
at org.eclipse.mylyn.wikitext.core.parser.MarkupParser.parse(MarkupParser.java:91)
at org.eclipse.mylyn.wikitext.core.parser.MarkupParser.parse(MarkupParser.java:81)
at html.HtmlLinks.setText(HtmlLinks.java:63)
at javax.swing.JEditorPane.<init>(Unknown Source)
at html.HtmlLinks.<init>(HtmlLinks.java:35)
at html.HtmlLinks.main(HtmlLinks.java:106)
There is no problem when I create new objects each time I want to parse some text. But it's a waste of resources...