1#!/bin/sh 2# 3# $Id: add_html_refs.sh,v 1.7 2002/08/18 18:43:21 moniot Rel $ 4# 5# Script to insert links from all occurrences of each ftnchek option 6# to the main description of the option in ftnchek.html. 7# 8# Author: Robert Moniot 9# Date: 19 Jul 1998 10# Originally written for use with PolyglotMan (rman) 11# Modified for use with vh-man2html 22 Apr 2001 12# 13# Get list of all ftnchek main options, excluding the leading '-'. 14# Turn it into a list of sed substitutions to change them into hrefs. 15# The href is "#option" (without the -). The substitutions look for -opt 16# preceded by non-letter so that, e.g. f77's param-intrinsic won't match 17# -intrinsic. This will fail if a real option comes at the start of a 18# line, but that shouldn't happen since man-to-html converter puts bolding 19# around them. 20 21ftnchek -help | \ 22 awk '/^ *-/ {split($0,opt); 23 sub(/\[no\]/,"",opt[1]); 24 sub(/=.*$/,"",opt[1]); 25 sub(/^-/,"",opt[1]); 26 printf("s,\\([^a-z]\\)-%s,\\1<A HREF=\"#%s\">-%s</A>,g\n", 27 opt[1],opt[1],opt[1]); 28 }' \ 29 > option_sub.sed 30 31# Now create the cross-references. 32 33# The tr command substitutes quote marks for the <BEL> characters that 34# vh-man2html substutes for quote marks. 35# The first sed command deletes any Content-type header intended for cgi use, 36# and creates and attaches anchors to all the option descriptions in 37# OPTIONS section. 38# The second sed substitutes hot-links to these anchors at all the places 39# where the options occur in the entire text. 40# The third sed puts hot-links in for the -[no]options in SYNOPSIS section 41# that are not recognized by the second sed. 42tr '\007' '"' | 43sed -e '/^Content-type:/d' \ 44 -e '/<H2>OPTIONS<\/H2>/,/<H2>.*<\/H2>/s,^<DT><B>-\([a-z][-a-z0-9]*\)[^<]*</B>,<A NAME="\1"></A>&,' | \ 45sed -f option_sub.sed | \ 46sed -e '/<H2>SYNOPSIS<\/H2>/,/<H2>.*<\/H2>/s,<B>-</B>\[<B>no</B>\]<B>\([a-z][-a-z0-9]*\),<A HREF="#\1">&</A>,g' 47 48 49