示例#1
0
 protected function _parseContent($options = array())
 {
     switch ($this->_content_syntax) {
         case framework\Settings::SYNTAX_MD:
             $parser = new \thebuggenie\core\helpers\TextParserMarkdown();
             $text = $parser->transform($this->_content);
             break;
         case framework\Settings::SYNTAX_PT:
             $options = array('plain' => true);
         case framework\Settings::SYNTAX_MW:
         default:
             $parser = new \thebuggenie\core\helpers\TextParser($this->_content, true, $this->getID());
             foreach ($options as $option => $value) {
                 $parser->setOption($option, $value);
             }
             $text = $parser->getParsedText();
             break;
     }
     if (isset($parser)) {
         $this->_parser = $parser;
     }
     return $text;
 }
示例#2
0
 protected function _retrieveLinksAndCategoriesFromContent($options = array())
 {
     $parser = new \thebuggenie\core\helpers\TextParser(html_entity_decode($this->_content));
     $options['no_code_highlighting'] = true;
     $parser->doParse($options);
     return array($parser->getInternalLinks(), $parser->getCategories());
 }
/**
 * Return parsed text, based on provided syntax and options
 *
 * @param string $text The text that should be parsed
 * @param boolean $toc [optional] Whether a TOC should be generated and included
 * @param mixed $article_id [optional] An article id to use as an element id prefix
 * @param array $options [optional] Parser options
 * @param integer $syntax [optional] Which parser syntax to use
 *
 * @return string
 */
function tbg_parse_text($text, $toc = false, $article_id = null, $options = array(), $syntax = \thebuggenie\core\framework\Settings::SYNTAX_MW)
{
    switch ($syntax) {
        default:
        case \thebuggenie\core\framework\Settings::SYNTAX_PT:
            $options = array('plain' => true);
        case \thebuggenie\core\framework\Settings::SYNTAX_MW:
            $wiki_parser = new \thebuggenie\core\helpers\TextParser($text, $toc, 'article_' . $article_id);
            foreach ($options as $option => $value) {
                $wiki_parser->setOption($option, $value);
            }
            $text = $wiki_parser->getParsedText();
            break;
        case \thebuggenie\core\framework\Settings::SYNTAX_MD:
            $parser = new \thebuggenie\core\helpers\TextParserMarkdown();
            $text = $parser->transform($text);
            break;
    }
    return $text;
}
示例#4
0
 protected function _getParsedText($text, $syntax, $options = array(), $parser_ref = null)
 {
     switch ($syntax) {
         default:
         case \thebuggenie\core\framework\Settings::SYNTAX_PT:
             $options = array('plain' => true);
         case \thebuggenie\core\framework\Settings::SYNTAX_MW:
             $parser = new \thebuggenie\core\helpers\TextParser($text);
             foreach ($options as $option => $value) {
                 $parser->setOption($option, $value);
             }
             $text = $parser->getParsedText();
             break;
         case \thebuggenie\core\framework\Settings::SYNTAX_MD:
             $parser = new \thebuggenie\core\helpers\TextParserMarkdown();
             $text = $parser->transform($text);
             break;
     }
     if (isset($parser) && !is_null($parser_ref)) {
         $this->{$parser_ref} = $parser;
     }
     return $text;
 }