Ejemplo n.º 1
0
/**
 * 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;
}
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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;
 }