I finally had some time to work out what is actually happening during the build process in the code I’m working with and I managed to put together an equivalent example. I believe that what I’m really struggling with is nested shortcodes. I can’t seem to work out how to stop the output form the highlight
shortcode getting rendered as markdown when the shortcode it is nested within gets rendered. I might be making a really obvious mistake but my mental model of hugo is still under construction.