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

Fix Issue #358 – preventing double nested links

1. Add the ability for a parsed element to enforce that the line handler not parse any (immediate) child elements of a specified type.
2. Use 1. to allow parsed Url elements to tell the line handler not to parse any child Links or Urls where they are immediate children.
This commit is contained in:
Aidan Woods 2016-10-01 15:56:14 +01:00 committed by GitHub
parent a2ed1592bd
commit d6d5f53ff4

View File

@ -987,7 +987,7 @@ class Parsedown
# ~
#
public function line($text)
public function line($text, $non_nestables=array())
{
$markup = '';
@ -1003,6 +1003,12 @@ class Parsedown
foreach ($this->InlineTypes[$marker] as $inlineType)
{
if(in_array($inlineType, $non_nestables))
{
continue;
}
$Inline = $this->{'inline'.$inlineType}($Excerpt);
if ( ! isset($Inline))
@ -1183,6 +1189,7 @@ class Parsedown
$Element = array(
'name' => 'a',
'handler' => 'line',
'non_nestables' => array('Url', 'Link'),
'text' => null,
'attributes' => array(
'href' => null,
@ -1410,9 +1417,11 @@ class Parsedown
{
$markup .= '>';
if(!isset($Element['non_nestables'])) $Element['non_nestables'] = array();
if (isset($Element['handler']))
{
$markup .= $this->{$Element['handler']}($Element['text']);
$markup .= $this->{$Element['handler']}($Element['text'], $Element['non_nestables']);
}
else
{