SHMD: Shell markdown preprocessor

SHMD: Shell markdown preprocessor

shmd extends the markdown markup language to allow for embedding the result of shell commands in documents.

Source Code


$ shmd < >
$ shmd < | markdown > myhtmlfile.html
$ shmd << EOF
> # Example shmd
> The date is \Wed Nov 30 08:48:55 AEDT 2022
> Current user \djl
> CPU model \



The syntax for embedding a command is \, e.g.

Build date: \Wed Nov 30 08:48:55 AEDT 2022 => Build date: Wed Nov 30 08:48:55 AEDT 2022

The syntax for creating a header section is /*\nname value\n*/, e.g.

title "SHMD: Shell markdown preprocessor"
 * author "Dylan Lom"
 * link stylesheet /main.css
 * hellofunc() "echo hello $1"

Values with spaces should be quoted with either double (“) or single (‘) quotations.

You can pad each line in the header section with non-alphabetical characters, as demonstrated in the third line in the example.

The following head elements are recognised as HTML elements and may have specific syntaxes

Anything else will create a meta tag, with name=name and content=value.

Everything declared in the header section will be available as a shell variable, (e.g. $title will contain the value of title).

Functions declared in the title should be suffixed by (), as demonstrated in the fifth line in the example, and can be invoked as per a regular user-defined shell function (e.g. hellofunc $author).