@@ -17,6 +17,7 @@ usage()
1717 echo
1818 echo " Options:"
1919 echo " --help Print this usage and exit."
20+ echo " --no-toc Do not include each issue in table of contents"
2021 echo " --intros Read a block of HTML text from standard input"
2122 echo " as an introductory paragraph for each status."
2223 echo " --nad Include Tentatively NAD issues in the report."
@@ -37,10 +38,12 @@ die()
3738intros=no
3839nad=no
3940ts=no
41+ toc=yes
4042while [[ " $1 " == --* ]]
4143do
4244 case " $1 " in
4345 --help) usage ; exit ;;
46+ --no-toc) toc=no ;;
4447 --intros) intros=yes ;;
4548 --nad) nad=yes ;;
4649 --ts) ts=yes ;;
@@ -89,7 +92,7 @@ dump_issues()
8992 count=$( echo " ${issues[$st]} " | wc -w)
9093 echo " Processing $count $st issues ..." >&2
9194 test $count -ne 0 || continue
92- printf ' <h2 id="%s">%s Issues</h2>\n' " ${anchors[$st]} " " $st "
95+ printf ' <h2 id="%s">%s Issues</h2>\n\n ' " ${anchors[$st]} " " $st "
9396 if [ " $intros " = " yes" ]
9497 then
9598 echo " * Enter HTML text, followed by EOF (Ctrl-D on UNIX):" >&2
@@ -122,6 +125,33 @@ dump_issues()
122125 done
123126}
124127
128+ dump_toc ()
129+ {
130+ # for each status
131+ st=" $1 "
132+
133+ count=$( echo " ${issues[$st]} " | wc -w)
134+ echo " Summarizing $count $st issues ..." >&2
135+ test $count -ne 0 || return
136+ echo " ${issues[$st]} " | while read i
137+ do
138+ if [[ $ts = no ]]
139+ then
140+ match=$( grep -o ' ^<title>\[[^]]\+\.ts\.[^]]\+]' " xml/issue$i .xml" )
141+ if [[ $match ]]
142+ then
143+ continue
144+ fi
145+ fi
146+ printf ' <li><a href="#%d">%d</a>.\n' $i $i
147+ # Extracting just the <title> from the HTML is tricky, due to some
148+ # multiline titles like issue2642.html so extract from the XML instead.
149+ xpath -q -e ' /issue/title/node()' xml/issue$i .xml \
150+ | sed -E -e ' s;`([^`]+)`;<code>\1</code>;g' # replace backticks
151+ printf ' \n</li>\n'
152+ done
153+ }
154+
125155cat << EOT
126156<!DOCTYPE HTML>
127157<html lang="en">
171201for st in " ${statuses[@]} "
172202do
173203 [ -n " ${issues[$st]} " ] || continue
174- printf ' <li><a href="#%s">%s Issues</a></li>\n' " ${anchors[$st]} " " $st "
204+ printf ' <li><a href="#%s">%s Issues</a>' " ${anchors[$st]} " " $st "
205+ if [[ $toc = yes ]]
206+ then
207+ printf ' \n<ul>\n'
208+ dump_toc " $st "
209+ printf ' </ul>\n'
210+ fi
211+ printf ' </li>\n'
175212done
176213echo ' </ul>'
177214
0 commit comments