Regression in 0.55.x from 0.54.0: asciidoctor and shortcodes

I think I’ve discovered a regression in 0.55.x (I’ve tested .5, .4, and .0) versus 0.54, for the following:

I have the following asciidoctor markup enclosed in a shortcode so that readers can expand and collapse a very large table (only a small part shown here).

If I run this using Hugo’s server in .54, I see the results in this screen shot…

works

If I run this using 0.55.x, I see the results in this screen shot: Notice that the expand/collapse prompt is gone, replaced by the actual shortcode contents and the table:

The contents in question and the shortcode are shown in the following snippets.

Is this a regression, or has something deliberately changed that I didn’t account for?

    {{% expand "Show/Hide Table" %}}
    [.table]
    .Time zones
    [width=20%]
    [.table-stripes, cols="^.<100", options="header"]
    |===
    | **Time zone**
    
    | Africa/Abidjan

    | Africa/Accra

    | Africa/Addis_Ababa

    | Africa/Algiers

    | Africa/Asmara

    | Africa/Asmera

The definition of expand.html is taken from the docdock theme:

    <div class="expand">
        <div class="expand-label" style="cursor: pointer;" onclick="$h = $(this);$h.next('.expand-
           content').slideToggle(100,function () {$h.children('span#chevron').attr('class',function () {return 
          $h.next('div').is(':visible') ? 'fa fa-chevron-down' : 'fa fa-chevron-right';});});">
          <span id="chevron" style="font-size:x-small; border-bottom: 1px solid black;" class="fas fa-
          chevron-right"></span>
          <span style="font-weight: bold; font-size: 1.2em; border-bottom: 1px solid black;">{{ .Get 0 }} 
          </span>
        </div>
        <div class="expand-content" style="display: none;">
            {{.Inner | safeHTML}}
        </div>
    </div>

There was a change related to shortcodes in 0.55: https://gohugo.io/news/0.55.0-relnotes/ so I’m wondering if that is the issue for you?

Thanks. I confess that I don’t know what this means:

Shortcodes using the {{% %}} as the outer-most delimiter will now be fully rendered when sent to the content renderer (e.g. Blackfriday for Markdown), meaning they can be part of the generated table of contents, footnotes, etc.

Why is this different from normal shortcode behavior? An example would have helped.

I also note that the impact of this change isn’t evident from the statement in the release notes. It has a large impact on shortcodes, particularly if your site isn’t using Markdown (mine uses asciidoctor). Using markdownify is, of course, not an option for me.

1 Like

Not the cause. I tested with the suggested workaround, using 55.3, and the same problem occurred.

Could you test again with 0.55.4?

I tested and was able to replicate your issue on 0.55.3, but it looks like 0.55.4 may have fixed it. It seems to be working (for me at least) using {{% %}} with the addition of

{{ $_hugo_config := `{ "version": 1 }` }}

at the beginning of the shortcode.

0.55.4 and the {{ $_hugo_config }} fix the problem. I’ll move forward.

Could you show what the .adoc file looks like with the positioning of the {{ $_hugo_config :={ “version”: 1 }}} added? I’m seeing a similar situation with docdock when trying to use the theme’s native {{% notice info %}} shortcode (rendered HTML in the output file.

My file contains:

{{% notice info %}}
An information disclaimer
{{% /notice %}}

And in the browser shows:

<div class="notices info" > An information disclaimer </div>

The {{ $_hugo_config line goes in your shortcode, not in your adoc file.

Thanks! Figured out where to make the changes for the docdock theme.