Quarto to Hugo: Preserving Figure Captions

The Problem When rendering Quarto notebooks (.qmd files) to Hugo-compatible markdown (.md files), figure captions are lost in the process. While Quarto generates proper figure captions in HTML output, for example: <img src="fig-distribution-output-1.png" width="464" height="470"> <figcaption> Figure 1: Distribution of Sample Data </figcaption> The markdown output for Hugo only includes the image with an alt text, like: <img src="fig-distribution-output-1.png" id="fig-dist" alt="Figure 1: Distribution of Sample Data" /> I tried playing with yaml options but there does not seem to be an easy fix. So here’s a javascript approach that constructs and includes captions for quarto generated figures automatically. ...

November 14, 2024 · 2 min · 301 words · Martin C. Arnold