#Is there a programmatic hook into markdown rendering?

4 messages · Page 1 of 1 (latest)

autumn vale
#

I like composing my blog posts in pure markdown, but I don't like the way the plain old img tags look on my page. Is there a hook into the rendering process so instead of outputting <img> when it encounters the image syntax, it could output <MyImageComponent> instead?

I suspect the suggested way to do that would be to use mdx instead and insert the component you want to use. But I try to avoid using mdx while writing because it forces you mentally out of writing mode and into coding mode. I don't like mixing content and code that way. And secondly, I'd have to go back through all of my past posts with images in them, convert them to mdx and replace the image syntax with the component. Seems like a hassle when all I really want is to extend the image tag logic that already happens in markdown rendering.

Am I way off base here? Is there a better solution I haven't considered?

#

(I guess I should add that my site is fully statically generated, I'm not using SSR at this point)

narrow fossil
autumn vale
#

Ooh, nice! It looks like the visit(tree, 'image' etc... syntax is exactly what I'm looking for!