#!/bin/sh # Generates an index.html with support for rendering a README.md if present. # With -R an entire directory hierarchy can be converted. # generate-index-html [-R] set -e if [ "x$1" = "x-R" ]; then exec find "$2" -type d -exec "$0" '{}' ';' fi cd "$1" (echo 'Directory listing' if [ -f README.md ]; then lowdown -thtml --html-no-skiphtml --html-no-escapehtml README.md echo '
' fi echo -n '
'
 # Assumes a BSD ls.
 ls -Flha | grep -Ev ' (\./|index\.html|README\.md|\.git/|\.gitignore)$' | \
 cut -w -f 5- | sed -E 's|^([^\t]+\t+)([^ ]+ +)([^ ]+ +)([^ ]+ +)(.*[^*])\*?$|\1\2\3\4\5|'
 echo '
' ) >index.html