I discovered an interesting MyLyn subproject today. It's called WikiText and let you parse common Wiki markup like Textile. You can easily generate an HTML output of a simple text with it:
Textile excerpt
h1. Congratulations!
You read a *textile* document.
Java code
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;
import org.eclipse.mylyn.wikitext.textile.core.TextileLanguage;
// ... skip ...
private String textileToHtml(CharSequence source) {
MarkupParser parser = new MarkupParser(new TextileLanguage());
return parser.parseToHtml(String.valueOf(source));
}
// ... skip ...
Result in HTML
<?xml version='1.0' encoding='utf-8' ?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<h1 id="Bravo">Congratulations!</h1>
<p>You read a <strong>textile</strong> documentation.</p>
</body>
</html>
Currently supported format:
- Confluence
- MediaWiki
- TracWiki
- TWiki
The project page also mentions that it should be easy to add new format to those parser. At this time, the only output format is HTML. Some other format are planned like Eclipse help format or DocBook.
WikiText is the kind of libs that should be a project on its own more than a small lib into a big framework. For now it benefits from a separate bundle which let you download it without the MyLyn stuff. But if no other client depends on it, it may disappear in MyLyn.
Recent Comments