From 65d7bc5013d4f39d3fb8b4dfbe87f9627ced2d74 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 18 Mar 2018 22:36:30 +0000 Subject: [PATCH] Special casing for elements with no name --- Parsedown.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index d7337a5..715deee 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -1489,12 +1489,18 @@ class Parsedown { $markup = ''; + $autoBreak = true; + foreach ($Elements as $Element) { - $markup .= "\n" . $this->element($Element); + // (autobreak === false) covers both sides of an element + $autoBreak = !$autoBreak ? $autoBreak : isset($Element['name']); + + $markup .= ($autoBreak ? "\n" : '') . $this->element($Element); + $autoBreak = isset($Element['name']); } - $markup .= "\n"; + $markup .= $autoBreak ? "\n" : ''; return $markup; } @@ -1539,6 +1545,12 @@ class Parsedown 'img' => 'src', ); + if ( ! isset($Element['name'])) + { + unset($Element['attributes']); + return $Element; + } + if (isset($safeUrlNameToAtt[$Element['name']])) { $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]);