|
|
1.1 root 1: #! /bin/sh
2: : 'idx2ind - new LaTeX index converter - 11-Jul-88/JLR'
3:
4: L=%%
5: case x$1 in
6: x-l) L=""; shift ;;
7: esac
8:
9: for i
10: do
11: awk 'BEGIN {for (i = 97; i < 123; i++) # index letters "a" to "z"
12: printf "%c\n", i; exit}' |\
13: cat - $i.idx |\
14: sed \
15: -e 's/ / /g'\
16: -e 's/^\\indexentry{\(.*\)}{\([^}]*\)}$/\1 \2/'\
17: -e 's/^\\verb\(.\)\(.*\)\1 \(.*\)$/\2 \3 \\verb\1\2\1/'\
18: -e '/\\/!s/ *{}//'\
19: -e '/,/{;s/^\(.*\) \(.*\)$/\1 \2 \1/;s/,/ /;}' |\
20: sort -u -t" " +0fd -1 +1n |\
21: awk -F" " '
22: BEGIN {printf "\\begin{theindex}\\makeatletter\n"
23: printf "\\raggedright\n"
24: printf "\\def\\newindex#1{{\\huge\\hspace{-.5in}"
25: printf "\\parbox[t]{.5in}{\\makebox[.35in][c]{\\uppercase{#1}}}"
26: printf "\\vspace{-1.5ex}}}\n"
27: }
28: NF == 1 {x = $1; next} # NF=1: index letter
29: {n = $1}
30: NF == 3 {n = $3} # NF=3: special sort key
31: n == p {printf ", %s", $2; next} # another page number
32: p != "" {printf "\n"} # end of this item
33: x != "" {if (p != "") # index letter?
34: printf "\\indexspace\n"
35: printf "'$L'\\newindex{%s}\n", x
36: }
37: {x = s = ""; i = n; l = $2} # reset
38: /,/ {s = "sub" # sub-item
39: nf = split (i, a, ","); k = a[1]; i = a[2]
40: split (p, pk, ",")
41: if (pk[1] != k && pk[1] != k"{}") # should use substr...
42: {i = n; s =""}
43: else for (j = 3; j <= nf; j++) # add sub-sub-items
44: i = sprintf ("%s,%s", i, a[j])
45: }
46: {printf "\\%sitem %s, %s", s, i, l}
47: {p = n} # save for next comparison
48: END {printf "\n\\end{theindex}\n"
49: }' > $i.ind
50:
51: done
52:
53: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.