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 options.
shorthand --help
Source code can be found at github.com/rsdoiel/shorthand
The project website is rsdoiel.github.io/shorthand
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 @now
From the command line you can do something like this
shorthand -e ':bash: @now date' \
-e ":import: @report testdata/report.md" \
-e "@report" \
-e ':exit:' | pandoc -s > testdata/report.html
What this command does is launch the shorthand interpreter and it replaces all occurrences of "@now" in the markdown 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 2015
Notice that both "@now" are replace with the same date information.
You could also embed the shorthand definitions command straight in the markdown itself. with something like
@now :bash: 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 @now
That makes the command line a little shorter
shorthand testdata/report.md | pandoc -s > testdata/report.html
shorthand can be installed with the go get command.
go get github.com/rsdoiel/shorthand/...