I am reposting this as I am not sure if registered user on XWiki-Users forum
can see it. Kindly request from registered XWiki-Users forum user to reply a
blank message to confirm.


I have mediawiki format text for wikipedia article on 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 like HTML to be 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? 




--
View this message in context: 
http://xwiki.475771.n2.nabble.com/how-to-convert-mediawiki-article-on-wikipedia-to-html5-tp7598134.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to