I was toying with the idea of converting my site’s content files to use asciidoc
rather than markdown
, as I’m using the former more often and the latter less often these days.
Anyway, I converted a couple of existing markdown
pages without incident, until I came to one which uses the {{figure}}
shortcode. When I convert that page to asciidoc
and Hugo rebuilds the site, the content of the shortcode is rendered directly to the page, rather than being replaced with HTML generated by the shortcode. Any idea why this is?
BTW - I used https://github.com/asciidoctor/kramdown-asciidoc to convert the page in question from markdown
to asciidoc
.
Here is the the original markdown
version of the page:
And here is the asciidoc conversion:
Excepting the different URL syntax, they look pretty identical to me. But, while the markdown
version built by Hugo renders the image correctly, here’s what I get with the asciidoc
version:
And in the source code. As you can see, the actual shortcode code is rendered inside a paragraph tag, within quotes,rather than being replaced by HTML:
For comparison, the same page rendered from the markdown
file:
And, just for completeness, here’s the {{figure}}
shortcode:
{{ "<!-- begin image shortcode //-->" | safeHTML }}
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>{{ with .Get "link"}}<a href="{{.}}">{{ end }}<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />{{ if .Get "link"}}</a>{{ end }}{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}<figcaption>{{ if isset .Params "title" }}{{ .Get "title" }}{{ end }}{{ if or (.Get "caption") (.Get "attr")}}{{ .Get "caption" }}{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}{{ .Get "attr" }}{{ if .Get "attrlink"}}</a> {{ end }}{{ end }}
</figcaption>{{ end }}</figure>
{{ "<!-- end image shortcode //-->" | safeHTML }}