/**
  * Prepare the parsing of a bbcode string, the real parsing is done in {@link _parse()}
  *
  * @param  string $value
  * @return Zend_Markup_TokenList
  */
 public function parse($value)
 {
     if (!is_string($value)) {
         /**
          * @see Zend_Markup_Parser_Exception
          */
         require_once 'Zend/Markup/Parser/Exception.php';
         throw new Zend_Markup_Parser_Exception('Value to parse should be a string.');
     }
     if (empty($value)) {
         /**
          * @see Zend_Markup_Parser_Exception
          */
         require_once 'Zend/Markup/Parser/Exception.php';
         throw new Zend_Markup_Parser_Exception('Value to parse cannot be left empty.');
     }
     $this->_value = str_replace(array("\r\n", "\r", "\n"), self::NEWLINE, $value);
     // variable initialization for tokenizer
     $this->_valueLen = strlen($this->_value);
     $this->_pointer = 0;
     $this->_buffer = '';
     $this->_temp = array();
     $this->_state = self::STATE_SCAN;
     $this->_tokens = array();
     $this->_tokenize();
     // variable initialization for treebuilder
     $this->_searchedStoppers = array();
     $this->_tree = new Zend_Markup_TokenList();
     $this->_current = new Zend_Markup_Token('', Zend_Markup_Token::TYPE_NONE, 'Zend_Markup_Root');
     $this->_tree->addChild($this->_current);
     $this->_createTree();
     return $this->_tree;
 }
 /**
  * Prepare the parsing of a Textile string, the real parsing is done in {@link _parse()}
  *
  * @param string $value
  *
  * @return array
  */
 public function parse($value)
 {
     if (!is_string($value)) {
         /**
          * @see Zend_Markup_Parser_Exception
          */
         require_once 'Zend/Markup/Parser/Exception.php';
         throw new Zend_Markup_Parser_Exception('Value to parse should be a string.');
     }
     if (empty($value)) {
         /**
          * @see Zend_Markup_Parser_Exception
          */
         require_once 'Zend/Markup/Parser/Exception.php';
         throw new Zend_Markup_Parser_Exception('Value to parse cannot be left empty.');
     }
     // first make we only have LF newlines, also trim the value
     $this->_value = str_replace(array("\r\n", "\r"), "\n", $value);
     $this->_value = trim($this->_value);
     // initialize variables and tokenize
     $this->_valueLen = iconv_strlen($this->_value, 'UTF-8');
     $this->_pointer = 0;
     $this->_buffer = '';
     $this->_temp = array();
     $this->_tokens = array();
     $this->_tokenize();
     // create the tree
     $this->_tree = new Zend_Markup_TokenList();
     $this->_current = new Zend_Markup_Token('', Zend_Markup_Token::TYPE_NONE, 'Zend_Markup_Root');
     $this->_tree->addChild($this->_current);
     $this->_createTree();
     return $this->_tree;
 }
 /**
  * Parse a string
  *
  * @param  string $value
  * @return Zend_Markup_TokenList
  */
 public function parse($value)
 {
     if (!is_string($value)) {
         /**
          * @see Zend_Markup_Parser_Exception
          */
         require_once 'Zend/Markup/Parser/Exception.php';
         throw new Zend_Markup_Parser_Exception('Value to parse should be a string.');
     }
     if (empty($value)) {
         /**
          * @see Zend_Markup_Parser_Exception
          */
         require_once 'Zend/Markup/Parser/Exception.php';
         throw new Zend_Markup_Parser_Exception('Value to parse cannot be left empty.');
     }
     // initialize variables
     $tree = new Zend_Markup_TokenList();
     $current = new Zend_Markup_Token('', Zend_Markup_Token::TYPE_NONE, 'Zend_Markup_Root');
     $tree->addChild($current);
     $token = new Zend_Markup_Token($value, Zend_Markup_Token::TYPE_NONE, '', array(), $current);
     $current->addChild($token);
     return $tree;
 }