summaryrefslogtreecommitdiff
path: root/web/noweb/src/lib/btdefn
blob: a7b2d1678d03456f824ac8e4eb33e58381d10004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh

# turn backticks into definitions

nawk '
/^@begin code / { code = 1 }
/^@end code / { code = 0 }
code && /^@text .*".*`.*"/ { print; next }
code && /^@text .*`/ {
  while (i = match($0, /`[a-zA-Z_][a-zA-Z0-9_]*/)) {
    id = substr($0, i+1, RLENGTH-1)
    sub(/`[a-zA-Z_][a-zA-Z0-9_]*/, id)
    print "@index defn " id
  }
}
{print}'