3

I have this Markdown text:

![alt](/md.png "title")

And after converting it to HTML with Markdown' Parsedown PHP parser (http://parsedown.org/) I get:

<p><img alt="alt" src="/md.png" title="title" /></p>

I need to add certain values before and after the conversion as well as inside the code such that the desired result would be like

<a href='#' class='some_class'>
  <p><img class='some_classy_image' alt="alt" src="/md.png" title="title" /></p>
</a>

How can I achieve this in a easy way? I'm open to an answer using Parsedown or another PHP parser out there that exposes this functions in a easier way.

Emanuil Rusev
  • 34,563
  • 55
  • 137
  • 201
adelriosantiago
  • 7,762
  • 7
  • 38
  • 71

1 Answers1

4

You need to write an extension that overrides the inlineLink method.

It should look something like:

protected function inlineLink($Excerpt)
{
    $Link = parent::inlineLink($Excerpt);

    # modify $Link to match your requirements

    return $Link;
}

See the wiki for more info.

Emanuil Rusev
  • 34,563
  • 55
  • 137
  • 201