CVS update: /cowiki/includes/cowiki/class/parse/, /cowiki/misc/development/tests/
[email protected] 2 Aug 2005 19:58:02 -0000
| Newsgroups | gmane.comp.php.cowiki.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: cmarble Date: 2005/08/02 12:58:02 Modified: cowiki/includes/cowiki/class/parse/class.WikiReverseParser.php cowiki/includes/cowiki/class/parse/class.WikiParser.php cowiki/misc/development/tests/RunTests.php cowiki/misc/development/tests/class.ParserTest.php Log: Issue number: 236, 237, 238 I grabbed a regex straight from RFC2396 for the URIs that dtg and I were arguing over. Its pretty simplistic now, and I'm expecting teething troubles. Fixes the emphasis-straight-after-uri thing, but it won't deal well with 'mailto:', for one thing. Tell me about it and I'll get to work. #236 was a true coding bug (now fixed) that affects #238. #237 will go away if I'm kept informed (listed STARTED). The invalid character bug is worth an issue to itself- but please let me, cos my hands are dirty already - it promises to be very interesting. Heads up: I'm expecting 238 to disappear. File Changes: Directory: /cowiki/includes/cowiki/class/parse/ =============================================== File [changed]: class.WikiReverseParser.php Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/parse/class.WikiReverseParser.php?r1=1.25&r2=1.26 Delta lines: +10 -4 -------------------- --- class.WikiReverseParser.php 21 Jun 2005 16:37:48 -0000 1.25 +++ class.WikiReverseParser.php 2 Aug 2005 19:57:58 -0000 1.26 @@ -2,7 +2,7 @@ /** * - * $Id: class.WikiReverseParser.php,v 1.25 2005/06/21 16:37:48 cmarble Exp $ + * $Id: class.WikiReverseParser.php,v 1.26 2005/08/02 19:57:58 cmarble Exp $ * * This file is part of coWiki. coWiki is free software under the terms of * the GNU General Public License (GPL). Read the LICENSE file. If you did @@ -17,7 +17,7 @@ * @author Daniel T. Gorski, <[email protected]> * @copyright (C) Daniel T. Gorski, {@link http://www.develnet.org} * @license http://www.gnu.org/licenses/gpl.html - * @version $Revision: 1.25 $ + * @version $Revision: 1.26 $ * */ @@ -349,7 +349,7 @@ $first = false; } } - if($aAttrib['origin'] != 'doubled') { + if(isset($aAttrib['origin']) && $aAttrib['origin'] != 'doubled') { $sStr .= '| '; } } else { @@ -435,7 +435,11 @@ $this->fLink = array(&$this, 'buildIdRefLink'); $this->sLink[1] = $aAttrib['idref']; } + if ( isset($aAttrib['origin'] ) ) { $this->sLink[0] = $aAttrib['origin']; + } else { + $this->sLink[0] = 'round'; + } $this->sLink[2] = ''; break; //subscript & superscript @@ -467,6 +471,7 @@ $this->sContent .= "=="; } break; + case 'strong': case 'b': if(isset($aAttrib['origin']) && $aAttrib['origin']=='html'){ array_push($this->aState,13); @@ -485,6 +490,7 @@ $this->sContent .= "__"; } break; + case 'em': case 'i': if(isset($aAttrib['origin']) && $aAttrib['origin']=='html'){ array_push($this->aState,15); File [changed]: class.WikiParser.php Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/parse/class.WikiParser.php?r1=1.59&r2=1.60 Delta lines: +11 -20 --------------------- --- class.WikiParser.php 27 Jul 2005 22:22:39 -0000 1.59 +++ class.WikiParser.php 2 Aug 2005 19:57:58 -0000 1.60 @@ -2,7 +2,7 @@ /** * - * $Id: class.WikiParser.php,v 1.59 2005/07/27 22:22:39 cmarble Exp $ + * $Id: class.WikiParser.php,v 1.60 2005/08/02 19:57:58 cmarble Exp $ * * This file is part of coWiki. coWiki is free software under the terms of * the GNU General Public License (GPL). Read the LICENSE file. If you did @@ -21,7 +21,7 @@ * @author Daniel T. Gorski, <[email protected]> * @copyright (C) Daniel T. Gorski, {@link http://www.develnet.org} * @license http://www.gnu.org/licenses/gpl.html - * @version $Revision: 1.59 $ + * @version $Revision: 1.60 $ * */ @@ -479,21 +479,6 @@ $sStr, $aMatches )) { if($debug){echo "7b ".$aMatches[1]."\n";} $sRet .= $this->createLinkElement( $aMatches[1], "square" ); - }else if( preg_match( '=^\(\(?[^\(\)]+\)?=Ui', $sStr, $aMatches )) { - if($debug){echo "8\n";} - $sRet .= $aMatches[0]; - }else if( preg_match( '=^\(?[^\(\)]+\)\)?=Ui', $sStr, $aMatches )) { - if($debug){echo "9\n";} - $sRet .= $aMatches[0]; - }else if( preg_match( '=^[^\(\)]+\)\([^\(\)]+=Ui', $sStr, $aMatches )) { - if($debug){echo "10\n";} - $sRet .= $aMatches[0]; - }else if( preg_match( '=^[\(\[]+=Ui', $sStr, $aMatches )) { - if($debug){echo "10.5\n";} - $sRet .= $aMatches[0]; - }else if( preg_match( '=^[\)\]]+=Ui', $sStr, $aMatches )) { - if($debug){echo "10.6\n";} - $sRet .= $aMatches[0]; //WikiWords }else if((($Registry != null && $Registry->get('RUNTIME_WIKIWORDS')) || $Registry == null) @@ -505,14 +490,20 @@ .$aMatches[1],"camel" ); //URIs }else if( preg_match( + /* '=^(http://|https://|ftp://|mailto:|news:) ([-\._A-Z0-9\S]*) (\*\s|\=\s|"|<|>|<|>|\(|\)|\s|$)?? =six', - $sStr, $aMatches )) { + */ + '=^(([A-Za-z]+):)(//([^/?\#\*\(\)\[\]]*))([^?\#\*\(\)\[\]]*)(\?([^\#]*))?(\#(.*))?=six' ,$sStr, $aMatches )) { if($debug){echo "12\n";} + /* $sRet .= '<uri strref="' . $aMatches[1].$aMatches[2] . '"/>'; + */ + $sRet .= '<uri strref="' . + $aMatches[0] . '"/>'; /* }else if( preg_match( '=^<plugin +([A-Za-z0-9_.]+)( +([^&]*))?(/?)>=i', $sStr, $aMatches )) { @@ -649,9 +640,9 @@ if($debug){echo "16 unknown ".$aMatches[0]."\n";} $sRet .= $aMatches[0]; /* - }else if( preg_match( '#^((([-=\*_/]{1})(?!\3))|[^-=\*_&%\(\[]|(&?!l))#Ui', + }else if( preg_match( '#^((([-=\*_/]{1})(?!\3))|[^-=\*_&%\(\[]|(&?!l))#i', */ - }else if( preg_match( '#^((([-=\*_/]{1})(?!\3))|[^-=\*_&%\(\[]|&(?!l))#i', + }else if( preg_match( '#^((([-=\*_/]{1})(?!\3))|[^-=\*_&%]|&(?!l))#i', $sStr, $aMatches ) ) { if($debug){echo "17 ".$aMatches[0]."\n";} $sRet .= $aMatches[0]; Directory: /cowiki/misc/development/tests/ ========================================== File [changed]: RunTests.php Url: http://cowiki.tigris.org/source/browse/cowiki/misc/development/tests/RunTests.php?r1=1.6&r2=1.7 Delta lines: +5 -6 ------------------- --- RunTests.php 21 Jun 2005 16:37:48 -0000 1.6 +++ RunTests.php 2 Aug 2005 19:57:58 -0000 1.7 @@ -1,7 +1,7 @@ <?php /** * - * $Id: RunTests.php,v 1.6 2005/06/21 16:37:48 cmarble Exp $ + * $Id: RunTests.php,v 1.7 2005/08/02 19:57:58 cmarble Exp $ * * This file is part of coWiki. coWiki is free software under the terms of * the GNU General Public License (GPL). Read the LICENSE file. If you did @@ -16,7 +16,7 @@ * @author Paul Hanchett <[email protected]> * @copyright (C) Paul Hanchett, 2005 * @license http://www.gnu.org/licenses/gpl.html - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * */ // @@ -27,8 +27,7 @@ $suite = new PHPUnit_TestSuite(); $result = new PHPUnit_TestResult(); $result->addListener(new ConsoleListener); - - +//foo $suite->addTestSuite(ParserBasicFormattingTest); $suite->addTestSuite(ParserBoldAsteriskFormattingTest); @@ -53,17 +52,17 @@ $suite->addTestSuite(ParserBadTagFormattingTest); - $suite->addTestSuite(ParserNoopTagFormattingTest); $suite->addTestSuite(ParserRemTagFormattingTest); $suite->addTestSuite(ParserCodeTagFormattingTest); - $suite->addTestSuite(ParserPreTagFormattingTest); + $suite->addTestSuite(ParserPostingTagFormattingTest); $suite->addTestSuite(ParserQTagFormattingTest); $suite->addTestSuite(ParserOtherProcessContentFormattingTest); $suite->addTestSuite(ParserOtherParseFormattingTest); +//bar //$suite->addTestSuite(ParserBlockFormattingTest); File [changed]: class.ParserTest.php Url: http://cowiki.tigris.org/source/browse/cowiki/misc/development/tests/class.ParserTest.php?r1=1.6&r2=1.7 Delta lines: +26 -19 --------------------- --- class.ParserTest.php 21 Jun 2005 16:37:48 -0000 1.6 +++ class.ParserTest.php 2 Aug 2005 19:57:58 -0000 1.7 @@ -1,7 +1,7 @@ <?php /** * - * $Id: class.ParserTest.php,v 1.6 2005/06/21 16:37:48 cmarble Exp $ + * $Id: class.ParserTest.php,v 1.7 2005/08/02 19:57:58 cmarble Exp $ * * This file is part of coWiki. coWiki is free software under the terms of * the GNU General Public License (GPL). Read the LICENSE file. If you did @@ -16,7 +16,7 @@ * @author Paul Hanchett <[email protected]> * @copyright (C) Paul Hanchett, 2005 * @license http://www.gnu.org/licenses/gpl.html - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * */ @@ -735,6 +735,16 @@ ParserGreedyTagFormattingTest :: __construct($name, "Code", "<code>", "</code>", '<code>', "</code>", "<b>", "</b>", '<b origin="html">', '</b>' ); } } +//-------------------------------------------------------------------------- +// <pre>: Pre-formatted tag for text within a paragraph +//-------------------------------------------------------------------------- +class ParserPreTagFormattingTest extends ParserGreedyTagFormattingTest +{ + function __construct($name) + { + ParserGreedyContentTagFormattingTest :: __construct($name, "Pre", "<pre>", "</pre>", '<pre>', "</pre>", "<b>", "</b>", '<b origin="html">', '</b>' ); + } +} //-------------------------------------------------------------------------- // Basic tests for formatting text within <tags> within paragraphs @@ -946,16 +956,6 @@ //-------------------------------------------------------------------------- -// <pre>: Pre-formatted tag for text within a paragraph -//-------------------------------------------------------------------------- -class ParserPreTagFormattingTest extends ParserGreedyContentTagFormattingTest -{ - function __construct($name) - { - ParserGreedyContentTagFormattingTest :: __construct($name, "Pre", "<pre>", "</pre>", '<pre>', "</pre>", "<b>", "</b>", '<b origin="html">', '</b>' ); - } -} -//-------------------------------------------------------------------------- // <posting>: Posting-formatted tag for text within a paragraph //-------------------------------------------------------------------------- class ParserPostingTagFormattingTest extends ParserGreedyContentTagFormattingTest { @@ -1001,6 +1001,7 @@ //-------------------------------------------------------------------------- // <br/> (must include slash) //-------------------------------------------------------------------------- + //foo function testLineBreak() { $inputString = "A line<br/>-break"; @@ -1054,31 +1055,32 @@ $this->assertEquals($outputString, $this->p->parse($inputString)); $this->assertEquals(trim($inputString), trim($this->r->parse($outputString))); } - + //bar //-------------------------------------------------------------------------- // links //-------------------------------------------------------------------------- function testBrokenLinkSyntax1() { $inputString = "A ((http://www.google.co.uk)\n(Alias)) test"; - $outputString = '<p>A ((http://www.google.co.uk)</p><p>(Alias)) test</p>'; + $outputString = '<p>A ((<uri strref="http://www.google.co.uk"/>)</p><p>(Alias)) test</p>'; $this->assertEquals($outputString, $this->p->parse($inputString)); $this->assertEquals(trim($inputString), trim($this->r->parse($outputString))); } function testBrokenLinkSyntax2() { $inputString = "A ((http://www.goo\ngle.co.uk)(Alias)) test"; - $outputString = '<p>A ((http://www.goo</p><p>gle.co.uk)(Alias)) test</p>'; + $outputString = '<p>A ((<uri strref="http://www.goo"/></p><p>gle.co.uk)(Alias)) test</p>'; $this->assertEquals($outputString, $this->p->parse($inputString)); $this->assertEquals(trim($inputString), trim($this->r->parse($outputString))); } function testBrokenLinkSyntax3() { $inputString = "A ((http://www.google.co.uk)(Al\nias)) test"; - $outputString = '<p>A ((http://www.google.co.uk)(Al</p><p>ias)) test</p>'; + $outputString = '<p>A ((<uri strref="http://www.google.co.uk"/>)(Al</p><p>ias)) test</p>'; $this->assertEquals($outputString, $this->p->parse($inputString)); $this->assertEquals(trim($inputString), trim($this->r->parse($outputString))); } + //foo function testUriLinkElement() { $inputString = 'A ((http://www.google.co.uk)(Alias)) test'; @@ -1130,6 +1132,7 @@ $this->assertEquals($outputString, $this->p->parse($inputString)); $this->assertEquals(trim($inputString), trim($this->r->parse($outputString))); } + //bar function testURIBrokenElement() { $inputString = "text http://co\nwiki.tigris.org"; @@ -1140,11 +1143,11 @@ function testURIBrokenElement2() { $inputString = "text ht\ntp://cowiki.tigris.org"; - $outputString = '<p>text ht</p><p>tp://cowiki.tigris.org</p>'; + $outputString = '<p>text ht</p><p><uri strref="tp://cowiki.tigris.org"/></p>'; $this->assertEquals($outputString, $this->p->parse($inputString)); $this->assertEquals(trim($inputString), trim($this->r->parse($outputString))); } - + //foo //-------------------------------------------------------------------------- // plugins //-------------------------------------------------------------------------- @@ -1198,6 +1201,7 @@ $this->assertEquals($outputString, $this->p->parse($inputString)); $this->assertEquals(trim($inputString), trim($this->r->parse($outputString))); } + //bar } //-------------------------------------------------------------------------- @@ -1550,11 +1554,14 @@ function testBlock() { $inputString = <<<EOD -CamelCase becomes a link +**http://www.google.co.uk** EOD; $outputString = '??'; $this->assertEquals($outputString, $this->p->parse($inputString)); $this->assertEquals(trim($inputString),trim($this->r->parse($outputString))); } } + +//foo +//bar ?>