1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Special casing for elements with no name

This commit is contained in:
Aidan Woods 2018-03-18 22:36:30 +00:00
parent 1a47e74be1
commit 65d7bc5013
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -1489,12 +1489,18 @@ class Parsedown
{ {
$markup = ''; $markup = '';
$autoBreak = true;
foreach ($Elements as $Element) 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; return $markup;
} }
@ -1539,6 +1545,12 @@ class Parsedown
'img' => 'src', 'img' => 'src',
); );
if ( ! isset($Element['name']))
{
unset($Element['attributes']);
return $Element;
}
if (isset($safeUrlNameToAtt[$Element['name']])) if (isset($safeUrlNameToAtt[$Element['name']]))
{ {
$Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]); $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]);