Skip to content

Error when JSON fenced code block contains shortcode call #12567

Open
@jmooring

Description

@jmooring

Reference: https://discourse.gohugo.io/t/panic-with-json-and-workaround-but-better-to-fix-it/50137/9

markdown

```json
{{< sc >}}
```

error

Error: error building site: render: failed to render pages: render of "home" failed: "/home/jmooring/code/hugo-testing/layouts/_default/home.html:11:5": execute of template failed: template: _default/home.html:11:5: executing "main" at <.Content>: error calling Content: unknown shortcode token "HAHAHUGOSHORTCODE<span style="color:#ae81ff">1<span style="color:#960050;background-color:#1e0010">s<span style="color:#ae81ff">0<span style="color:#960050;background-color:#1e0010">HBHB" (number of tokens: 1)

The problem seems to be limited to the JSON hiighlighting language. I tested about 20 other languages, including some likely suspects, but was unable to reproduce the problem.

This isn’t a problem if you call the shortcode using the {{% %}} notation. The shortcode template itself is irrelevant.

It looks like we started throwing this error in v0.111.0 and later, but as far as I can tell this combination has never worked.

Low priority.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions