In hugo version v0.77.0 with hugo-theme-techdoc
I’m trying to render a table with some specific styling.
I’m trying to use zwbetz’s {{ bootstrap-table "classname" }}
shortcode. It’s defined in /layouts/shortcodes/bootstrap-table.html
like this:
{{ $htmlTable := .Inner | markdownify }}
{{ $class := .Get 0 }}
{{ $old := "<table>" }}
{{ $new := printf "<table class=\"%s\">" $class }}
{{ $htmlTable := replace $htmlTable $old $new }}
{{ $htmlTable | safeHTML }}
It works correctly with a trivial table in markdown like so:
{{< bootstrap-table "someclassname" >}}
| animal | sound |
|--------|-------|
| dog | meow |
| cat | woof |
{{< /bootstrap-table > }}
But if the marked-down table contains other Hugo shortcodes, it rejects the table markup and makes an empty table, followed in the generated html by messages (in html comments) saying Hugo rejected some html.
Here’s an offending markdown table.
{{< bootstrap-table "someclassname" >}}
| animal | sound |
|--------|-------|
| {{< img src="dog.jpg" alt="Dog" class="align__left size__80" >}} | meow |
| {{< img src="cat.jpg" alt="Cat" class="align__left size__80" >}} | woof |
{{< /bootstrap-table > }}
There’s obviously something I don’t get about markdownify
and / or safeHTML
What can I do to make this bootstrap-table
Hugo tag accept my table with images or other hugo shortcodes in it?