2018-03-15 22:46:03 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class UnsafeExtension extends Parsedown
|
|
|
|
{
|
|
|
|
protected function blockFencedCodeComplete($Block)
|
|
|
|
{
|
2018-03-21 05:32:01 +03:00
|
|
|
$text = $Block['element']['element']['text'];
|
|
|
|
unset($Block['element']['element']['text']);
|
2018-03-15 22:46:03 +03:00
|
|
|
|
|
|
|
// WARNING: There is almost always a better way of doing things!
|
|
|
|
//
|
|
|
|
// This example is one of them, unsafe behaviour is NOT needed here.
|
|
|
|
// Only use this if you trust the input and have no idea what
|
|
|
|
// the output HTML will look like (e.g. using an external parser).
|
2018-03-21 05:32:01 +03:00
|
|
|
$Block['element']['element']['rawHtml'] = "<p>$text</p>";
|
2018-03-15 22:46:03 +03:00
|
|
|
|
|
|
|
return $Block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class TrustDelegatedExtension extends Parsedown
|
|
|
|
{
|
|
|
|
protected function blockFencedCodeComplete($Block)
|
|
|
|
{
|
2018-03-21 05:32:01 +03:00
|
|
|
$text = $Block['element']['element']['text'];
|
|
|
|
unset($Block['element']['element']['text']);
|
2018-03-15 22:46:03 +03:00
|
|
|
|
|
|
|
// WARNING: There is almost always a better way of doing things!
|
|
|
|
//
|
2018-03-15 22:55:33 +03:00
|
|
|
// This behaviour is NOT needed in the demonstrated case.
|
|
|
|
// Only use this if you are sure that the result being added into
|
|
|
|
// rawHtml is safe.
|
|
|
|
// (e.g. using an external parser with escaping capabilities).
|
2018-03-21 05:32:01 +03:00
|
|
|
$Block['element']['element']['rawHtml'] = "<p>$text</p>";
|
|
|
|
$Block['element']['element']['allowRawHtmlInSafeMode'] = true;
|
2018-03-15 22:46:03 +03:00
|
|
|
|
|
|
|
return $Block;
|
|
|
|
}
|
|
|
|
}
|