Last active
August 29, 2015 14:25
-
-
Save adammichaelwood/cf6212e15f0721350113 to your computer and use it in GitHub Desktop.
Renders markdown files to usable HTML, changes the file name, and moves them to the proper output directory
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/sh | |
myname=adamwood | |
#change that to your name | |
month=$(date +"%b") | |
mo=$( tr '[A-Z]' '[a-z]' <<< $month) | |
yr=$(date +"%y") | |
mdfile="$1.md" | |
hfile="../html/$1-$myname-$mo-$yr.html" | |
pandoc -f markdown -S -o $hfile $mdfile | |
sed -i '' -e "s/’/\’/g" -e "s/‘/\‘/g" -e 's/“/\“/g' -e 's/”/\”/g' -e 's/—/\—/g' -e 's/–/\–/g' $hfile | |
open -a "Sublime Text" $hfile | |
# exiting so I can provide built-in README, since there are no comment blocks in bash | |
exit | |
##README## | |
' | |
This uses pandoc to render markdown files into html files, with some little added things: | |
i keep my original source files with just the topic-specific name and the .md extension in a directory called source | |
this renames them to the format WIHT likes (with my name and the month in the title) and puts those files into the html directory | |
(aside -- when I invoice, I move the files into a subdirectory labelled /invoiced --- so i always know what i have and have not invoiced for) | |
the pandoc output automatically turns straight quotes into curly quotes | |
the sed command replaces the curly quotes with the propery HTML character entity, so that they display correctly in ALL contexts, regardless of character set being used | |
pandoc also add automatic id tags to all headings, which is sometimes a good thing. sometime it is not desired and I manually add the correct flag into that line locally | |
(TO DO - allow this as an option on the command line when running) | |
the open command pops the rendered output up in my favorite editor so i can glance at it real quick and make sure everythign looks alright | |
TO INSTALL | |
drop this file into your executable path (i keep it in my user-specific /bin folder) | |
change myname to your name | |
TO RUN | |
$> rend.sh name-of-markdown-file-with-no-extension | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment