TERMINAL MARKDOWN


Terminal markdown works much like markdown. Text is styled by wrapping it in special characters.

The association of characters to styles is

For the colors, the association is:

l : Black L : White ('l' for 'lightness')
r : Red R : Bright Red
g : Green G : Bright Green
y : Yellow Y : Bright Yellow
b : Blue B : Bright Blue
m : Magenta M : Bright Magenta
c : Cyan C : Bright Cyan

So, for example, if you type the following into your terminal:

    % echo '$Hello$ *^yWorld^*!' | tmd

you'll get the following displayed on the terminal:

    Hello World!

Piping allows combination with other programs:

    % cat intro.tmd | tmd
    % curl -s https://raw.githubusercontent.com/Evoniuk/terminal-markdown/master/intro.tmd | tmd

For longer text it might be easier to put your text into files and call tmd like so:

    % tmd file1 file2 ...

Use as a library

You can use tmd as a C library by #include-ing tmd.h and compiling with tmd.c. This provides three functions:

char* substitute_escapes(char* string, bool format) will return the formatted version of text if format is true, and the unformatted version if format is false. The return value of this function will need to be freed.

void format_and_print(char* text, bool format) will print and format your text if format is true. It will print unformatted text (the same text but without any styling) if format is false.

char* escape_all(char* text) will return text but with all special characters escaped with a backslash. This is useful if you have text (such as source code) with special characters you want to style with tmd.