I have mediawiki format text for wikipedia article on Speed
<https://en.wikipedia.org/wiki/Speed> I used xwiki libaries to convert
but the conversion to HTML5 is very poor. This is the code I used:
try {
String str = FileUtils.readFileToString(new
File("SpeedwikiText.txt"), "UTF-8");
// XWIKI
// Initialize Rendering components and allow getting instances
EmbeddableComponentManager componentManager = new
EmbeddableComponentManager();
componentManager.initialize(this.getClass().getClassLoader());
// Get the MediaWiki Parser
Parser parser = componentManager.getInstance(Parser.class,
"mediawiki/1.0");
// Parse the content in mediawiki markup and generate an AST (it's also
possible to use a streaming parser for large content)
XDOM xdom = parser.parse(new StringReader(str))
// Generate XHTML out of the modified XDOM
WikiPrinter printer = new DefaultWikiPrinter();
BlockRenderer renderer =
componentManager.getInstance(BlockRenderer.class, "html/5.0" ) ; //
"xhtml/1.0");
renderer.render(xdom, printer);
// The result is now in the printer object
FileUtils.writeStringToFile(
new File("xwiki" + name + ".html"),
printer.toString());
} catch(Exception e) {
System.out.println(e.getMessage());
}
There are many issues:
math symbols or formula are not converted and the html output is something
like
v = \\frac{d}{t},</math> where <math>v</math> is speed.
Top header is missing. (Speed)
tables are not formatted properly.
References section is incomplete.
Ideally I would HTML to exactly look like in wikipedia including images
where image links are pointing to images hosted on wikimedia and are display
in the same location as in wikipedia. Is this achievable and what do I need
to need in above code?
Thanks
--
View this message in context:
http://xwiki.475771.n2.nabble.com/convert-mediawiki-article-on-wikipedia-to…
Sent from the XWiki- Users mailing list archive at
Nabble.com.