New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Issue #358 – preventing double nested links #433
Changes from 1 commit
d6d5f53
4d3600f
50952b3
a81aede
543a6c4
3aef89b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1005,18 +1005,9 @@ public function line($text, $non_nestables=array()) | |
{ | ||
# check to see if the current inline type is nestable in the current context | ||
|
||
foreach ($non_nestables as $key => $non_nestable) | ||
if (in_array($inlineType, $non_nestables)) | ||
{ | ||
# case that we used array syntax | ||
if (is_array($non_nestable) and $non_nestable[0] === $inlineType) | ||
{ | ||
continue 2; | ||
} | ||
# case that we used plain string syntax | ||
elseif ( ! is_array($non_nestable) and $non_nestable === $inlineType) | ||
{ | ||
continue 2; | ||
} | ||
continue; | ||
} | ||
|
||
$Inline = $this->{'inline'.$inlineType}($Excerpt); | ||
|
@@ -1040,26 +1031,11 @@ public function line($text, $non_nestables=array()) | |
$Inline['position'] = $markerPosition; | ||
} | ||
|
||
# cause the new element to 'inherit' our non nestables, if appropriate | ||
# cause the new element to 'inherit' our non nestables | ||
|
||
foreach ($non_nestables as $key => $non_nestable) | ||
foreach ($non_nestables as $non_nestable) | ||
{ | ||
# array syntax, and depth is sufficient to pass on | ||
if (is_array($non_nestable) and isset($non_nestable[1]) and | ||
is_int($non_nestable[1]) and $non_nestable[1] > 1) | ||
{ | ||
$Inline['element']['non_nestables'][] = array($non_nestable[0], $non_nestable[1] -1); | ||
} | ||
# array syntax, and depth is indefinite | ||
elseif (is_array($non_nestable) and ! isset($non_nestable[1])) | ||
{ | ||
$Inline['element']['non_nestables'][] = array($non_nestable[0]); | ||
} | ||
# string syntax, so depth is indefinite | ||
elseif ( ! is_array($non_nestable)) | ||
{ | ||
$Inline['element']['non_nestables'][] = $non_nestable; | ||
} | ||
$Inline['element']['non_nestables'][] = $non_nestable; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PhrozenByte I did consider that, though there is no guarantee that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, didn't think about that. I agree that adding another check doesn't improve readability, so it's probably best to keep it the way you did 😃 |
||
} | ||
|
||
# the text that comes before the inline | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
if (!empty($non_nestables) && in_array($inlineType, $non_nestables))
?in_array()
really is very expensive, even with empty arrays.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds sensible, I'll commit that change when I get a sec :)