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

allow element to have no name

This commit is contained in:
Aidan Woods 2017-06-13 20:28:32 +01:00
parent 97dd037e6f
commit 72d30d33bc
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -1460,26 +1460,33 @@ class Parsedown
$Element = $this->sanitiseElement($Element);
}
$markup = '<'.$Element['name'];
$hasName = isset($Element['name']);
if (isset($Element['attributes']))
$markup = '';
if ($hasName)
{
foreach ($Element['attributes'] as $name => $value)
{
if ($value === null)
{
continue;
}
$markup .= '<'.$Element['name'];
$markup .= ' '.$name.'="'.self::escape($value).'"';
if (isset($Element['attributes']))
{
foreach ($Element['attributes'] as $name => $value)
{
if ($value === null)
{
continue;
}
$markup .= ' '.$name.'="'.self::escape($value).'"';
}
}
}
if (isset($Element['text']))
{
$markup .= '>';
$markup .= $hasName ? '>' : '';
if (!isset($Element['nonNestables']))
if (!isset($Element['nonNestables']))
{
$Element['nonNestables'] = array();
}
@ -1493,9 +1500,9 @@ class Parsedown
$markup .= self::escape($Element['text'], true);
}
$markup .= '</'.$Element['name'].'>';
$markup .= $hasName ? '</'.$Element['name'].'>' : '';
}
else
elseif ($hasName)
{
$markup .= ' />';
}