/** * 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(); foreach ($options as $option => $value) { $parser->setOption($option, $value); } $text = $parser->transform($text); break; } return $text; }