Commit 2f96c5c8 authored by Markus Willman's avatar Markus Willman

fix ParsedownExtra::processTag(), retain entities on deeper recursions

parent 9b1891d3
......@@ -617,7 +617,7 @@ class ParsedownExtra extends Parsedown
# ~
protected function processTag($elementMarkup) # recursive
protected function processTag($elementMarkup, $recursion = false) # recursive
{
# http://stackoverflow.com/q/1148928/200145
libxml_use_internal_errors(true);
......@@ -628,10 +628,13 @@ class ParsedownExtra extends Parsedown
$elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');
# keep these incoming encoded entities as is (reserve the html entity representation for DOM autoconversion)
$elementMarkup = str_replace(
array('>', '<', '>', '<', '>', '<'),
array('^0x3e^', '^0x3c^', '^0x3e^', '^0x3c^', '^0x3e^', '^0x3c^'),
$elementMarkup);
if (!$recursion)
{
$elementMarkup = str_replace(
array('>', '<', '>', '<', '>', '<'),
array('^0x3e^', '^0x3c^', '^0x3e^', '^0x3c^', '^0x3e^', '^0x3c^'),
$elementMarkup);
}
# http://stackoverflow.com/q/4879946/200145
$DOMDocument->loadHTML($elementMarkup);
......@@ -661,7 +664,7 @@ class ParsedownExtra extends Parsedown
if ($Node instanceof DOMElement and ! in_array($Node->nodeName, $this->textLevelElements))
{
$elementText .= $this->processTag($nodeMarkup);
$elementText .= $this->processTag($nodeMarkup, true);
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment