Ticket #39 (new enhancement)

Opened 2 years ago

Last modified 2 years ago

Rework BBCode parser

Reported by: Connor Assigned to: Shawn
Priority: normal Milestone: 1.3
Component: general Version: 1.2.*
Severity: major Keywords:
Cc:

Description (Last modified by Connor)

http://forums.punbb.org/viewtopic.php?pid=58105#p58105
http://forums.punbb.org/viewtopic.php?pid=59733#p59733
http://forums.punbb.org/viewtopic.php?pid=59967#p59967

List tags (detailed discussion in forum),
The overall goals of a list system (imho) are:
1. Simple lists where each item is one line of text should be simple.
2. More complicated lists where each item can contain several paragraphs, possibly with images and code samples, should not be very much more complicated.
3. Nesting of lists should be simple.
4. The markup generated by the list system should not insert unecessary <br> elements. It should allow users to use newlines in their list code.
5. Users should get back exactly what they put in when editing posts which contain lists.
From Smartys: http://forums.punbb.org/viewtopic.php?id=13625 I've tested this and it looks like simply having URLs parsed before any text formatting is enough to fix the issue :)

So the fix would be in parser.php (in this fix I moved bold/underline/italics after email as well: I don't think it's possible to mess up the layout with email, but I figure it's better to be safe than sorry)

FIND

        $pattern = array('#\[b\](.*?)\[/b\]#s',
                                         '#\[i\](.*?)\[/i\]#s',
                                         '#\[u\](.*?)\[/u\]#s',
                                         '#\[url\]([^\[]*?)\[/url\]#e',
                                         '#\[url=([^\[]*?)\](.*?)\[/url\]#e',
                                         '#\[email\]([^\[]*?)\[/email\]#',
                                         '#\[email=([^\[]*?)\](.*?)\[/email\]#',
                                         '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s');

        $replace = array('<strong>$1</strong>',
                                         '<em>$1</em>',
                                         '<span class="bbu">$1</span>',
                                         'handle_url_tag(\'$1\')',
                                         'handle_url_tag(\'$1\', \'$2\')',
                                         '<a href="mailto:$1">$1</a>',
                                         '<a href="mailto:$1">$2</a>',
                                         '<span style="color: $1">$2</span>');

REAPLACE WITH

        $pattern = array('#\[url\]([^\[]*?)\[/url\]#e',
                                         '#\[url=([^\[]*?)\](.*?)\[/url\]#e',
                                         '#\[email\]([^\[]*?)\[/email\]#',
                                         '#\[email=([^\[]*?)\](.*?)\[/email\]#',
                                         '#\[b\](.*?)\[/b\]#s',
                                         '#\[i\](.*?)\[/i\]#s',
                                         '#\[u\](.*?)\[/u\]#s',
                                         '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s');

        $replace = array('handle_url_tag(\'$1\')',
                                         'handle_url_tag(\'$1\', \'$2\')',
                                         '<a href="mailto:$1">$1</a>',
                                         '<a href="mailto:$1">$2</a>',
                                         '<strong>$1</strong>',
                                         '<em>$1</em>',
                                         '<span class="bbu">$1</span>',
                                         '<span style="color: $1">$2</span>');

Change History

11/21/06 11:19:03 changed by Connor

  • description changed.

11/21/06 11:19:36 changed by Connor

  • description changed.

11/21/06 11:20:03 changed by Connor

  • description changed.

11/21/06 17:40:57 changed by Connor

  • owner changed from Connor to Shawn.

01/03/07 15:45:57 changed by Rickard