diff options
Diffstat (limited to 'src/development/genhtml.sh')
-rwxr-xr-x | src/development/genhtml.sh | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/src/development/genhtml.sh b/src/development/genhtml.sh index d48df68..631aa13 100755 --- a/src/development/genhtml.sh +++ b/src/development/genhtml.sh @@ -1,8 +1,66 @@ #!/bin/sh set -eu -MD="$1" -HTML="$(dirname "$MD")/$(basename "$MD" .md).html" +usage() { + cat <<-'EOF' | sed "s|@NAME@|$0|g" + Usage: + @NAME@ FILENAME + @NAME@ -h + EOF +} + +help() { + cat <<-'EOF' + + Options: + -h, --help show this message + + FILENAME the input markdown file + EOF +} + +for f in "$@"; do + case "$f" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) +F="${1:-}" + +assert_arg() { + if [ -z "$1" ]; then + printf 'Missing %s.\n\n' "$2" >&2 + usage >&2 + exit 2 + fi +} + +assert_arg "$F" 'FILENAME' + +HTML="$(dirname "$F")/$(basename "$F" .md).html" escape() { sed 's/a/a/' @@ -24,7 +82,9 @@ _() { langs='en pt fr eo es' # langs='' . src/development/config.env -. "${MD%.md}.env" +. "${F%.md}.env" + +# src/development/md snippets "$F" cat <<-EOF <!DOCTYPE html> @@ -91,9 +151,11 @@ awk ' should_print {print} separator == 2 && !should_print { should_print = !should_print } -' "$MD" | +' "$F" | md2html +# src/development/md render + cat <<-EOF </article> </main> |