diff --git a/ParsedownExtra.php b/ParsedownExtra.php index 8cdb5d2..c1385ae 100644 --- a/ParsedownExtra.php +++ b/ParsedownExtra.php @@ -17,7 +17,7 @@ class ParsedownExtra extends Parsedown { # ~ - const version = '0.8.0'; + const version = '0.8.2'; # ~ @@ -508,7 +508,7 @@ protected function buildFootnoteElement() ), ); - uasort($this->DefinitionData['Footnote'], 'self::sortFootnotes'); + uasort($this->DefinitionData['Footnote'], [$this, 'sortFootnotes']); foreach ($this->DefinitionData['Footnote'] as $definitionId => $DefinitionData) { @@ -624,12 +624,15 @@ protected function processTag($elementMarkup) # recursive $DOMDocument = new DOMDocument; - # http://stackoverflow.com/q/11309194/200145 - $elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8'); - - # http://stackoverflow.com/q/4879946/200145 - $DOMDocument->loadHTML($elementMarkup); + # https://www.php.net/manual/en/domdocument.loadhtml.php#95251 + $DOMDocument->loadHTML('' . $elementMarkup); $DOMDocument->removeChild($DOMDocument->doctype); + foreach ($DOMDocument->childNodes as $Node) { + if ($Node->nodeType === XML_PI_NODE) { + $DOMDocument->removeChild($Node); + } + } + $DOMDocument->encoding = 'UTF-8'; $DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild); $elementText = ''; @@ -683,4 +686,4 @@ protected function sortFootnotes($A, $B) # callback # protected $regexAttribute = '(?:[#.][-\w]+[ ]*)'; -} +} \ No newline at end of file