Pandoc, images and accessibility

29th April 2025

By default, pandoc, which I use to make this site uses the alt text attribute in Markdown as the caption for any given image. I was not happy with this behaviour, as it does not allow things made with Markdown to be fully accessible. I tried searching online for an answer but couldn’t find one immediately, but looking through the manual, I noticed that any key/value pair can be passed using the following syntax:

![caption](image-url){key=value}

I tried experimentally passing the key alt with a different value, and it works a charm! So if you’re looking to add (proper) alt text to your pandoc generated HTML documents, here’s the example syntax you need:

![The old castle walls](./assets/images/old_castle.jpg){alt="An image of the walls an old castle. There is a large brown wooden door in the centre of the walls. Above them is a blue sky."}

I have experimentally tried this with my latest blog about a trip to Restalrig, so you can see the effect of this over there. I will add this to all future blogs too.


Tagged as: web pandoc programming