Ruoshan's jiffies

About Archive

A handy script for auto generating markdown file to html.

On 16 Aug 2013, By Ruoshan Huang

a handy script

to auto generate markdown to html everytime I update the markdown file, and preview in Firefox. I wrote this scipt as followed,

#!/bin/bash
# a handy script to regenerate the markdown file once modified.
# please install the inotify-tools.
# USAGE:
#   $ cd to_your_directory
#   $ bash imarkdown.sh *.markdown
#
# by Ruoshan Huang

inotifywait -qm -e close_write --format "%w" *.markdown |while read f; do
    if [ -z "$f" ]; then
        exit 1
    fi
    html=${f/%markdown/html}
    echo "markdown generated: ${html}"
    markdown "$f" > "$html"
done


requirement

please install these softs first:

  • sudo apt-get install inotify-tools markdown
  • for Firefox, please install the Auto Reload Addon


notice

the script can only deal with suffix “.markdown”, modify it to see you fit.