Drew
Drew

Reputation: 6274

extending markdown?

I have a site where users can file game reports. I currently use a combination of markdown and HTMLPurifier to allow for limited mark-up.

I would like to add inline photo support, drawing images from a user gallery.

I've built an image sidebar with a bit of JS that on thumbnail click inserts a corresponding markdown code snippet at the cursor position.

This is all well and good, but rather than markdown processing this standard code and giving me:

<img src="foo.jpg" />

I'd much rather end up with:

<a href="original/foo.jpg">
    <img src="foo.jpg" />
</a>

i.e., an automatic link to the original fullsize image.

Because the code and paths are predictable, I could change these tags at the post-markdown HTML step via string replace, but that seems... inelegant.

Should I extend or otherwise modify markdown.php to give me a customized '<img /> mark-up, or is this a bad idea for some reason I am not perceiving?

Upvotes: 3

Views: 568

Answers (1)

sarnold
sarnold

Reputation: 104020

Modifying your markdown parser sounds like a good idea to me. You're entitled to getting the program you want. Be sure to store your changes as a patch as well, so you can easily re-apply them to future versions of markdown.

Upvotes: 1

Related Questions