-
-
Save dirkakrid/7110ae72d99c302588c61d6409205573 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
# Download HTML converted from provided Markdown, using GitHub API v3 | |
## | |
md2html(){ | |
if [[ $# -ne 2 ]]; then | |
echo "ERROR.\nSYNTAX: Markdown_To_HTML <markdown-filepath> <dest-html-filepath>" | |
return | |
fi | |
unset _markdown_filepath | |
unset _html_filepath | |
unset _github_json_filepath | |
unset _markdown_for_github | |
_markdown_filepath=$1 | |
_html_filepath=$2 | |
_github_json_filepath="${_markdown_filepath}.json" | |
sed -i 's/$/\\n/g' $_markdown_filepath | |
sed -i 's/"/\\"/g' $_markdown_filepath | |
echo "{ \"text\" : \"" > $_github_json_filepath | |
cat $_markdown_filepath >> $_github_json_filepath | |
echo "\" }" >> $_github_json_filepath | |
cat $_github_json_filepath | curl -sLk -X POST -d@- https://api.github.com/markdown > $_html_filepath | |
rm $_github_json_filepath | |
echo "Successful conversion of ${_markdown_filepath} to ${_html_filepath}." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment