Code snippets

 code   2021-04-09

It’s pretty simple, just use the corresponding include:

hello.hpp
#pragma once

void hello_snippets();
hello.cpp
#include "world.hpp"

#include <iostream>

void hello_snippets() {
    std::cout << "Hello snippets!\n";
}

This is another set of snippets:

world.hpp
#pragma once

void hello_world();
world.cpp
#include "world.hpp"

#include <iostream>

void hello_world() {
    std::cout << "Hello world!\n";
}

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:

#!/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