gethinode / hinode

A clean documentation and blog theme for your Hugo site based on Bootstrap 5
https://gethinode.com
MIT License
150 stars 54 forks source link

{{< file>}} add options for syntax highlight #1272

Closed d-oit closed 1 month ago

d-oit commented 1 month ago

Problem or enhancement idea

add hugo highlight options to the file shortcode

Proposed solution

{{< file full="true" show="false" path="./layouts/partials/navbar-mode.html" id="file-collapse-1" options="linenos=table,hl_lines=8 15-17,linenostart=3" >}}

use hugo syntax: https://gohugo.io/content-management/syntax-highlighting/

Solution: file shortcode

{{- $options := .Get "options" -}} {{- highlight (trim $content "\r\n") $lang $options -}}

markdumay commented 1 month ago

Thanks for submitting the PR @d-oit! I've merged the changes with the main branch. I'll move the content of the added post to the docs next.

d-oit commented 1 month ago

Thought in this way you could see directly the changes.

markdumay commented 1 month ago

It has been released: https://gethinode.com/docs/components/file/#syntax-highlighting