Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpillora/md-tmpl
Simple markdown templating using shell commands
https://github.com/jpillora/md-tmpl
Last synced: 3 months ago
JSON representation
Simple markdown templating using shell commands
- Host: GitHub
- URL: https://github.com/jpillora/md-tmpl
- Owner: jpillora
- License: mit
- Created: 2015-03-16T08:04:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-05-19T12:52:36.000Z (over 5 years ago)
- Last Synced: 2024-06-19T09:12:54.929Z (7 months ago)
- Language: Go
- Size: 18.6 KB
- Stars: 4
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# md-tmpl
Simple markdown templating using shell commands
:warning: If you only need to `cat` files, please use https://github.com/campoy/embedmd instead.
### Install
**Binaries**
See [Releases](https://github.com/jpillora/md-tmpl/releases)
**Source**
```sh
$ go get -v github.com/jpillora/md-tmpl
```### Usage
```
$ mk-tmpl
``````plain
Usage: md-tmpl [options] [files...]
Options:
--preview, -p Enables preview mode. Displays all commands encountered.
--write, -w Write file instead of printing to standard out
--help, -h```
Insert templates in the form:
```xml
```
where `command` is a shell command and `option`s are listed below
#### Options
- `chomp` - trims any trailing newline generated by `command`
- `code` - wraps the output of `command` in triple backticks### Examples
Create a `foo.md` with a template tag
```markdown
_Updated on _
```Then you execute the templates and rewrite `foo.md` with:
```
$ md-tmpl -w foo.md
```Now, `foo.md` should be:
```markdown
_Updated on Sun 31 Mar 2019 00:41:18 AEDT_
```And appear will test display on Github, like:
_Updated on Sun 31 Mar 2019 00:41:18 AEDT_
### More Examples
- Dynamic examples (`cat examples/foo`)
- Usage text (`prog --help`)
- Update timestamps (`date`)### :warning: Warnings
- Malicious tags. Commands are run by piping strings straight into `bash`. If you think someone has slipped a `rm -rf /` in one of your markdown files, you can view all nested commands with the `--preview, -p` option.
- Currently it has only been tested on Markdown hosted on Github (GFM).
- You cannot use `>` in your commands as it marks the end of the command by closing the tag, use `>` instead.#### MIT License
Copyright © 2019 Jaime Pillora <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.