Doesn't convert bbcode within url tags
Been looking for a good bbcode to html parser and so far SBBCodeParser has passed all the tests except it doesn't seem to parse bbcode inside [url] tags.... ie;
[url=http://moo.com][color=#9966ff]a colored text link[/color][/url]
is converted to:
<a href="http://moo.com">[color=#9966ff]a colored text link[/color]</a>
and..
[url=http://moo.com][b]a bold text link[/b][/url]
is converted to:
<a href="http://moo.com">[b]a bold text link[/b]</a>
I found the solution go to "classes/Node/Container/Document.php" and change the url Tag (starting from the line 564) to the following code :
new BBCode('url', function($content, $attribs, $node)
{
if(empty($attribs['default']))
$attribs['default'] = $content;
// add http:// to www starting urls
if(strpos($attribs['default'], 'www') === 0)
$attribs['default'] = 'http://' . $attribs['default'];
// add the base url to any urls not starting with http or ftp as they must be relative
else if(substr($attribs['default'], 0, 4) !== 'http'
&& substr($attribs['default'], 0, 3) !== 'ftp')
$attribs['default'] = $node->root()->get_base_uri() . $attribs['default'];
return '<a href="'.$attribs['default'].'">' . $content . '</a>';
})
Thanks for your post, but I ended up using NBBC instead :) One of the reasons being that this repo is no longer maintained - no commits in over 3 years now.
Good , but is there some problems in the NBBC parser ?
No major issues that I can recall - it's a pretty solid parser, but not sure if it's maintained anymore either, but is built well and is very flexible.