1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-12 15:49:03 -08:00
rc/sh/ghmd
Connor Olding d5f3f14d72 merge compatibility lines
RIP meaningful last-modified dates
2024-03-26 15:08:14 -07:00

31 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env sh
# ghmd - format GitHub markdown
# via: https://leahneukirchen.org/dotfiles/.zshrc
# example: ghmd < README.md > README.html
# YES_ZSH YES_BASH YES_DASH YES_ASH
ghmd() { ### @-
### 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)
###
### ```
### ~/sh/ghmd < ~/rc/README.md > ~/rc/README.html
### ```
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"/><style type="text/css">' \
'@media (prefers-color-scheme: dark) { body { background: black; } }' \
'</style></head><body style="box-sizing: border-box; min-width: 200px; ' \
'max-width: 980px; margin: 0 auto;"><article class="markdown-body" ' \
'style="padding: 45px;">'
curl -s --data-binary @- -H 'Content-Type: text/plain' \
https://api.github.com/markdown/raw
local ret=$?
printf '%s' '</article></body></html>'
return $ret
}
[ -n "${preload+-}" ] || ghmd "$@"