File highlighting
Posted on September 23, 2023 (Last modified on October 25, 2024) • 4 min read • 768 wordsThe file shortcode prints the full content of any given file with syntax highlighting
The file shortcode prints and highlights the full content of a given input file. It recognizes the languages supported by Hugo’s highlight function.
Use the Hugo syntax highlighting options for marking lines in the file. Hugo Documentation
|
|
defaultMarkdownHandler = "goldmark"
[highlight]
anchorLineNos = false
codeFences = true
guessSyntax = true
hl_Lines = ""
lineAnchors = ""
lineNoStart = 1
lineNos = false
lineNumbersInTable = false
noClasses = false
tabWidth = 2
## Update the 'create:syntax' command in package.json to modify the style
## The first two lines have been modified to remove the background color
# style = "monokailight"
[goldmark]
[goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = true
[goldmark.extensions.passthrough]
enable = true
[goldmark.extensions.passthrough.delimiters]
block = [['\[', '\]'], ['$$', '$$']]
inline = [['\(', '\)'], ['$', '$']]
[goldmark.parser]
autoHeadingID = true
autoHeadingIDType = 'github'
wrapStandAloneImageWithinParagraph = false
[goldmark.parser.attribute]
block = true
[goldmark.renderer]
hardWraps = false
unsafe = false
xhtml = false
---
author: Hinode Contributors
title: File highlighting
date: 2023-09-23
description: The file shortcode prints the full content of any given file with syntax highlighting
tags: ["file", "shortcode"]
thumbnail:
url: img/puzzle.jpg
author: Ryoji Iwata
authorURL: https://unsplash.com/@ryoji__iwata
origin: Unsplash
originURL: https://unsplash.com/photos/5siQcvSxCP8
---
The [file shortcode](https://gethinode.com/docs/components/file/) prints and highlights the full content of a given input file. It recognizes the languages supported by Hugo’s highlight function.
## File Shortcode
Use the Hugo syntax highlighting options for marking lines in the file.
[Hugo Documentation](https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode)
{{< file full="true" show="true" path="./layouts/shortcodes/file.html" options="linenos=table,hl_lines=41 68-70,linenostart=42" >}}
## Default configuration
{{< file full="true" show="false" path="./config/_default/markup.toml" >}}
## Current page as markdown file
{{< file full="true" show="true" path="./content/en/blog/file-highlight.md" >}}