blob: 279254ccef9274f016cbdf61adb0acee30aee7cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
+++
title = "Hugo highlighting example"
outputs = ["Reveal"]
[reveal_hugo]
theme = "simple"
+++
## Hugo Highlighter Presentation
This is an example of a presentation using Hugo's compile-time syntax highlighter.
---
Reveal.js uses Javascript for syntax highlighting (via Highlight.js). This might slow the presentation down if many slides contain code.
---
Hugo has a built-in [compile-time highlighter](https://gohugo.io/content-management/syntax-highlighting/), and it's lightning fast too!
---
You can enable it using the `highlight` shortcode.
{{< highlight go >}}
{{</* highlight go */>}}
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}
{{</* /highlight */>}}
{{< /highlight >}}
---
Several options are supported, check [Hugo's documentation](https://gohugo.io/content-management/syntax-highlighting/).
{{< highlight go "style=github,linenos=inline,hl_lines=8" >}}
{{</* highlight go "style=github,linenos=inline,hl_lines=6" */>}}
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}
{{</* /highlight */>}}
{{< / highlight >}}
---
You can also use Hugo's highlighter in markdown code fences,
by putting this in `config.toml`:
{{< highlight toml "style=github" >}}
# use Hugo's hl in markdown (with or without a language tag)
[markup.highlight]
codeFences = true
style = "github"
{{< /highlight >}}
(This can only be enabled globally for all presentations.)
---
- Highlight.js is automatically disabled in code blocks highlighted by Hugo.
- The two highlighters can be even mixed.
{{< highlight go >}}
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}
{{< / highlight >}}
```go
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}
```
---
If you don't need highlight.js at all, you can prevent it from loading.
{{< highlight toml "style=github" >}}
# This works both in config.toml and a presentation's front
# matter. Default plugins include highlight.js, so disable them
# and load those that we want manually.
[params.reveal_hugo]
load_default_plugins = false
plugins = [
"reveal-js/plugin/zoom-js/zoom.js",
"reveal-js/plugin/notes/notes.js",
]
|