Просмотр исходного кода

ZF-8916: Bbcode is not rendered after code tag anymore.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20942 44c647ce-9c0f-0410-b52a-842ac1e357ba
kokx 16 лет назад
Родитель
Сommit
465fdc21c2
2 измененных файлов с 16 добавлено и 1 удалено
  1. 15 0
      library/Zend/Markup/Parser/Bbcode.php
  2. 1 1
      tests/Zend/Markup/BbcodeAndHtmlTest.php

+ 15 - 0
library/Zend/Markup/Parser/Bbcode.php

@@ -125,6 +125,11 @@ class Zend_Markup_Parser_Bbcode implements Zend_Markup_Parser_ParserInterface
             'type'     => self::TYPE_SINGLE,
             'stoppers' => array(),
         ),
+        'code' => array(
+            'type'         => self::TYPE_DEFAULT,
+            'stoppers'     => array('[/code]', '[/]'),
+            'parse_inside' => false
+        )
     );
 
     /**
@@ -372,6 +377,16 @@ class Zend_Markup_Parser_Bbcode implements Zend_Markup_Parser_ParserInterface
                             array(),
                             $this->_current
                         ));
+                    } elseif (isset($this->_tags[$this->_current->getName()]['parse_inside'])
+                        && !$this->_tags[$this->_current->getName()]['parse_inside']
+                    ) {
+                        $this->_current->addChild(new Zend_Markup_Token(
+                            $token['tag'],
+                            Zend_Markup_Token::TYPE_NONE,
+                            '',
+                            array(),
+                            $this->_current
+                        ));
                     } else {
                         // add the tag
                         $child = new Zend_Markup_Token(

+ 1 - 1
tests/Zend/Markup/BbcodeAndHtmlTest.php

@@ -266,7 +266,7 @@ class Zend_Markup_BbcodeAndHtmlTest extends PHPUnit_Framework_TestCase
     public function testFailureAfterCodeTag()
     {
         $input = "[code][b][/code][list][*]Foo[/*][/list]";
-        $expected = "<code>[b]</code><ul><li>Foo</li></ul>";
+        $expected = "<code><span style=\"color: #000000\">\n[b]</span>\n</code><ul><li>Foo</li></ul>";
         $this->assertEquals($expected, $this->_markup->render($input));
     }