aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/_posts/2021-04-09-snippets.md
blob: bda3a6fbf2967030493c43f27d62ffac197dd94e (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

                    
              











                                                       
                                                                   


                                
                                                                   
 

                                                                          












                                     













                                     
                                    








                                                                                                                             
---
title: Code snippets
category: Code
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 jekyll-theme/snippets/section.html section_id='hello' %}

This is another set of snippets:

{% include jekyll-theme/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`!

Here's a snippet which requires a horizontal scrollbar to display, it should
look OK:

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

echo AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA What a long snippet
```