\section{Weaving a {\tt noweb} file into a \TeX file} The copyright applies both to the {\tt noweb} source and to the generated shell script. <>= # Copyright 1991-1997 by Norman Ramsey. All rights reserved. # See file COPYRIGHT for more information. # $Id: noweave.nw,v 1.7 2008/10/06 01:03:24 nr Exp $ @ Here's the organization of the source: <>= #!/bin/sh <> <> <> <> | $backend $noindex $delay $shortxref exit $? <>= if [ -n "$verbose" ]; then echo $backend $noindex $delay $shortxref 1>&2; fi @ The first item of initialization is to locate the {\tt noweb} library. <>= LIB=|LIBDIR| @ <>= markup=$LIB/markup backend=$LIB/totex wrapper= delay= args= markopts= noweboptions= autodefs= verbose= shortxref= noquote="-noquote" docanchor= noindex="-noindex" filtera= filterb= filterc= filterd= filtere= filterf= filterg= # following supported by change in totex back end noquote= @ I make two passes over the arguments so as not to require that options be given in a certain order <>= pass2setcmd="set ignore" for i do pass2setcmd="$pass2setcmd '$i'" done arg= while [ $# -gt 0 ]; do case $1 in <> -) arg="$arg $1" ;; -*) echo "$0: Unrecognized option '$1'" 1>&2 ; <>; exit 1 ;; *) arg="$arg $1" ;; esac shift done <> if [ -z "$wrapper" ]; then wrapper=latex; fi eval $pass2setcmd shift while [ $# -gt 0 ]; do case $1 in <> esac shift done <>= pass2args="$*" while [ $# -gt 0 ]; do case $1 in <> -*) echo "$0: Unrecognized option '$1'" 1>&2 ; <>; exit 1 ;; *) arg="$arg $1" ;; esac shift done if [ -z "$wrapper" ]; then wrapper=latex; fi if [ -n "$pass2args" ]; then set ignoreme $pass2args shift while [ $# -gt 0 ]; do case $1 in <> esac shift done fi <>= if [ -z "$noweboptions" ] ; then noweboptions="$newopt" else noweboptions="$noweboptions,$newopt" fi <>= -latex) if [ "$wrapper" != "none" ]; then wrapper=latex; fi ;; -tex) wrapper=tex ;; -html) if [ "$wrapper" != "none" ]; then wrapper=html; fi; backend="$LIB/tohtml -localindex" noquote=""; docanchor="-docanchor 10" ;; -latex+html) if [ "$wrapper" != "none" ]; then wrapper=latex; fi; backend="$LIB/tohtml -localindex -raw" noquote=""; docanchor="-docanchor 10" ;; -ascii) wrapper=none backend="$LIB/toascii" ;; -troff) wrapper=mm backend="$LIB/toroff" ;; -n) wrapper=none ;; -backend) backend="$2" ; shift ;; -markup) markup="$2" ; shift ;; @ Note some versions of echo break on [[echo "-n..."]], echoing nothing at all. The leading space is claimed to prevent this problem. <