cache = $cache; $this->initParsedown(); } protected function initParsedown() { $this->parsedown = new \Parsedown(); $this->parsedown->setSafeMode(true); } /** * Converts the given markdown text to HTML. * The result is cached. * @param string $markdown The markdown text that should be parsed to html. * @param bool $inline_mode Only allow inline markdown codes like (*bold* or **italic**), not something like tables * @return string The HTML version of the given text. * @throws \Psr\Cache\InvalidArgumentException */ public function parse(string $markdown, bool $inline_mode = false) : string { return sprintf( '
Markdown loading...
', htmlspecialchars($markdown) ); //Generate key /*if ($inline_mode) { $key = 'markdown_i_' . md5($markdown); } else { $key = 'markdown_' . md5($markdown); } return $this->cache->get($key, function (ItemInterface $item) use ($markdown, $inline_mode) { //Expire text after 2 months $item->expiresAfter(311040000); if ($inline_mode) { return $this->parsedown->line($markdown); } return '
' . $this->parsedown->text($markdown) . '
'; });*/ } }