Skip to content

Instantly share code, notes, and snippets.

@sochoa
Last active December 30, 2015 16:18
Show Gist options
  • Save sochoa/7853422 to your computer and use it in GitHub Desktop.
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. :)
#!/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}"
}
@sochoa
Copy link
Author

sochoa commented Dec 8, 2013

I just realized that the Markdown.pl script doesn't add css. :( So, I added a few lines to prepend a nice markdown stylesheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment