Skip to content
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

Wrap image inside div - not working #174

Open
hrvoj3e opened this issue Jan 11, 2022 · 0 comments
Open

Wrap image inside div - not working #174

hrvoj3e opened this issue Jan 11, 2022 · 0 comments

Comments

@hrvoj3e
Copy link

hrvoj3e commented Jan 11, 2022

Please see this

Example works when class MarkdownPlugin extends \Parsedown but not when extending ParsedownExtra (version 0.8.0).
Why is that?

class MarkdownPlugin extends \ParsedownExtra
{
    protected function inlineImage($excerpt)
    {
        $element = parent::inlineImage($excerpt);
        if (!is_array($element ?? null)) {
            return null;
        }

        // wrap img with div
        $block = [
            'extent' => $element['extent'],
            'element' => [
                'name' => 'div',
                'handler' => 'element',
                'text' => $element,
                'attributes' => [
                    'class' => 'my-img-wrap',
                ],
            ],
        ];

        return $block;
    }
}

This is my test case:

![my-image](my-image.jpg)
<div class="my-img-wrap'">
   <img src="my-image.jpg" alt="my-image">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant