aboutsummaryrefslogtreecommitdiff
path: root/emcollect
blob: c0f7759426544417df8ce80c55a59bbebcc920dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/awk -f

# aux/emcollect -- collect hyperlink references in em source

function collect(line) {
	left = $0
	right = $0
	sub("^ \\[", "", left)
	sub("\\].*$", "", left)
	sub("^ \\[[0-9]+\\] <", "", right)
	sub(">$", "", right)
	printf "%s=%s\n", left, right
}

BEGIN { expectblock = 1 }

/^$/							{ expectblock = 1; getline }
expectblock && /^ \[[0-9]+\] /	{ block = "nl"; expectblock = 0 }
block = "nl" && /^ \[[0-9]+\] <(\.\/.*|\.\.\/.*|#.*|.*\/.*)>$/	{ collect($0); next }