Last active
December 30, 2015 16:18
-
-
Save sochoa/7853422 to your computer and use it in GitHub Desktop.
I added a function to my bashrc to render to markdown that I could reuse in Vim. :)
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
#!/bin/bash | |
# I renamed Markdown.pl to markdown for simpler typing. | |
function to_markdown() { | |
local src="${1}" | |
if [ -z "${src}" ]; then | |
echo "no source" | |
return | |
fi | |
if [ ! -f "${src}" ]; then | |
echo "src doesn't exist" | |
return | |
fi | |
if ! which markdown &>/dev/null ; then | |
echo "Markdown not installed" | |
fi | |
src="$(python -c "import os; print os.path.abspath(\"${src}\")")" | |
dest="$(echo "${src}" | sed 's/\.md$/.html/g')" | |
# adding some style | |
echo "<style>" >> "${dest}" | |
cat "${HOME}/md.css" >> "${dest}" | |
echo "</style>" >> "${dest}" | |
markdown "${src}" --html4tags >> "${dest}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just realized that the Markdown.pl script doesn't add css. :( So, I added a few lines to prepend a nice markdown stylesheet.