summaryrefslogtreecommitdiff
path: root/src/htmlbody
blob: e4e56928aae7a69edbcd11bdf75a0ee846c23594 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
set -euo pipefail


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 -