erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.69k stars 1.12k forks source link

Nested html tags #813

Open nvayalil opened 3 years ago

nvayalil commented 3 years ago

Hi, I am trying to modify the "inlineImage" function to use

tags, but just returns only the outer tag, The modified function is below:

 protected function inlineImage($Excerpt)
    {
        if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
        {
            return;
        }

        $Excerpt['text']= substr($Excerpt['text'], 1);

        $Link = $this->inlineLink($Excerpt);

        if ($Link === null)
        {
            return;
        }

        $Inline = array(
            'extent' => $Link['extent'] + 2,
            'element' => array(
                'name' => 'figure',
                'elements' => array(
                    array(
                        'name' => 'img', 
                        'attributes' => array(
                            'src' => $Link['element']['attributes']['href'],
                            'alt' => $Link['element']['text'],
                        )
                    ),
                ),
            ),
        );
        return $Inline;
    }

I expected something like

></figure>, but only returning <figure />.            </div>
        </div>
    
    
    <div class=