Thanks to visit codestin.com
Credit goes to github.com

Skip to content

transform.HighlightCodeBlock returns .Inner with wrapping tags for code blocks without lang #14820

@GoldsteinE

Description

@GoldsteinE

documentation states that .Inner

Returns highlighted code without any wrapping elements, allowing you to create your own wrapper.

but that is not the case for codeblocks without any .Type.

reproducer:

; hugo new project meow
# a bunch of output
; cd meow
; echo '{{ .Content }}' > layouts/home.html
; mkdir layouts/_markup
; cat >layouts/_markup/render-codeblock.html <<'EOF'
{{ $result := transform.HighlightCodeBlock . }}
<pre><code>{{ $result.Inner }}</code></pre>
EOF
; cat >content/_index.md <<'EOF'
```
meow
```
EOF
; hugo build
; cat public/index.html

<pre><code><pre tabindex="0"><code>meow</code></pre></code></pre>

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

$ hugo version
hugo v0.160.1+extended+withdeploy linux/amd64 BuildDate=unknown VendorInfo=nixpkgs

Does this issue reproduce with the latest release?

yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions