Re: BBCodeParser massive update (/me cries)
| From: | bertrand Gugger | Date: | Wed, 28 Sep 2005 02:33:38 +0000 |
| Subject: | Re: BBCodeParser massive update (/me cries) | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-39948@lists.php.net to get a copy of this message | ||
Bonsoir,
Just a first quick answer as I must go in bed.
Yes, the plan is still to replace HTML_BBCodeparser by the Text_Wiki solution.
Text_Wiki_BBCode was released as planned.
You find the sketch of the replacement in http://cvs.php.net/pear/Text_Wiki/doc/README_BBCodeParser
The example there is whole functionning.
Anyway, we need another zero-config example without all the extensions enabled by Text_Wiki.
I'll care of it, will be in HTML_BBCodeParser I imagine
I'm peculiarly interested to have some help / other maintainers in it, I don't mean your developments are loosed, even if I'm no PHPUnit fanatic.
(tsk tsk ... you should check the list too )
I will review your code very soon and come back to you.
à+
--
bertrand "toggg" Gugger
Seth Price wrote:
> So, I just spent a few days working on BBCodeParser, in part to make
> it more bullet proof for my own website. I'm almost done.
> - It can clean up some fairly painful BBCode.
> - It produces XHTML 1.1
> - It is backwards compatible with older BBCode (although two things
> aren't supported in XHTML 1.1 without javascript; I'm ignoring those
> attributes)
> - It fixes most of the bugs listed on the package home page.
>
> Then, on a whim, I checked the pear-dev list. I read that you are
> scrapping it. You guys should really mention things like this on the
> package's home page. Should I continue to work on BBCodeParser or
> will it be obsoleted anyway? Also, is the wiki parser stack based?
>
> I was just about to make some finishing touches to make it fully
> XHTML 1.1 compliant, start to make it configurable "on the fly", and
> maybe add a smilies filter. You can download the current version that
> I'm working on here and see how it is:
> http://pricepages.org/bbcode/BBCodeParser.zip
>
> Here is a list of test cases that it currently passes. Can the
> current wiki parser make sense of these? I'm particularly happy with
> my list parsing, although I've spent quite a while refining the URL
> code.
>
> function emailBBCode($bbc, $funcNam){
> $this->assertEquals('<a
> href="mailto:guest@anonymous.org">guest@anonymous.org</a>',
$bbc->
> $funcNam('guest@anonymous.org'));
> $this->assertEquals('<a href="mailto:guest@anonymous.org">mail
> me</a>', $bbc->$funcNam('[email=guest@anonymous.org]mail me[/email]'));
> $this->assertEquals('<a
> href="mailto:guest@anonymous.org">guest@anonymous.org</a>',
$bbc->
> $funcNam('[email]guest@anonymous.org[/email]'));
> }
>
> function imgBBCode($bbc, $funcNam){
> $this->assertEquals('<img src="img.jpg" />', $bbc->$funcNam
> ('[img]img.jpg[/img]'));
> $this->assertEquals('<img src="http://www.server.org/image.jpg"
> width="100" height="200" />', $bbc->$funcNam('[img w=100
h=200]http://
> www.server.org/image.jpg[/img]'));
> }
>
> function basicBBCode($bbc, $funcNam){
> $this->assertEquals('<strong>txt</strong>',
$bbc->$funcNam('[b]
> txt[/b]'));
> $this->assertEquals('<em>txt</em>',
$bbc->$funcNam('[i]txt[/i]'));
> $this->assertEquals('<em>txt</em>',
$bbc->$funcNam('[i]txt[/I]'));
> $this->assertEquals('<em>txt</em>',
$bbc->$funcNam('[I]txt[/i]'));
> $this->assertEquals('<em>txt</em>',
$bbc->$funcNam('[I]txt[/I]'));
> $this->assertEquals('<del>txt</del>',
$bbc->$funcNam('[s]txt[/ s]'));
> $this->assertEquals('<span style="text-
> decoration:underline;">txt</span>',
$bbc->$funcNam('[u]txt[/u]'));
> $this->assertEquals('<sub>txt</sub>',
$bbc->$funcNam('[sub]txt[/
> sub]'));
> $this->assertEquals('<sup>txt</sup>',
$bbc->$funcNam('[sup]txt[/
> sup]'));
> $this->assertEquals('<sup><sub>txt</sub></sup>',
$bbc->$funcNam
> ('[sup][sub]txt[/sup][/sub]'));
> }
>
> function listBBCode($bbc, $funcNam){
> $this->assertEquals('<ul><li>txt</li></ul>',
$bbc->$funcNam('[*]
> txt'));
> $this->assertEquals("<ul><li>txt\n</li></ul>",
$bbc->$funcNam
> ("[ulist][*]txt\n[/ulist]"));
> $this->assertEquals('<ul><li>txt</li></ul>',
$bbc->$funcNam
> ('[ulist]txt[/ulist]'));
>
$this->assertEquals('<ul><li><ul><li><ul><li>txt</li></ul></li></
> ul></li></ul>', $bbc->$funcNam('[ulist][ulist][ulist]txt'));
>
$this->assertEquals('<ul><li>[xxx]txt[/xxx]</li></ul>',
$bbc->
> $funcNam('[ulist][xxx]txt[/xxx][/ulist]'));
> $this->assertEquals('<ul><li>txt</li></ul>',
$bbc->$funcNam
> ('[ulist][li]txt[/li][/ulist]'));
>
$this->assertEquals('<ul><li>txt</li><li>txt</li></ul>',
$bbc->
> $funcNam('[ulist][li]txt[li]txt[/ulist]'));
> $this->assertEquals('<ul><li>txt</li></ul>',
$bbc->$funcNam
> ('[ulist][*]txt[/ulist]'));
>
$this->assertEquals('<ul><li><ol><li>txt</li></ol></li></ul>',
> $bbc->$funcNam('[ulist][*][list][*]txt[/ulist]'));
> $this->assertEquals('<ol><li>txt</li></ol>',
$bbc->$funcNam
> ('[list][li]txt[/li][/list]'));
>
$this->assertEquals('<ul><li><ol><li>txt</li></ol></li></ul>',
> $bbc->$funcNam('[li][list][li]txt[/li][/list]'));
>
$this->assertEquals('<ul><li>txt<ul><li>txt</li></ul></li></
ul>',
> $bbc->$funcNam('[*]txt[ulist]txt[/ulist]'));
>
$this->assertEquals('<ul><li><ul><li><ul><li><ul><li>txt</li></
> ul></li></ul></li></ul></li></ul>',
$bbc->$funcNam('[li][ulist][ulist]
> [ulist]txt'));
> $this->assertEquals(
> '<ol style="list-style-type:upper-alpha;"><li>ordered item
1,
> nested list:<ol style="list-style-type:upper-roman;"><li>nested item
> 1</li><li>nested item 2</li></ol></li><li>ordered item
2</li></ ol>',
> $bbc->$funcNam('[list=A s=3][li]ordered item 1, nested list:
> [list=I][li]nested item 1[/li][li]nested item 2[/li][/list][/li][li]
> ordered item 2[/li][/list]'));
> $this->assertEquals(
> '<ol style="list-style-type:upper-alpha;"><li>ordered item 1
> type A</li><li>ordered item 12 type A</li></ol>',
> $bbc->$funcNam('[list=A][li]ordered item 1 type A[/li][li=12]
> ordered item 12 type A[/li][/list]'));
> $this->assertEquals(
> '<ol style="list-style-type:lower-alpha;"><li>ordered item 5
> type a</li><li>ordered item 6 type a</li></ol>',
> $bbc->$funcNam('[list=a s=5][li]ordered item 5 type a[/li][*]
> ordered item 6 type a[/list]'));
> $this->assertEquals(
> '<ol style="list-style-type:upper-roman;"><li>ordered item 1
> type I</li></ol>',
> $bbc->$funcNam('[list=I][*]ordered item 1 type I[/list]'));
> $this->assertEquals(
> '<ol style="list-style-type:lower-roman;"><li>ordered item 1
> type i</li><li>ordered item 4 type i</li></ol>',
> $bbc->$funcNam('[list=i][*]ordered item 1 type i[li=4] ordered
> item 4 type i[/li][/list]'));
> $this->assertEquals(
> '<ol style="list-style-type:decimal;"><li>ordered item
1</
> li><li>ordered item 2</li></ol>',
> $bbc->$funcNam('[list=1][*]ordered item 1[*]ordered item 2[/
> list]'));
> }
>
> function linkBBCode($bbc, $funcNam){
> $this->assertEquals(
> '<a href="http://www.test.com/">http://www.test.com/</a>',
> $bbc->$funcNam('http://www.test.com/'));
> $this->assertEquals(
> '<a href="http://www.test.com/">www.test.com</a>',
> $bbc->$funcNam('[url]www.test.com[/url]'));
> $this->assertEquals(
> '<a href="http://www.test.com/testurl">http://www.test.com/
> testurl</a>',
> $bbc->$funcNam('[url]http://www.test.com/testurl[/url]'));
> $this->assertEquals(
> '<a href="http://www.test.com/">testurl</a>',
> $bbc->$funcNam('[url=www.test.com/]testurl[/url]'));
> $this->assertEquals(
> '<a href="http://www.server.org">server</a>',
> $bbc->$funcNam('[url=http://www.server.org
t=new]server[/
> url]'));
> $this->assertEquals(
> 'txt <a href="http://www.test.com/">www.test.com</a>
txt',
> $bbc->$funcNam('txt www.test.com txt'));
> $this->assertEquals(
> 'txt <em><a href="http://www.test.com/">www.test.com</a></
em>
> txt',
> $bbc->$funcNam('txt [i]www.test.com[/i] txt'));
> $this->assertEquals(
> 'Click here',
> $bbc->$funcNam('[url=javascript:location.replace
> ("bad_link");]Click here[/url]'));
> $this->assertEquals(
> '<a href="http://domain.com/index.php?i=1&j=2">linked
> text</a>',
> $bbc->$funcNam('[url=http://domain.com/index.php?i=1&j=2]
> linked text[/url]'));
> }
>
> function extBBCode($bbc, $funcNam){
> $this->assertEquals('<h2>txt</h2>',
$bbc->$funcNam('[h2]txt[/ h2]'));
> $this->assertEquals('<span style="color:blue">blue
text</span>',
> $bbc->$funcNam('[color=blue]blue text[/color]'));
> $this->assertEquals('<span style="font-size:18pt">the size of
> this text is 18pt</span>', $bbc->$funcNam('[size=18]the size of this
> text is 18pt[/size]'));
> $this->assertEquals('<span style="font-family:arial">different
> font type</span>', $bbc->$funcNam('[font=arial]different font type[/
> font]'));
> $this->assertEquals('<div style="text-align:right">yes,
you\'re
> right, this isn\'t on the left</div>', $bbc->$funcNam('[align=right]
> yes, you\'re right, this isn\'t on the left[/align]'));
> $this->assertEquals('he said: <q cite="http://www.server.org/
> quote.html">i\'m tony montana</q>', $bbc->$funcNam('he said:
> [quote=http://www.server.org/quote.html]i\'m
tony montana[/quote]'));
> $this->assertEquals('<code>x + y = 6;</code>', $bbc->$funcNam
> ('[code]x + y = 6;[/code]'));
> }
>
> function baseHtmlEsc($bbc, $funcNam){
> $this->assertEquals('<', $bbc->$funcNam('<'));
> $this->assertEquals('>', $bbc->$funcNam('>'));
> $this->assertEquals('"', $bbc->$funcNam('"'));
> }
>