You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
: (`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`.
7
+
8
+
codeFences
9
+
: (`bool`) Whether to highlight fenced code blocks. Default is `true`.
10
+
11
+
guessSyntax
12
+
: (`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`.
13
+
14
+
[lexer]: /getting-started/glossary/#lexer
15
+
16
+
{{% note %}}
17
+
The Chroma syntax highlighter includes lexers for approximately 250 languages, but only 5 of these have implemented automatic language detection.
18
+
{{% /note %}}
19
+
20
+
hl_Lines
21
+
: (`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.
22
+
23
+
hl_inline
24
+
: (`bool`) Whether to render the highlighted code without a wrapping container. Default is `false`.
25
+
26
+
lineAnchors
27
+
: (`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`.
28
+
29
+
lineNoStart
30
+
: (`int`) The number to display at the beginning of the first line. Irrelevant if `lineNos` is `false`. Default is `1`.
31
+
32
+
lineNos
33
+
: (`bool`) Whether to display a number at the beginning of each line. Default is `false`.
34
+
35
+
lineNumbersInTable
36
+
: (`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`.
37
+
38
+
noClasses
39
+
: (`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`.
40
+
41
+
style
42
+
: (`string`) The CSS styles to apply to the highlighted code. See the [style gallery] for examples. Case-sensitive. Default is `monokai`.
43
+
44
+
tabWidth
45
+
: (`int`) Substitute this number of spaces for each tab character in your highlighted code. Irrelevant if `noClasses` is `false`. Default is `4`.
46
+
47
+
wrapperClass
48
+
{{< new-in 0.140.2 >}}
49
+
: (`string`) The class or classes to use for the outermost element of the highlighted code. Default is `highlight`.
50
+
51
+
{{% note %}}
52
+
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
53
+
54
+
lineNos=inline
55
+
: equivalent to `lineNos=true` and `lineNumbersInTable=false`
56
+
57
+
lineNos=table
58
+
: equivalent to `lineNos=true` and `lineNumbersInTable=true`
The `transform.Highlight` shortcode takes three arguments.
25
+
26
+
CODE
27
+
: (`string`) The code to highlight.
23
28
24
29
LANG
25
-
: The language of the code to highlight. Choose from one of the [supported languages]. Case-insensitive.
30
+
: (`string`) The language of the code to highlight. Choose from one of the [supported languages]. This value is case-insensitive.
26
31
27
32
OPTIONS
28
-
: A map or comma-separated list of zero or more options. Set default values in [site configuration].
29
-
30
-
## Options
31
-
32
-
anchorLineNos
33
-
: (`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`.
34
-
35
-
codeFences
36
-
: (`bool`) Whether to highlight fenced code blocks. Default is `true`.
37
-
38
-
guessSyntax
39
-
: (`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`.
40
-
41
-
[lexer]: /getting-started/glossary/#lexer
42
-
43
-
{{% note %}}
44
-
The Chroma syntax highlighter includes lexers for approximately 250 languages, but only 5 of these have implemented automatic language detection.
45
-
{{% /note %}}
46
-
47
-
hl_Lines
48
-
: (`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.
49
-
50
-
hl_inline
51
-
: (`bool`) Whether to render the highlighted code without a wrapping container.Default is `false`.
52
-
53
-
lineAnchors
54
-
: (`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`.
55
-
56
-
lineNoStart
57
-
: (`int`) The number to display at the beginning of the first line. Irrelevant if `lineNos` is `false`. Default is `1`.
58
-
59
-
lineNos
60
-
: (`bool`) Whether to display a number at the beginning of each line. Default is `false`.
33
+
: (`map or string`) A map or space-separate key-value pairs wrapped in quotation marks. Set default values for each option in your [site configuration]. The key names are case-insensitive.
61
34
62
-
lineNumbersInTable
63
-
: (`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`.
64
-
65
-
noClasses
66
-
: (`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`.
67
-
68
-
style
69
-
: (`string`) The CSS styles to apply to the highlighted code. See the [style gallery] for examples. Case-sensitive. Default is `monokai`.
70
-
71
-
tabWidth
72
-
: (`int`) Substitute this number of spaces for each tab character in your highlighted code. Irrelevant if `noClasses` is `false`. Default is `4`.
73
-
74
-
wrapperClass
75
-
{{< new-in 0.140.2 >}}
76
-
: (`string`) The class or classes to use for the outermost element of the highlighted code. Default is `highlight`.
77
-
78
-
{{% note %}}
79
-
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
80
-
81
-
lineNos=inline
82
-
: equivalent to `lineNos=true` and `lineNumbersInTable=false`
83
-
84
-
lineNos=table
85
-
: equivalent to `lineNos=true` and `lineNumbersInTable=true`
Although you can call this shortcode using the `{{</* */>}}` notation, computationally it is more efficient to call it using the `{{%/* */%}}` notation as shown above.
0 commit comments