Created
January 28, 2016 14:36
-
-
Save epochblue/21e1a7882cde6f90abb4 to your computer and use it in GitHub Desktop.
A bash function to convert a file into Github-flavored Markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This function requires `jq` be installed. | |
# On OS X, you can install jq via Homebrew: `brew install jq` | |
function markdown { | |
in=$1 | |
if [ -z "$in" ]; then | |
echo "Error: No input file specified" | |
return 1 | |
fi | |
out=$2 | |
if [ -z "$out" ]; then | |
out="$HOME/Desktop/markdown.html" | |
fi | |
jq --slurp --raw-input '{"text": "\(.)", "mode": "markdown"}' < "$in" | curl -s --data @- https://api.github.com | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment