2021-07-30 11:51:31 -07:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
# ghmd - format GitHub markdown
|
|
|
|
# via: https://leahneukirchen.org/dotfiles/.zshrc
|
|
|
|
# example: ghmd < README.md > README.html
|
|
|
|
# YES_ZSH
|
|
|
|
# YES_BASH
|
|
|
|
# YES_DASH
|
|
|
|
|
2021-07-30 19:41:16 -07:00
|
|
|
ghmd() { ### @-
|
2021-08-01 09:27:25 -07:00
|
|
|
### convert a markdown file to HTML in the style of GitHub.
|
|
|
|
### note that this uses GitHub's API, so it requires internet connectivity.
|
|
|
|
###
|
|
|
|
### this script utilizes the CSS provided at
|
|
|
|
### [sindresorhus/github-markdown-css.](https://github.com/sindresorhus/github-markdown-css)
|
2021-08-01 09:45:19 -07:00
|
|
|
###
|
|
|
|
### ```
|
|
|
|
### ~/sh/ghmd < ~/rc/README.md > ~/rc/README.html
|
|
|
|
### ```
|
2021-07-30 11:51:31 -07:00
|
|
|
printf '%s' '<!DOCTYPE html><html><head><meta charset="utf-8"><link ' \
|
|
|
|
'href="https://eaguru.guru/t/github-markdown.css" ' \
|
|
|
|
'media="all" rel="stylesheet" type="text/css"/></head><body ' \
|
|
|
|
'style="box-sizing: border-box; min-width: 200px; max-width: 980px; ' \
|
|
|
|
'margin: 0 auto; padding: 45px;"><article class="markdown-body">'
|
|
|
|
curl -s --data-binary @- -H 'Content-Type: text/plain' \
|
|
|
|
https://api.github.com/markdown/raw
|
|
|
|
local ret=$?
|
|
|
|
printf '%s' '</article></body></html>'
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
[ -n "${preload+-}" ] || ghmd "$@"
|