dotfiles/scripts/mkgist
2022-02-07 00:32:28 +01:00

26 lines
488 B
Bash
Executable file

#!/usr/bin/env zsh
FILE="$1"
DEST="$2"
command_exists () {
whence -- "$@" &> /dev/null
}
if ( ! command_exists markdown2htmldoc ); then
echo "md2htmldoc not found. Exiting."
exit 1
fi
filename=$(basename -- "$FILE")
extension="${filename##*.}"
filename="${filename%.*}"
content=$(cat "$FILE")
md_content="# \`$filename.$extension\`\n\n\`\`\`$extension\n$content\n\`\`\`"
echo "$md_content" > temp.md
markdown2htmldoc temp.md "$DEST/$filename.$extension.html"
rm -rf temp.md