Skip to content

Cannot get attributes in no language identifier in CodeBlock #10118

@chick-p

Description

@chick-p

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

$ hugo version
hugo v0.101.0+extended darwin/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes

The issue

Sometimes, I don't specify a language identifier in a Code Block as follows:

```{foo=true}
bar
```

In the above case, the Render Hooks for Code Block do not receive the attributes.
Is this behavior expected?

I guess this cause is that attrStartIdx equals 0 if no language identifier ingetAttributes().
Ref. https://github.com/gohugoio/hugo/blob/master/markup/goldmark/codeblocks/render.go#L184-L191

If this behavior is a bug, I guess that be fixed by the below diff.

-		if attrStartIdx > 0 {
+		if attrStartIdx != -1 {

Ref. b6b15e5

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions