aboutsummaryrefslogtreecommitdiff
path: root/src/development/genhtml.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-08-22 18:17:58 -0300
committerEuAndreh <eu@euandre.org>2022-08-22 18:17:58 -0300
commitaeb7fe69e8074f26c3e0bdfc59313f944400e6e7 (patch)
tree5bef722754d08400a1bbce212ee5751078495453 /src/development/genhtml.sh
parentpublic.asc: Update public key (diff)
downloadeuandre.org-aeb7fe69e8074f26c3e0bdfc59313f944400e6e7.tar.gz
euandre.org-aeb7fe69e8074f26c3e0bdfc59313f944400e6e7.tar.xz
src/development/: WIP work on Perl md2html
Diffstat (limited to '')
-rwxr-xr-xsrc/development/genhtml.sh70
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>