Skip to content

Commit

Permalink
Document wrapperClass highlighting option
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring authored Dec 31, 2024
1 parent e227dc4 commit ef00649
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
64 changes: 32 additions & 32 deletions content/en/functions/transform/Highlight.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,55 @@ LANG
: The language of the code to highlight. Choose from one of the [supported languages]. Case-insensitive.

OPTIONS
: A map, or comma-separated list, of zero or more [options]. Set default values in [site configuration].
: A map or comma-separated list of zero or more options. Set default values in [site configuration].

## Options

lineNos
: Boolean. Default is `false`.\
Display a number at the beginning of each line.
anchorLineNos
: (`bool`) Whether to render each line number as an HTML anchor element, setting the `id` attribute of the surrounding `span` element to the line number. Irrelevant if `lineNos` is `false`. Default is `false`.

lineNumbersInTable
: Boolean. Default is `true`.\
Render the highlighted code in an HTML table with two cells. The left table cell contains the line numbers. The right table cell contains the code, allowing a user to select and copy the code without line numbers. Irrelevant if `lineNos` is `false`.
codeFences
: (`bool`) Whether to highlight fenced code blocks. Default is `true`.

anchorLineNos
: Boolean. Default is `false`.\
Render each line number as an HTML anchor element, and set the `id` attribute of the surrounding `<span>` to the line number. Irrelevant if `lineNos` is `false`.
guessSyntax
: (`bool`) Whether to automatically detect the language if the `LANG` argument is blank or set to a language for which there is no corresponding [lexer]. Falls back to a plain text lexer if unable to automatically detect the language. Default is `false`.

lineAnchors
: String. Default is `""`.\
When rendering a line number as an HTML anchor element, prepend this value to the `id` attribute of the surrounding `<span>`. This provides unique `id` attributes when a page contains two or more code blocks. Irrelevant if `lineNos` or `anchorLineNos` is `false`.
[lexer]: /getting-started/glossary/#lexer

lineNoStart
: Integer. Default is `1`.\
The number to display at the beginning of the first line. Irrelevant if `lineNos` is `false`.
{{% note %}}
The Chroma syntax highlighter includes lexers for approximately 250 languages, but only 5 of these have implemented automatic language detection.
{{% /note %}}

hl_Lines
: String. Default is `""`.\
A space-delimited list of lines to emphasize within the highlighted code. To emphasize lines 2, 3, 4, and 7, set this value to `2-4 7`. This option is independent of the `lineNoStart` option.
: (`string`) A space-delimited list of lines to emphasize within the highlighted code. To emphasize lines 2, 3, 4, and 7, set this value to `2-4 7`. This option is independent of the `lineNoStart` option.

hl_inline
: Boolean. Default is `false`.\
Render the highlighted code without a wrapping container.
: (`bool`) Whether to render the highlighted code without a wrapping container.Default is `false`.

style
: String. Default is `monokai`.\
The CSS styles to apply to the highlighted code. See the [style gallery] for examples. Case-sensitive.
lineAnchors
: (`string`) When rendering a line number as an HTML anchor element, prepend this value to the `id` attribute of the surrounding `span` element. This provides unique `id` attributes when a page contains two or more code blocks. Irrelevant if `lineNos` or `anchorLineNos` is `false`.

lineNoStart
: (`int`) The number to display at the beginning of the first line. Irrelevant if `lineNos` is `false`. Default is `1`.

lineNos
: (`bool`) Whether to display a number at the beginning of each line. Default is `false`.

lineNumbersInTable
: (`bool`) Whether to render the highlighted code in an HTML table with two cells. The left table cell contains the line numbers, while the right table cell contains the code. Irrelevant if `lineNos` is `false`. Default is `true`.

noClasses
: Boolean. Default is `true`.\
Use inline CSS styles instead of an external CSS file. To use an external CSS file, set this value to `false` and [generate the file with the hugo client][hugo client].
: (`bool`) Whether to use inline CSS styles instead of an external CSS file. To use an external CSS file, set this value to `false` and generate the CSS file using the `hugo gen chromastyles` command. Default is `true`.

style
: (`string`) The CSS styles to apply to the highlighted code. See the [style gallery] for examples. Case-sensitive. Default is `monokai`.

tabWidth
: Integer. Default is `4`.\
Substitute this number of spaces for each tab character in your highlighted code. Irrelevant if `noClasses` is `false`.
: (`int`) Substitute this number of spaces for each tab character in your highlighted code. Irrelevant if `noClasses` is `false`. Default is `4`.

guessSyntax
: Boolean. Default is `false`.\
If the `LANG` argument is blank or an unrecognized language, auto-detect the language if possible, otherwise use a fallback language.
wrapperClass
{{< new-in 0.140.2 >}}
: (`string`) The class or classes to use for the outermost element of the highlighted code. Default is `highlight`.

{{% note %}}
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
Expand Down Expand Up @@ -100,8 +102,6 @@ lineNos=table
```

[Chroma]: https://github.com/alecthomas/chroma
[hugo client]: /commands/hugo_gen_chromastyles
[options]: #options
[site configuration]: /getting-started/configuration-markup#highlight
[style gallery]: https://xyproto.github.io/splash/docs/
[supported languages]: /content-management/syntax-highlighting#list-of-chroma-highlighting-languages
4 changes: 4 additions & 0 deletions content/en/getting-started/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ See [template](#template).

A directory that contains an index.md file and zero or more [resources](#resource). Analogous to a physical leaf, a leaf bundle is at the end of a branch. It has no descendants. See&nbsp;[details](/content-management/page-bundles/).

###### lexer

A software component that identifies keywords, identifiers, operators, numbers, and other basic building blocks of a programming language within the input text.

###### list page

Any [page kind](#page-kind) that receives a page [collection](#collection) in [context](#context). This includes the home page, [section pages](#section-page), [taxonomy pages](#taxonomy-page), and [term pages](#term-page).
Expand Down
12 changes: 10 additions & 2 deletions data/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ config:
targets: null
workers: 10
disableAliases: false
disableDefaultLanguageRedirect: false
disableHugoGeneratorInject: false
disableKinds: null
disableLanguages: null
Expand Down Expand Up @@ -1148,6 +1149,7 @@ config:
noHl: false
style: monokai
tabWidth: 4
wrapperClass: highlight
tableOfContents:
endLevel: 3
ordered: false
Expand Down Expand Up @@ -2560,8 +2562,9 @@ tpl:
- querify
Args:
- params
Description: Querify encodes the given params in URL-encoded form ("bar=baz&foo=quux")
sorted by key.
Description: |-
Querify returns a URL query string composed of the given key-value pairs,
encoded and sorted by key.
Examples:
- - '{{ (querify "foo" 1 "bar" 2 "baz" "with spaces" "qux" "this&that=those")
| safeHTML }}'
Expand Down Expand Up @@ -3289,6 +3292,11 @@ tpl:
- args
Description: Babel processes the given Resource with Babel.
Examples: []
Batch:
Aliases: null
Args: null
Description: ""
Examples: null
Build:
Aliases: null
Args: null
Expand Down

0 comments on commit ef00649

Please sign in to comment.