Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.3

Request #14401 Improve handling of rendering errors
Submitted: 2008-07-24 21:55 UTC
From: bfuerst Assigned:
Status: Open Package: Text_Wiki (version CVS)
PHP Version: 5.2.0 OS: Debian 4.0
Roadmaps: (Not assigned)    
Subscription  


 [2008-07-24 21:55 UTC] bfuerst (Bernhard Fürst)
Description: ------------ In Wiki.php,v 1.52 2007/12/17 at line 1057 the render process will break if the parser finds 'Unbalanced tokens'. Is there any way to make the render process more tolerant to Wiki syntax errors? BTW: By just commenting out line 1057 I get expected results when rendering wrong Wiki syntax.

Comments

 [2008-07-26 03:10 UTC] doconnor (Daniel O'Connor)
Hey Bernhard, any chance of a small executable test case for this? At the moment, I have no idea what unbalanced tokens are (i don't know text_wiki enough) - but with some simple test script...
 [2008-07-26 10:48 UTC] bfuerst (Bernhard Fürst)
In the example below (the text is from real live) the author forgot to close the first ''' (bold) tag. Text_Wiki::render() returns immediately with an PEAR_Error object. The rendered output up to this point will be lost. Better way would be if render() will return the $output it produced up to the syntax error instead of returning an error object. This way you can help the user to locate the syntax error by just showing the output. An PEAR_Error should be thrown anyway. It can be used to callback a function (configurable using a Text_Wiki setter function) or something other. A second approach can be to throw the error but not breaking the render process. I tried it using one bigger text (using Wikimedia export in Openoffice) and it went well. I checked how the Mediawiki software behaves and it too rendered the whole text at once. I would prefere the second approach but I have no glue which side effects this will have. And here is the example: <?php $text = "=='''A) For all'== =='''B) For you'''== =='''C) For me'''=="; include_once 'Text/Wiki.php'; include_once 'PEAR.php'; $wiki =& Text_Wiki::singleton('Mediawiki'); $wiki->parse($text); $output = $wiki->render(); print_r($output); ?>