Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "unknown shortcode token" when calling shortcode within fenced code block #10819

Closed
jmooring opened this issue Mar 11, 2023 · 3 comments · Fixed by #10822
Closed

Error "unknown shortcode token" when calling shortcode within fenced code block #10819

jmooring opened this issue Mar 11, 2023 · 3 comments · Fixed by #10822
Assignees
Milestone

Comments

@jmooring
Copy link
Member

jmooring commented Mar 11, 2023

N.B. I'm not sure if this is a bug, or if we've fixed a bug.

Reproducible with v0.111.0 and later.

If a shortcode is called using the {{< >}} notation within a fenced code block, Chroma lexes the placeholder, triggering an error such as:

unknown shortcode token "HAHAHUGOSHORTCODE<span style="color:#f92672">-<span style="color:#a6e22e">s0<span style="color:#f92672">-<span style="color:#a6e22e">HBHB"

But this does not happen with all lexers, and may depend on where the shortcode is placed within the codeblock (not sure).

For example, this works:

```bash
{{< sc >}}
```

But this throws an error:

```go
{{< sc >}}
```

And both of these work:

```bash
{{% sc %}}
```

```go
{{% sc %}}
```

What the shortcode does is irrelevant (e.g., it can be empty).

Reference: https://discourse.gohugo.io/t/43387 (Kubernetes site)

Simple example:

git clone --single-branch -b hugo-forum-topic-43387 https://github.com/jmooring/hugo-testing hugo-forum-topic-43387
cd hugo-forum-topic-43387
hugo server
@bep bep removed the NeedsTriage label Mar 12, 2023
@bep bep self-assigned this Mar 12, 2023
@bep bep modified the milestones: v0.112.0, v0.111.3 Mar 12, 2023
@bep
Copy link
Member

bep commented Mar 12, 2023

N.B. I'm not sure if this is a bug, or if we've fixed a bug.

I suspect the latter; or possibly also a subtle change in some of the Chroma lexers.

```bash
{{< sc >}}
```

The technical reasons why this fails is that some Chroma highlighters highlights the hyphen in the temporary placeholder, which doesn't work ...

However, the above construct looks a little bit odd since the output of {{< sc >}} will not be highlighted by Chroma. {{% sc %}} will.

But we need to fix this anyway.

@craigbox
Copy link

Thanks @bep! I'll update the markup used in the Kubernetes docs.

FWIW, it was hard to find this due to #10735.

Error: Error building site: "/Users/craigbox/Documents/Projects/kubernetes.io/content/ja/docs/tasks/administer-cluster/kubeadm/adding-windows-nodes.md:1:1": unknown shortcode token "HAHAHUGOSHORTCODE-s12</span>-HBHB"```

@github-actions
Copy link

github-actions bot commented Apr 3, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants