How to preserve softbreaks in the alt text of images?

Originally this was an issue in goldmark but it has been fixed recently (in 1.6.0), which has been picked up by Hugo 0.120.3. However, when I render an image like this (with Hugo 0.120.3):

![alt
tex](logo.png)

it still gives me

<img src="logo.png" alt="alttext">

That is, the softbreak was still eaten. I’m hoping to get

<img src="logo.png" alt="alt
text">

I wonder if there is a way to configure Hugo to preserve the softbreaks. Thanks!

(You may ask why I had those breaks in the alt text, and the reason is that my text editor wraps the Markdown source.)

I wonder if there is a way to configure Hugo to preserve the softbreaks.

There is not.

Ouch.

I’ve verified that (a) v0.120.3 is using yuin/goldmark v1.6.0, and (b) yuin/goldmark v1.6.0 resolves the reported problem.

https://github.com/gohugoio/hugo/issues/11681

https://github.com/gohugoio/hugo/pull/11682

1 Like