summaryrefslogtreecommitdiff
path: root/src/htmlbody
diff options
context:
space:
mode:
Diffstat (limited to 'src/htmlbody')
-rwxr-xr-xsrc/htmlbody26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/htmlbody b/src/htmlbody
index 53a4485..e4e5692 100755
--- a/src/htmlbody
+++ b/src/htmlbody
@@ -1,4 +1,26 @@
#!/bin/sh
-set -eu
+set -euo pipefail
-cat "${1:--}" | asciidoctor -s -
+
+usage() {
+ echo 'Usage: htmlbody FILENAME.adoc'
+}
+
+FILENAME="${1:-}"
+eval "$(assert-arg -- "$FILENAME" 'FILENAME.adoc')"
+
+
+plaintext_links() {
+ awk -v BASE="$(basename "$FILENAME" .adoc)".html l'
+ { print }
+ /^----$/ {
+ in_block = !in_block
+ if (in_block) {
+ next
+ }
+ file = BASE "." count++ ".txt"
+ print "link:" file "[plaintext,role=plaintext]"
+ }' "$1"
+}
+
+plaintext_links "$FILENAME" | asciidoctor -s -