Skip to content

Instantly share code, notes, and snippets.

@epochblue
Created January 28, 2016 14:36
Show Gist options
  • Save epochblue/21e1a7882cde6f90abb4 to your computer and use it in GitHub Desktop.
Save epochblue/21e1a7882cde6f90abb4 to your computer and use it in GitHub Desktop.
A bash function to convert a file into Github-flavored Markdown
# 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