function commonmark_convert($content) { global $commonmark_converter; if ($commonmark_converter === null) { $commonmark_converter = new League\CommonMark\CommonMarkConverter(); } return $commonmark_converter->convertToHtml($content); }
/** * Constructor * * @return \Docs */ public function __construct() { parent::__construct(); $this->load->config('docs'); $this->lang->load('docs'); // Save our folders $this->doc_folders = config_item('docs.folders'); list($this->current_group, $this->current_path) = $this->determineFromURL(); $this->determineVisibleGroups($this->current_group, $this->current_path); $this->load->helper('form'); $this->load->helper('language'); $this->docbuilder = new \Myth\Docs\Builder(array('apppath' => APPPATH)); $formatter = function ($str) { $converter = new \League\CommonMark\CommonMarkConverter(); return $converter->convertToHtml($str); }; $this->docbuilder->registerFormatter($formatter, true); }
/** * Return a formatted variant of the Long Description using MarkDown. * * @todo this should become a more intelligent piece of code where the * configuration contains a setting what format long descriptions are. * * @codeCoverageIgnore Will be removed soon, in favor of adapters at * PhpDocumentor itself that will process text in various formats. * * @return string */ public function getFormattedContents() { $result = $this->contents; // if the long description contains a plain HTML <code> element, surround // it with a pre element. Please note that we explicitly used str_replace // and not preg_replace to gain performance if (strpos($result, '<code>') !== false) { $result = str_replace(array('<code>', "<code>\r\n", "<code>\n", "<code>\r", '</code>'), array('<pre><code>', '<code>', '<code>', '<code>', '</code></pre>'), $result); } if (class_exists('Parsedown')) { $markdown = \Parsedown::instance(); $result = $markdown->parse($result); } elseif (class_exists('dflydev\\markdown\\MarkdownExtraParser')) { $markdown = new \dflydev\markdown\MarkdownExtraParser(); $result = $markdown->transformMarkdown($result); } elseif (class_exists('League\\CommonMark\\CommonMarkConverter')) { $markdown = new \League\CommonMark\CommonMarkConverter(); $result = $markdown->convertToHtml($result); } return trim($result); }