mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Merge pull request #511 from aidantwoods/feature/null-name-element
Allow element to have no name
This commit is contained in:
commit
a3265e7c6f
@ -1466,24 +1466,31 @@ 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']))
|
||||
{
|
||||
@ -1499,9 +1506,9 @@ class Parsedown
|
||||
$markup .= self::escape($Element['text'], true);
|
||||
}
|
||||
|
||||
$markup .= '</'.$Element['name'].'>';
|
||||
$markup .= $hasName ? '</'.$Element['name'].'>' : '';
|
||||
}
|
||||
else
|
||||
elseif ($hasName)
|
||||
{
|
||||
$markup .= ' />';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user