HTML in shortcode attribute breaks shortcode

It looks like the internal figure shortcode does not allow HTML in the caption attribute. Is that a bug or a feature?

{{< figure src="/2018/03/wider-den-darts/darts-1000x667.jpg" caption="Terrorist an Zielscheibe - Photo by <a href="">Clem Onojeghuo</a>" width="930" height="620" >}}

prints the shortcode unrendered

{{< figure src="/2018/03/wider-den-darts/darts-1000x667.jpg" caption="Terrorist an Zielscheibe - Photo by Clem Onojeghuo" width="930" height="620" >}}

prints out as expected…

(note: html is allowed in the caption tag in HTML5)

This is a known issue (the issue talks about Markdown emphasis chars not rendered, but the same applies to HTML too):

My workaround is to use my custom figure shortcode that does what I want:

  • Render markdown/HTML in figure captions.

With the above custom shortcode, this works:

{{< figure src="/images/magit-log-buffer-file.png" caption="Figure 1: Terrorist an Zielscheibe - Photo by <a href=\"\">Clem Onojeghuo</a>" >}}

Note that I use \" instead of " inside the double quotes for caption property.

How about trying to wrap the href in single quotes?

Like so:

caption="Terrorist an Zielscheibe - Photo by <a href=''>Clem Onojeghuo</a>"

For your specific case though, the figure shortcode has attr and attrlink parameters too, which you can use as:

{{< figure src="/2018/03/wider-den-darts/darts-1000x667.jpg" caption="Terrorist an Zielscheibe" attr="Photo by Clem Onojeghuo" attrlink="" width="930" height="620" >}}

Yes! Great! I’ll add the dash via CSS between caption and attribution. I was writing my own custom shortcode that has the caption between opening and closing shortcode tags when you posted this :slight_smile: This is way better.

That printed out the HTML in the caption. \" and \' both result in captiontext with <tag bla="fasel">text</tag> being printed, which is expected in Go.