The “image caption” example is nothing more than an emphasized string following an image. It has no relationship to the image.
Yes, and the only way I found to make it look like a caption is to target it this way:
img + em {
display: flex;
justify-content: center;
}
This method is error-prone as this will affect anyem element appearing right after an image.
Still, this is a handy way to add information about an image directly in Markdown.
Do you think of a way to improve it?
Should I open an issue on Hugo’s tracker asking to generate an HTML output more appropriated or is it more an issue related to CommonMark specifications?
The HTML <img> element does does not have a caption attribute. If you want to structurally associate a caption with an image, use a <figure> element.
You cannot create a <figure> element with markdown syntax, just as you cannot create <audio>, <video>, or <form> elements with markdown syntax. In these cases use HTML within your markdown, either directly or with a shortcode.