From 3eb6d349f0bae5e73fba5e6d68d696f811feba5c Mon Sep 17 00:00:00 2001 From: Emanuil Rusev Date: Mon, 12 Jan 2015 02:58:08 +0200 Subject: [PATCH] "src" and "alt" attributes should come first --- Parsedown.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index ec56d78..3ed86f7 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -1247,22 +1247,28 @@ class Parsedown $excerpt = substr($excerpt, 1); - $Inline = $this->inlineLink($excerpt); + $InlineLink = $this->inlineLink($excerpt); - if ($Inline === null) + if ($InlineLink === null) { return; } - $Inline['extent'] ++; + $Inline = array( + 'extent' => $InlineLink['extent'] + 1, + 'element' => array( + 'name' => 'img', + 'attributes' => array( + 'src' => $InlineLink['element']['attributes']['href'], + 'alt' => $InlineLink['element']['text'], + ), + ), + ); + + $Inline['element']['attributes'] += $InlineLink['element']['attributes']; - $Inline['element']['name'] = 'img'; - $Inline['element']['attributes']['src'] = $Inline['element']['attributes']['href']; unset($Inline['element']['attributes']['href']); - $Inline['element']['attributes']['alt'] = $Inline['element']['text']; - unset($Inline['element']['text']); - return $Inline; }