Welcome to mirror list, hosted at ThFree Co, Russian Federation.

_index.md « highlightjs-linenumbers-example « content « exampleSite - github.com/dzello/reveal-hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: efc66c3cc12fcfa3f5fea27b73df686d65206419 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
+++
title = "Reveal.js 3.9.0 highlighting example"
outputs = ["Reveal"]

[reveal_hugo]
theme = "white"
highlight_theme = "vs"
+++

## New highlighting features Presentation

---

This presentation shows the use of the [new highlighting features](https://github.com/hakimel/reveal.js/blob/master/README.md#step-by-step-highlights) which were introduced with Reveal.js [v3.9.0](https://github.com/hakimel/reveal.js/releases/tag/3.9.0)

---

## Prerequisite

First, disable `CodeFences` in to your `config.toml`:

{{< highlight toml "style=github" >}}
[markup.highlight]
codeFences = false
{{< /highlight >}}

---
## Theme

Specify a theme for Highlight.js in `config.toml`

{{< highlight toml "style=github" >}}
[params.reveal_hugo]
highlight_theme = "github"
{{< /highlight >}}

or in the `frontmatter`

{{< highlight toml "style=github" >}}
[reveal_hugo]
highlight_theme = "github"
{{< /highlight >}}

---

## Usage

The line highlighting is configured by adding `{}` immediately after the language selection of the markdown code block.

{{< highlight md >}}  
```foo{}

```
{{< /highlight >}}

---

## Just line numbers

`{}`

{{< highlight md >}}  
```go{}
package main
import "fmt"
func main() {
    fmt.Println("Hello world!")
}
```
{{< /highlight >}}
   
```go{}
package main
import "fmt"
func main() {
    fmt.Println("Hello world!")
}
```

---

## Highlight specific lines

`{<line numbers separated by comma>}`

{{< highlight md >}}
```go{1,3-5}
package main
import "fmt"
func main() {
    fmt.Println("Hello world!")
}
```
{{< /highlight >}}
```go{1,3-5}
package main
import "fmt"
func main() {
    fmt.Println("Hello world!")
}
```

---

## Multi step highlight

`{<line numbers separated by pipe>}`

{{< highlight md >}}
```go{1|2|3-5}
package main
import "fmt"
func main() {
    fmt.Println("Hello world!")
}
```
{{< /highlight >}}

```go{1|2|3-5}
package main
import "fmt"
func main() {
    fmt.Println("Hello world!")
}
```
---

## Hiding the line numbers

There is no Reveal.js parameter to use line highlighting *without* line numbers. 
However it can be achieved by adding the some [custom CSS](https://github.com/dzello/reveal-hugo#adding-html-to-the-layout).

{{< highlight html "style=github" >}}
<style>
  .hljs-ln-numbers {
    display: none;
  }
</style>
{{< /highlight >}}

<small>💡 Tip: To hide line numbers for every presentation, put it here:</small>

```text
layouts/partials/reveal-hugo/body.html
```