shorthand
A simple label or macro expander
Example use cases:
- label or abbreviation expansion in Markdown files
- build html templates from markdown files
- compose pages from multiple markdown files
The supported command line options can be listed using the -help option.
shorthand -help
Source code can be found at github.com/rsdoiel/shorthand
The project website is rsdoiel.github.io/shorthand
Tutorial
Timestamp in Markdown file
If the content of the markdown file testdata/report.md was
Report Date: @now
# Topic: The current local time.
This report highlights the current local time of rendering this document
The current local time is @nowPut the definitions in a file of their own, now.shorthand
:bash: @now date
and give it to shorthand before the document, then render the result with pandoc
shorthand now.shorthand testdata/report.md | pandoc -s > testdata/report.html
What this command does is read the definitions, then the document, and replace all occurrences of “@now” in the document with the output from the Unix program date.
The output (before piping to Pandoc) would look something like
Report Date: Sat Aug 29 11:25:48 PDT 2015
# Topic: The current local time.
This report highlights the current local time of rendering this document
The current local time is Sat Aug 29 11:25:48 PDT 2015Notice that both “@now” are replace with the same date information.
embedding shorthand definitions
You could also embed the shorthand definitions straight in the markdown itself. with something like
:bash: @now date
Report Date: @now
# Topic: The current local time.
This report highlights the current local time of rendering this document
The current local time is @nowThat makes the command line a little shorter
shorthand testdata/report.md | pandoc -s > testdata/report.html
Installation
shorthand can be installed with the go install command.
go install github.com/rsdoiel/shorthand/cmd/shorthand@latest