Bug or Feature? language-less code blocks use "default" formatting

And this may be useful:

https://discourse.gohugo.io/t/add-option-to-use-default-chroma-lexer-for-code-fences-with-no-language/55368/3

The render hook (layouts/_markup/render-codeblock.html) is trivial:

{{- $lang := "text" }}
{{- $options := .Options }}
{{- if transform.CanHighlight .Type }}
  {{- $lang = .Type }}
{{- else }}
  {{- $options = .Attributes }}
{{- end }}

{{- transform.Highlight .Inner $lang $options }}
1 Like