Closed themustafaomar closed 3 years ago
Well, I solved my issue.
class Markdown extends \Parsedown
{
protected function blockFencedCodeComplete($Block)
{
$highlighter = new \Highlight\Highlighter();
$element = $Block['element']['text'];
$snippet = $highlighter->highlight(
$this->resolveLang($element), $element['text']
)->value;
$Block['element']['text']['rawHtml'] = $snippet;
unset($Block['element']['text']['text']);
return $Block;
}
public function resolveLang(array $element)
{
return ltrim($element['attributes']['class'], 'language-');
}
}
By unsetting the text key and create a new one called rawHtml the second condition is going to work.
hence the $premitRawHtml variable can be overwritten with true if safeMode
is set to false
Hi, I have a problem using a highlighter because parsedown always escapes the HTML tags of the highlighted text. It's always shown like that even if the
setSafeMode
andsetMarkupEscaped
are set to falseI made an extension for this, here is the code:
After some digging, it turns out that the
escape
method is responsible for this issue.I tried to overwrite the escape method, but you guys are using
self::escape
I can't overwrite it, it should be static I think!I would like to know if there is a better way or anything I can do to solve this problem!
Thanks.