aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_posts/2021-04-09-snippets.md
blob: a320e07a35914e25c0ada429d9134375627a1c0f (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
---
title: Code snippets
excerpt: >
  Easily include code snippets in your posts.
snippets_root_directory: snippets
snippets_language: c++
snippets:
  hello:
    - hello.hpp
    - hello.cpp
  world:
    - world.hpp
    - world.cpp
---
It's pretty simple, just use the corresponding include:

{% include snippets/section.html section_id='hello' %}

This is another set of snippets:

{% include snippets/section.html section_id='world' %}

Of course, you can insert a code snippet using the regular Markdown syntax
without any highlighting:

```
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail

main() {
    echo "Hello, world!"
}

main
```

The same with highlighting enabled:

```bash
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail

main() {
    echo "Hello, world!"
}

main
```

Also, some inline code: `./test.sh`!