With v0.60 and later, is there any benefit to doing this:
{{< highlight go >}}
// ... code
{{< / highlight >}}
instead of this?
```go
// ... code
```
Just curious if the shortcode approach is still widely used, and if so, why?
With v0.60 and later, is there any benefit to doing this:
{{< highlight go >}}
// ... code
{{< / highlight >}}
instead of this?
```go
// ... code
```
Just curious if the shortcode approach is still widely used, and if so, why?
I think the shortcode is good if you are changing up options between uses. Like custom line numbers (from to) and such:
{{< highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" >}}
// ... code
{{< / highlight >}}
That won’t work with the three ticks if I don’t miss anything.
With attributes you can do the same thing with backticks.
```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199}
// ... code
```
See https://gohugo.io/content-management/syntax-highlighting/#highlighting-in-code-fences.
It was more useful before we improved the highlight support in Markdown (code fences, attributes), but it is still useful in HTML file, Asciidoc files etc.
Yeah, I just realized that there’s a lot of non-md content out there. Thanks.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.