diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index 1fe39202..d30d89db 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -39,6 +39,7 @@ class BBCode extends FormatterExtension { } $text = preg_replace('!^>>([^\d].+)!', '
$1
', $text); $text = preg_replace('!>>(\d+)(#c?\d+)?!s', '>>$1$2', $text); + $text = preg_replace('!\[anchor=(.*?)\](.*?)\[/anchor\]!s', '$2', $text); // add "bb-" to avoid clashing with eg #top $text = preg_replace('!\[url=site://(.*?)(#c\d+)?\](.*?)\[/url\]!s', '$3', $text); $text = preg_replace('!\[url\]site://(.*?)(#c\d+)?\[/url\]!s', '$1$2', $text); $text = preg_replace('!\[url=((?:https?|ftp|irc|mailto)://.*?)\](.*?)\[/url\]!s', '$2', $text); @@ -77,6 +78,7 @@ class BBCode extends FormatterExtension { ) as $el) { $text = preg_replace("!\[$el\](.*?)\[/$el\]!s", '$1', $text); } + $text = preg_replace("!\[anchor=(.*?)\](.*?)\[/anchor\]!s", '$2', $text); $text = preg_replace("!\[url=(.*?)\](.*?)\[/url\]!s", '$2', $text); $text = preg_replace("!\[img\](.*?)\[/img\]!s", "", $text); $text = preg_replace("!\[\[([^\|\]]+)\|([^\]]+)\]\]!s", '$2', $text); diff --git a/ext/bbcode/test.php b/ext/bbcode/test.php index 14aac004..4e3fd832 100644 --- a/ext/bbcode/test.php +++ b/ext/bbcode/test.php @@ -71,6 +71,12 @@ class BBCodeUnitTest extends UnitTestCase { "spam@shishnet.org"); } + public function testAnchor() { + $this->assertEqual( + $this->filter("[anchor=rules]Rules[/anchor]"), + "Rules"); + } + private function filter($in) { $bb = new BBCode(); return $bb->format($in);