erusev/parsedown — pull request #150 by jarofgreen (2014-04-01 11:12:46+00:00)
Title: getHTMLForLink() to allow sub classes to override

You probably won't like this but we'll try ... :-)

I have a use case where I have a folder of MD files. I want to convert them to a folder of HTML files. So far so good - a simple PHP script with your library has done the job.

But there are times where one markdown file wants to link to another markdown file. When we convert to HTML, we don't want to link to the MD, we want to link to the associated HTML.

So basically on converting MD to HTML, I want to rewrite URLs slightly.

Hopefully I've come up with a nice solution .... I didn't want to add URL rewriting into Parsedown - instead I thought let's provide some hooks that other programmers can call to do what they want in terms of extending the functionality without adding to the complexity of the original class.

Add a function getHTMLForLink() which takes params and generates HTML. Parsedown class then calls that to generate any HTML. The changes to your class are minimal, the API is the same, all tests pass.

I can then extend the Parsedown class, override the getHTMLForLink() method and do URL rewriting in there.