gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.66k stars 7.52k forks source link

Location in shortocde error sometimes off #10735

Open killermoehre opened 1 year ago

killermoehre commented 1 year ago

What version of Hugo are you using (hugo version)?

hugo v0.110.0+extended darwin/arm64 BuildDate=unknown

Does this issue reproduce with the latest release?

yes

Hi. I have a markdown file which gives me the error:

$ hugo
Start building sites …
hugo v0.110.0+extended darwin/arm64 BuildDate=unknown
Error: Error building site: "<path>/_index.md:1:1": unrecognized character in shortcode action: U+0022 '"'. Note: Parameters with non-alphanumeric args must be quoted
Total in 719 ms

Which is not really helpful, because

  1. I expect that " is allowed in a {{< ref "#someAnchor" >}} and
  2. :1:1 is not an actual error location, because my document starts with a ---

Any idea how I can debug this further?

bep commented 1 year ago

Any idea how I can debug this further?

https://discourse.gohugo.io/ would be a good start. We will fix he error location, but assuming you don't have hundreds of shortodes in that file, it should not be too hard to spot.

killermoehre commented 1 year ago

I checked all my shortcodes. They look good. It's in fact some specific entry where when I switch " to ' I get the same error message, but with unrecognized character in shortcode action: U+0027 '''

I have the feeling some global state is broken here.

bep commented 1 year ago

I have the feeling some global state is broken here.

There's no global state where this error is produced. I'm pretty sure this is a subtle error in your Markdown source, which is hard to spot without ... seing the source.

I keep this issue open for the error message (which is a bug) -- I would appreciate if you could take further troubleshooting on the forum. If this, against my best judgement, turns out to be a bug, we'll create a new issue.

killermoehre commented 1 year ago

Well, this is a work topic with internal data, and I'm on holiday for the next two weeks. So even I really would love to drop into the discord, I can't share the source and am not at my laptop.

killermoehre commented 1 year ago

So, with the help of a colleague I found my problem.

---
title: "Some Title"
description: "Some Desc"
---

Here is [a working link]({{< rel "#someAnchor" >}})

And here is [a syntax error]({{< "#someOtherAnchor" >}})

## Some Anchor {#someAnchor}

## Some Other Anchor {#someOtherAnchor}

And now the error message depends on the used quoting character of the first rel.