diff options
Diffstat (limited to 'web/pwebmac')
-rw-r--r-- | web/pwebmac/README.md | 18 | ||||
-rw-r--r-- | web/pwebmac/index.md | 2 | ||||
-rwxr-xr-x | web/pwebmac/makeall | 176 | ||||
-rw-r--r-- | web/pwebmac/pwebmac.tex | 39 | ||||
-rw-r--r-- | web/pwebmac/webman.ch | 328 |
5 files changed, 385 insertions, 178 deletions
diff --git a/web/pwebmac/README.md b/web/pwebmac/README.md index cfd364de09..e85b89cbc4 100644 --- a/web/pwebmac/README.md +++ b/web/pwebmac/README.md @@ -1,7 +1,7 @@ # pwebmac – Consolidated WEB macros for DVI, PDF, and HINT output The original [WEB](https://ctan.org/pkg/web) system by Donald Knuth has the -macros `webmac.tex` that produce DVI output only; for historic reasons, it +macros `webmac.tex` that produce DVI output only; for historic reasons, they will never be modified (apart from catastrophic errors). Hàn Thế Thành has extended these macros in his (outdated?) `pdfwebmac.tex` for PDF output (only) with [pdfTeX](https://ctan.org/pkg/pdftex). @@ -19,7 +19,7 @@ for Martin Ruckert's “[HiTeX](https://ctan.org/pkg/hitex)” engine and its Its initial application is the production of PDF and HINT files for all major WEB programs for “TeX and friends” as distributed in [TeX Live](https://www.tug.org/texlive). For this purpose, the shell script -`makeall` was whipped together; it provides various commandline options and +`makeall` was whipped together; it provides various command-line options and works around several “quirks” in the WEB sources. The resulting collections of PDF and HINT documents can be browsed in the [`knuth-pdf`](https://ctan.org/pkg/knuth-pdf) and @@ -27,13 +27,15 @@ of PDF and HINT documents can be browsed in the WEB programmers who want to use `pwebmac.tex` instead of the default `webmac.tex` in their programs have to change the first line in the TeX file -created by `weave`. From there, all depends on the “TeX engine” you use: -“plain TeX” by default creates DVI output, “plain TeX” with the invocation -`tex "\let\pdf+\input…"`, `pdftex`, `luatex`, and `xetex` create PDF output -with clickable links and bookmarks (depending on your PDF viewer), and `hitex` -creates HINT output that can be viewed with the +created by `WEAVE` (try `weave -p`). From there, all depends on the “TeX +engine” you use: “plain TeX” by default creates DVI output, “plain TeX” with +the invocation `tex "\let\pdf+\input…"`, as well as `pdftex`, `luatex`, and +`xetex` create PDF output with clickable links and bookmarks (with `pdftex` +and `luatex` you are advised to apply the “`--shell-escape`” command-line +option in order to avoid an internal miscalculation in the resulting PDF +file), and `hitex` creates HINT output that can be viewed with the [`hintview`](https://hint.userweb.mwn.de/hint/hintview.html) program. The `pwebmac` package is free software and may be used without constraints. -This is version **4.10** of the `pwebmac` package — 2023-10-07, Andreas Scherer. +This is version **4.11** of the `pwebmac` package — 2023-12-02, Andreas Scherer. diff --git a/web/pwebmac/index.md b/web/pwebmac/index.md index a580c752a6..90ddc7d131 100644 --- a/web/pwebmac/index.md +++ b/web/pwebmac/index.md @@ -108,4 +108,4 @@ directly. ## Happy C/WEB Programming! -2023-06-11 Andreas Scherer +2023-12-02 Andreas Scherer diff --git a/web/pwebmac/makeall b/web/pwebmac/makeall index 602f2377c5..b5b53ff72e 100755 --- a/web/pwebmac/makeall +++ b/web/pwebmac/makeall @@ -86,60 +86,48 @@ do esac done -CWEAVE="cweave -f +lX" -CTWILL="ctwill -f +lpdf" +CWEAVE="cweave -f +lX +bph" +CTWILL="ctwill -f +lpdf +bph" +HITEX="hitex --compress" PAX="pax -wvzf" -SED_I="sed -i" # non-GNU-sed requires an extra '' argument for '-i' option. PDF=pdf # default extension for 'knuth-pdf' -HITEX="hitex --compress" +SED_I="sed -i" # non-GNU-sed requires an extra '' argument for '-i' option. +WEAVE="weave" -# HINT format -if [ hitex = "$TEX" ] -then - CTWILL="$CTWILL +P" - TEX="$HITEX" - PDF=hnt # default extension for 'knuth-hint' - PDFTOCFRONT=false # use 'hintview -h' to start with TOC page - VALID=false # HiTeX has no command-line option '--shell-escape' -fi +case "$TEX" in + hitex ) # HINT format + CTWILL="$CTWILL +P" + TEX="$HITEX" + PDF=hnt # default extension for 'knuth-hint' + PDFTOCFRONT=false # use 'hintview -h' to start with TOC page + VALID=false ;; # HiTeX has no command-line option '--shell-escape' + + pdftex | luatex ) # actually only necessary for 'pwebmac.tex' + VALID=true ;; + + * ) VALID=false ;; # plain TeX and XeTeX use different approach +esac # Valid PDF output from 'pdftex' and 'luatex': In 'pwebmac.tex' set '\countD' # to the actual number of @<named modules@>, not the number of all sections. -if ( $VALID ) +if $VALID then + NEW=true # PDF output requires 'pwebmac.tex' TEX="$TEX --shell-escape" fi +# Use alternative TeX macros more suited for PDF output. +if $NEW +then WEAVE="$WEAVE -p" +fi + # WEB and CWEB programs we want to get formatted for f in $FILES do f=$(basename $f .web) - if [ ctwill = $f ] - then - # apply tons of editorial changes to 'ctwill.w' - if [ "$HITEX" = "$TEX" ] - then ctie -m $f.w cweave.w $f-w2c.ch $f-hint.ch - else ctie -m $f.w cweave.w $f-w2c.ch $f-mini.ch - fi - cp -an $KNUTHWARE/cwebdir/*.bux . - $CTWILL $f # prime the pump - $CTWILL $f # get decent answers - - elif [ twill = $f ] - then - tie -m $f.web weave.web weave.ch weav-$f.ch - weave $f - - elif [ glue = $f ] - then - weave $f # no 'glue.ch' at this time - - elif [ hitex = $f ] - then - cweave $f # no 'hitex.ch' at this time - - elif $CHANGES + if $CHANGES && echo $f | grep -v -q -E 'twill|glue|hitex' + # These are changes in and of themselves then case $f in # CWEB programs have individual changefiles @@ -153,49 +141,48 @@ do # main WEB programs have complex change files tex | mf | pdftex | xetex ) WEBINPUTS=$KNUTHWARE/../../Work//:$WEBINPUTS: \ - weave $f $f-final ;; - - # TWILL is a change in and of itself - twill ) ;; + $WEAVE $f $f-final - # HiTeX is a stand-alone version of TeX - hitex ) ;; + # FIX: XeTeX uses '\pdfTeX' from section 114, + # which is not changed and thus 'disappears'; + # repeat in preamble. + if [ xetex = $f ] + then $SED_I -e "s/\(\\\\let\\\\maybe\)/\\\\def\\\\pdfTeX{pdf\\\\TeX}\n\1/" $f.tex + fi ;; # all other WEB codes have singular changefiles - * ) weave $f $f ;; + * ) $WEAVE $f $f ;; esac - # FIX: XeTeX uses '\pdfTeX' from section 114, which is not - # changed and thus 'disappears'; repeat in preamble. - if [ xetex = $f ] - then - $SED_I -e "s/\(\\\\let\\\\maybe\)/\\\\def\\\\pdfTeX{pdf\\\\TeX}\n\1/" \ - $f.tex - fi - # only document changed modules/sections $SED_I -e "s/\(\\\\let\\\\maybe=\)\\\\iftrue/\1\\\\iffalse/" \ $f.tex else case $f in + ctwill ) + # apply tons of editorial changes to 'ctwill.w' + if [ "$HITEX" = "$TEX" ] + then ctie -m $f.w cweave.w $f-w2c.ch $f-hint.ch + else ctie -m $f.w cweave.w $f-w2c.ch $f-mini.ch + fi + $CTWILL $f # prime the pump + $CTWILL $f ;; # get decent answers + c* | refsort | twinx | tie | hitex ) $CWEAVE $f ;; - * ) weave $f ;; + + twill ) + tie -m $f.web weave.web weave.ch weav-$f.ch + $WEAVE $f ;; + + * ) $WEAVE $f ;; esac fi - if $NEW + # 'pwebmac' is for WEB only; do nothing for CWEB programs + if $NEW && echo $f | grep -v -q -E '^c|refsort|twinx|tie|hitex' then - # use extended WEB macros for TeX Live PDF documentation - $SED_I -e "1 s/\\\\input webmac/\\\\input pwebmac/" $f.tex - # timestamp on table-of-contents page or the first page case $f in - # do nothing for CWEB programs - c* | refsort | twinx | tie ) ;; - - hitex ) - $SED_I -e "s/\(\\\\def\\\\topofcontents\)/\\\\datethis\n\\\\emergencystretch=.1\\\\hsize\n\1/" $f.tex ;; - bibtex | patgen | tangle | weave ) $SED_I -e "s/\(\\\\def\\\\title\)/\\\\datecontentspage\n\1/" $f.tex ;; @@ -247,8 +234,7 @@ FI # FIX: don't wait for Oren Patashnik. bibtex ) $SED_I -e "s/\\\\def\\\\titlepage{F}/\\\\titletrue/" $f.tex if ! $CHANGES - then - $SED_I -e "71,78d" $f.tex + then $SED_I -e "71,78d" $f.tex fi ;; # FIX: 'glue.web' obviously uses an old 'webmac.tex'. @@ -259,29 +245,27 @@ FI # appear correctly in the bookmarks, too. pdftex ) if $NEW && [ tex != "$TEX" ] && [ "$HITEX" != "$TEX" ] - then - $SED_I -e "s/\(\\\\def\\\\pdfTeX{pdf\\\\TeX}\)/\1 \\\\sanitizecommand\\\\pdfTeX{pdfTeX}\\\\sanitizecommand\\\\eTeX{e-TeX}/" \ - $f.tex + then $SED_I -e "s/\(\\\\def\\\\pdfTeX{pdf\\\\TeX}\)/\1 \\\\sanitizecommand\\\\pdfTeX{pdfTeX}\\\\sanitizecommand\\\\eTeX{e-TeX}/" $f.tex fi ;; # FIX: weave uses '\max' in name of module 173; this should # appear correctly in the bookmarks, too. weave ) if $NEW && [ tex != "$TEX" ] && [ "$HITEX" != "$TEX" ] - then - $SED_I -e "s/\(\\\\def\\\\({}\)/\\\\sanitizecommand\\\\max{max}\n\1/" \ - $f.tex + then $SED_I -e "s/\(\\\\def\\\\({}\)/\\\\sanitizecommand\\\\max{max}\n\1/" $f.tex fi ;; # FIX: purge obsolete macros from XeTeX. xetex ) $SED_I -e "/\\\\input xewebmac/d" $f.tex ;; + + # timestamp on table-of-contents page or the first page + hitex ) $SED_I -e "s/\(\\\\def\\\\topofcontents\)/\\\\datethis\n\\\\emergencystretch=.1\\\\hsize\n\1/" $f.tex ;; esac # shift table-of-contents pages to the front in PDF - if $PDFTOCFRONT && [ ctwill != $f ] && [ hitex != $f ] + if $PDFTOCFRONT && echo $f | grep -v -q -E 'ctwill|hitex' then - $SED_I -e "0,/\\\\N[1{]/s/\(\\\\N[1{]\)/\\\\input pdfwebtocfront\n\n\1/" \ - $f.tex + $SED_I -e "0,/\\\\N[1{]/s/\(\\\\N[1{]\)/\\\\input pdfwebtocfront\n\n\1/" $f.tex # only XeTeX can process XETEX.WEB if [ xetex = $f ] @@ -295,24 +279,24 @@ FI fi fi - if [ xetex = $f ] # only XeTeX can process XETEX.WEB - then $f $f - elif [ ctwill = $f ] # gives two different outcomes - then - # sort mini-indexes - if [ "$HITEX" = "$TEX" ] - then # directly in the TeX file - proofsort $f.tex > $f-sorted.tex - mv $f-sorted.tex $f.tex - else # in the TeX-created .ref file - $TEX $f - ctwill-refsort < $f.ref > $f.sref - fi - $TEX $f - elif [ refsort = $f ] - then $TEX -interaction nonstopmode $f - else $TEX $f - fi + case $f in + xetex ) $f $f ;; # only XeTeX can process XETEX.WEB + + ctwill ) # gives two different outcomes + if [ "$HITEX" = "$TEX" ] # sort mini-indexes + then # directly in the TeX file + ctwill-proofsort < $f.tex > $f-sorted.tex + mv $f-sorted.tex $f.tex + else # in the TeX-created .ref file + $TEX $f + ctwill-refsort < $f.ref > $f.sref + fi + $TEX $f ;; + + refsort ) $TEX -interaction nonstopmode $f ;; + + * ) $TEX $f ;; + esac done if ( $PDFTOCFRONT || [ "$HITEX" = "$TEX" ] ) && ! $FILESELECT @@ -385,9 +369,7 @@ then f=$(kpsewhich -engine tex cwebman) tie -m $(basename $f) $f $(basename $f .tex)-w2c.ch if [ "$HITEX" = "$TEX" ] - then - $SED_I -e "s/\(\\\\input cwebmac\)/\1\n\\\\input hiplainpage/" \ - cwebman.tex + then $SED_I -e "s/\(\\\\input cwebmac\)/\1\n\\\\input hiplainpage/" cwebman.tex fi touch pages.tex # let 'manmac' produce output at all diff --git a/web/pwebmac/pwebmac.tex b/web/pwebmac/pwebmac.tex index 880075cb2a..a7bdc717b9 100644 --- a/web/pwebmac/pwebmac.tex +++ b/web/pwebmac/pwebmac.tex @@ -5,19 +5,7 @@ % macro integration \`a la CWEB by Andreas Scherer <andreas_tex@freenet.de>. % This file is not copyrighted and can be used freely. \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros -\xdef\fmtversion{\fmtversion+WEBMAC4.10} -\input iftex.sty % TeX engine tests -\ifx\pdf+\pdftrue\fi -% Uncomment the following line if you want PDF goodies to be the default -%\ifx\pdf-\else\pdftrue\fi -\def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color -\ifxetex\pdftrue\fi % XeTeX produces PDF output -\newif\ifacrohint \ifpdf\acrohinttrue\fi \ifhint\acrohinttrue\fi -\newif\ifpdflua \ifluatex\pdfluatrue\fi \ifpdftex\pdfluatrue\fi -\ifpdflua % pdfTeX and luaTeX produce PDF output if \pdfoutput>0 - \def\Black{\pdfliteral{0 g 0 G}} % use rgb colors for direct PDF output too - \def\Blue{\pdfliteral{\pdflinkcolor\space rg \pdflinkcolor\space RG}} -\fi +\xdef\fmtversion{\fmtversion+PWEBMAC4.11} \parskip 0pt % no stretch between paragraphs \parindent 1em % for paragraphs and for the first line of Pascal text @@ -90,6 +78,20 @@ \newif\iftokprocessed \newif\ifTnum \newif\ifinstr {\def\\{\global\let\spacechar= }\\ } +% Here we decide the output format, depending on the TeX engine in use: +\input iftex.sty % TeX engine tests +\ifx\pdf+\pdftrue\fi % for plain TeX in combination with dvipdfm +% Uncomment the following line if you want PDF goodies to be the default +%\ifx\pdf-\else\pdftrue\fi +\ifxetex\pdftrue\fi % XeTeX produces PDF output +\ifpdf \def\pdflinkcolor{0 0 1} \fi % the RGB values for hyperlink color +\newif\ifacrohint \ifpdf\acrohinttrue\fi \ifhint\acrohinttrue\fi +\newif\ifpdflua \ifluatex\pdfluatrue\fi \ifpdftex\pdfluatrue\fi +\ifpdflua % pdfTeX and luaTeX produce PDF output if \pdfoutput>0 (default) + \def\Black{\pdfliteral{0 g 0 G}} % use rgb colors for direct PDF output too + \def\Blue{\pdfliteral{\pdflinkcolor\space rg \pdflinkcolor\space RG}} +\fi + \ifluatex % LuaTeX is almost like pdfTeX \protected\def\pdfliteral {\pdfextension literal} \protected\def\pdfstartlink {\pdfextension startlink\space} @@ -97,7 +99,7 @@ \protected\def\pdfoutline {\pdfextension outline\space} \protected\def\pdfdest {\pdfextension dest\space} \protected\def\pdfcatalog {\pdfextension catalog} -\chardef\pdfshellescape +\chardef\pdfshellescape % excerpt from 'shellesc.sty' \directlua{tex.sprint((status.shell_escape or os.execute()) .. " ")} \edef\pdfhorigin {\pdfvariable horigin} \edef\pdfvorigin {\pdfvariable vorigin} @@ -106,7 +108,7 @@ \let\pdfoutput=\outputmode \fi % end of LuaTeX->pdfTeX redirection macros -\ifpdf % The following are pdf macros from 'cwebmac.tex 3.70' +\ifpdf % The following are general pdf macros from 'cwebmac.tex 3.70' \def\thewidth{\the\wd0 \space} \def\theheight{\the\ht\strutbox\space} \def\thedepth{\the\dp\strutbox\space} @@ -190,7 +192,7 @@ \def\makeolproctokchar#1 #2 #3{\addF{#3}} \def\outlinedone{\edef\outlinest{\global\noexpand\toksE={\the\toksF}}% \outlinest\let\outlinedone=\relax} -\fi % End of pdf macros +\fi % End of general pdf macros \ifhint % The following uses HINT primitives to implement: @@ -232,9 +234,10 @@ \next } \def\makenote{\addtokens\toksB - {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countC=0} + {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}% + \toksC={}\global\countC=0} \def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} -\fi % End of common macros +\fi % End of common pdf/hint macros \def\pdfURL#1#2{\ifpdf \ifpdflua\pdfannotlink height \theheight depth \thedepth attr {/Border [0 0 0]} user { /Type /Annot /Subtype /Link /A diff --git a/web/pwebmac/webman.ch b/web/pwebmac/webman.ch index 1663836f42..1817ab4665 100644 --- a/web/pwebmac/webman.ch +++ b/web/pwebmac/webman.ch @@ -20,8 +20,8 @@ \def\bkminfo{} \outer\def\section #1.{\penalty-50\vskip 12pt plus 3pt minus 3pt \noindent\ifpdf\vbox to 0pt{\kern-2.5ex\relax - \ifpdflua\pdfdest num \destcount fitbh\relax - \else\special{pdf: dest (\the\destcount) [ @thispage /FitBH @ypos ]}\fi + \ifpdflua\pdfdest num \destcount fith\relax + \else\special{pdf: dest (\the\destcount) [ @thispage /FitH @ypos ]}\fi \def\.##1{##1}% \ifx\bkminfo\empty\def\sectitle{#1}\else\def\sectitle{#1 (\bkminfo)}\fi \ifpdflua\pdfoutline goto num \destcount {\sectitle}\relax @@ -82,6 +82,13 @@ This memo describes how to write programs in the \itemitem{3)} A \PASCAL\ part, containing a piece of the program that @z +@x l.304 +`\.{\\input webmac}'; this will cause \TeX\ to read in the macros that +@y +`\.{\\input webmac}'---or, if you invoke `\.{weave -p}', +`\.{\\input pwebmac}'---; this will cause \TeX\ to read in the macros that +@z + @x l.358 \.{which is a \\\&\{packed\}{ }\\\&\{array\}{ }\$ @y @@ -131,8 +138,10 @@ Finally, Appendix F is the `\.{webmac}' file that sets \TeX\ up to accept the output of \.{WEAVE}; Appendix~G discusses how to use some of its macros to vary the output formats; and Appendix~H discusses what needs to be done @y -Finally, \Appendix F is the `\.{webmac}' file that sets \TeX\ up to accept -the output of \.{WEAVE}; \Appendix G discusses how to use some of its macros +Finally, \Appendix F shows the `\.{webmac.tex}' file that sets \TeX\ up to +accept the output of \.{WEAVE}; it also shows the `\.{pwebmac.tex}' file that +provides alternative macros more suited for {\mc PDF} output with modern \TeX\ +engines; \Appendix G discusses how to use some of these macros to vary the output formats; and \Appendix H discusses what needs to be done @z @@ -261,77 +270,277 @@ XREF[P]:=0;END{:62};IDLOOKUP:=P;END; {:58}{66:}FUNCTION MODLOOKUP(L:SIXTEENBITS):NAMEPOINTER;LABEL 31; @z -@x l.1208 -\verbatim +@x l.1203 +\section Appendix F: The \.{webmac.tex} file. +This is the file that extends ``plain \TeX'' format in order to support the @y -\begingroup \def\tt{\ninett} \baselineskip10pt -\verbatim +\section Appendix F: Macros for formatting. +The \.{webmac.tex} file extends ``plain \TeX'' format in order to support the @z -@x l.1210 +@x l.1208 +\verbatim +% standard macros for WEB listings (in addition to PLAIN.TEX) \xdef\fmtversion{\fmtversion+WEBMAC4.0} % identifies current set of macros -@y -\xdef\fmtversion{\fmtversion+WEBMAC4.2} % identifies current set of macros -@z +\parskip 0pt % no stretch between paragraphs +\parindent 1em % for paragraphs and for the first line of Pascal text -@x l.1218 -\font\tentex=cmtex10 % TeX extended character set (used in strings) -@y +\font\eightrm=cmr8 \let\sc=\eightrm % NOT a caps-and-small-caps font! +\let\mainfont=\tenrm +\font\titlefont=cmr7 scaled\magstep4 % title on the contents page +\font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title \font\tentex=cmtex10 % TeX extended character set (used in strings) -\fontdimen7\tentex=0pt % no extra space after punctuation -@z -@x l.1294 +\def\\#1{\hbox{\it#1\/\kern.05em}} % italic type for identifiers +\def\|#1{\hbox{$#1$}} % one-letter identifiers look a bit better this way +\def\{\hbox{\bf#1\/}} % boldface type for reserved words +\def\.#1{\hbox{\tentex % typewriter type for strings + \let\\=\BS % backslash in a string + \let\'=\RQ % right quote in a string + \let\`=\LQ % left quote in a string + \let\{=\LB % left brace in a string + \let\}=\RB % right brace in a string + \let\~=\TL % tilde in a string + \let\ =\SP % space in a string + \let\_=\UL % underline in a string + \let\&=\AM % ampersand in a string + #1}} +\def\#{\hbox{\tt\char`\#}} % parameter sign +\def\${\hbox{\tt\char`\$}} % dollar sign +\def\%{\hbox{\tt\char`\%}} % percent sign +\def\^{\ifmmode\mathchar"222 \else\char`^ \fi} % pointer or hat +% circumflex accents can be obtained from \^^D instead of \^ +\def\AT!{@} % at sign for control text + +\chardef\AM=`\& % ampersand character in a string +\chardef\BS=`\\ % backslash in a string +\chardef\LB=`\{ % left brace in a string +\def\LQ{{\tt\char'22}} % left quote in a string +\chardef\RB=`\} % right brace in a string +\def\RQ{{\tt\char'23}} % right quote in a string +\def\SP{{\tt\char`\ }} % (visible) space in a string +\chardef\TL=`\~ % tilde in a string +\chardef\UL=`\_ % underline character in a string + +\newbox\bak \setbox\bak=\hbox to -1em{} % backspace one em +\newbox\bakk\setbox\bakk=\hbox to -2em{} % backspace two ems + +\newcount\ind % current indentation in ems +\def\1{\global\advance\ind by1\hangindent\ind em} % indent one more notch +\def\2{\global\advance\ind by-1} % indent one less notch +\def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement +\def\4{\copy\bak} % backspace one notch +\def\5{\hfil\penalty-1\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break +\def\6{\ifmmode\else\par % forced break + \hangindent\ind em\noindent\kern\ind em\copy\bakk\ignorespaces\fi} +\def\7{\Y\6} % forced break and a little extra space + +\let\yskip=\smallskip +\def\to{\mathrel{.\,.}} % double dot, used only in math mode +\def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt\eightrm#1~#2.\par}} +\def\lapstar{\rlap{*}} +\def\startsection{\Q\noindent{\let\*=\lapstar\bf\modstar.\quad}} +\def\defin#1{\global\advance\ind by 2 \1\&{#1 }} % begin `define' or `format' +\def\A{\note{See also section}} % crossref for doubly defined section name +\def\As{\note{See also sections}} % crossref for multiply defined section name +\def\B{\mathopen{\.{@\{}}} % begin controlled comment +\def\C#1{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % Pascal comments + \XX\hfil\penalty-1\hfilneg\quad$\{\,$#1$\,\}$\XX} +\def\D{\defin{define}} % macro definition +\def\E{\cdot10^} % exponent in floating point constant +\def\ET{ and~} % conjunction between two section numbers +\def\ETs{, and~} % conjunction between the last two of several section numbers +\def\F{\defin{format}} % format definition +\let\G=\ge % greater than or equal sign +\def\H#1{\hbox{\rm\char"7D\tt#1}} % hexadecimal constant +\let\I=\ne % unequal sign +\def\J{\.{@\&}} % TANGLE's join operation +\let\K=\gets % left arrow +\let\L=\le % less than or equal sign +\outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section + \vskip12ptminus3pt\startsection\ignorespaces} +\outer\def\N#1.#2.{\MN#1.\vfil\eject % beginning of starred section + \def\rhead{\uppercase{\ignorespaces#2}} % define running headline + \message{*\modno} % progress report + \edef\next{\write\cont{\Z{#2}{\modno}{\the\pageno}}}\next % to contents file + \ifon\startsection{\bf\ignorespaces#2.\quad}\ignorespaces} +\def\MN#1.{\par % common code for \M, \N {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}} \ifx\modno\modstar \onmaybe \else\ontrue \fi \mark{\modno}} -@y - {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}% remove \* from section name - \ifx\modno\modstar \onmaybe \else\ontrue \fi - \mark{{{\tensy x}\modno}{\rhead}}} - % each \mark is {section reference or null}{group title} -@z - -@x l.1325 +\def\O#1{\hbox{\rm\char'23\kern-.2em\it#1\/\kern.05em}} % octal constant +\def\P{\rightskip=0pt plus 100pt minus 10pt % go into Pascal mode + \sfcode`;=3000 + \pretolerance 10000 + \hyphenpenalty 10000 \exhyphenpenalty 10000 + \global\ind=2 \1\ \unskip} +\def\Q{\rightskip=0pt % get out of Pascal mode + \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 } +\let\R=\lnot % logical not +\let\S=\equiv % equivalence sign +\def\T{\mathclose{\.{@\}}}} % terminate controlled comment +\def\U{\note{This code is used in section}} % crossref for use of a section +\def\Us{\note{This code is used in sections}} % crossref for uses of a section +\let\V=\lor % logical or +\let\W=\land % logical and +\def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % section name + \XX$\langle\,$#2{\eightrm\kern.5em#1}$\,\rangle$\XX} +\def\Y{\par\yskip} +\let\Z=\let % now you can \send the control sequence \Z +\def\){\hbox{\.{@\$}}} % sign for string pool check sum +\def\]{\hbox{\.{@\\}}} % sign for forced line break +\def\=#1{\kern2pt\hbox{\vrule\vtop{\vbox{\hrule + \hbox{\strut\kern2pt\.{#1}\kern2pt}} + \hrule}\vrule}\kern2pt} % verbatim string +\let\~=\ignorespaces +\let\*=* + +\def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue +\newif\ifon \newif\iftitle \newif\ifpagesaved \def\lheader{\mainfont\the\pageno\eightrm\qquad\rhead\hfill\title\qquad \tensy x\mainfont\topmark} % top line on left-hand pages \def\rheader{\tensy x\mainfont\topmark\eightrm\qquad\title\hfill\rhead \qquad\mainfont\the\pageno} % top line on right-hand pages -@y -\def\lheader{\mainfont\the\pageno\eightrm\qquad\rhead - \hfill\title\qquad\mainfont\topsecno} % top line on left-hand pages -\def\rheader{\mainfont\topsecno\eightrm\qquad\title\hfill - \rhead\qquad\mainfont\the\pageno} % top line on right-hand pages -\def\topsecno{\expandafter\takeone\topmark} -\def\takeone#1#2{#1} -\def\taketwo#1#2{#2} -\def\nullsec{\eightrm\kern-2em} % the \kern-2em cancels \qquad in headers -@z +\def\page{\box255 } +\def\normaloutput#1#2#3{\ifodd\pageno\hoffset=\pageshift\fi + \shipout\vbox{ + \vbox to\fullpageheight{ + \iftitle\global\titlefalse + \else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi + \vfill#1}} % parameter #1 is the page itself + \global\advance\pageno by1} -@x l.1336 \def\rhead{\.{WEB} OUTPUT} % this running head is reset by starred sections -@y -\def\rhead{\.{WEB} OUTPUT} % this running head is reset by starred sections -\mark{\noexpand\nullsec{\rhead}} -@z - -@x l.1392 +\def\title{} % an optional title can be set by the user +\def\topofcontents{\centerline{\titlefont\title} + \vfill} % this material will start the table of contents page +\def\botofcontents{\vfill} % this material will end the table of contents page +\def\contentspagenumber{0} % default page number for table of contents +\newdimen\pagewidth \pagewidth=6.5in % the width of each page +\newdimen\pageheight \pageheight=8.7in % the height of each page +\newdimen\fullpageheight \fullpageheight=9in % page height including headlines +\newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones +\def\magnify#1{\mag=#1\pagewidth=6.5truein\pageheight=8.7truein + \fullpageheight=9truein\setpage} +\def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size +\def\contentsfile{CONTENTS} % file that gets table of contents info +\def\readcontents{\input CONTENTS} + +\newwrite\cont +\output{\setbox0=\page % the first page is garbage + \openout\cont=\contentsfile + \global\output{\normaloutput\page\lheader\rheader}} +\setpage +\vbox to \vsize{} % the first \topmark won't be null + +\def\ch{\note{The following sections were changed by the change file:} + \let\*=\relax} +\newbox\sbox % saved box preceding the index +\newbox\lbox % lefthand column in the index +\def\inx{\par\vskip6pt plus 1fil % we are beginning the index + \write\cont{} % ensure that the contents file isn't empty + \closeout\cont % the contents information has been fully gathered + \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi + \global\setbox\sbox=\page \global\pagesavedtrue} + \pagesavedfalse \eject % eject the page-so-far and predecessors + \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box + \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height + \hsize=.5\pagewidth \advance\hsize by -10pt + % column width for the index (20pt between cols) + \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines + \def\lr{L} % this tells whether the left or right column is next + \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R} + \else\normaloutput{\vbox to\pageheight{\box\sbox\vss + \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader + \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi} + \message{Index:} + \parskip 0pt plus .5pt + \outer\def\:##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry + \let\ttentry=\. \def\.##1{\ttentry{##1\kern.2em}} % give \tt a little room + \def\[##1]{$\underline{##1}$} % underlined index item + \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar + \hyphenpenalty 10000 \parindent0pt} +\def\fin{\par\vfill\eject % this is done when we are ending the index + \ifpagesaved\null\vfill\eject\fi % output a null index column + \if L\lr\else\null\vfill\eject\fi % finish the current page + \parfillskip 0pt plus 1fil \def\rhead{NAMES OF THE SECTIONS} -@y - \def\rhead{NAMES OF THE SECTIONS} - \let\topsecno=\nullsec -@z - -@x l.1395 + \message{Section names:} + \output{\normaloutput\page\lheader\rheader} + \setpage \def\note##1##2.{\hfil\penalty-1\hfilneg\quad{\eightrm##1 ##2.}} + \linepenalty=10 % try to conserve lines + \def\U{\note{Used in section}} % crossref for use of a section + \def\Us{\note{Used in sections}} % crossref for uses of a section + \def\:{\par\hangindent 2em}\let\*=*\let\.=\ttentry} +\def\con{\par\vfill\eject % finish the section names + \rightskip 0pt \hyphenpenalty 50 \tolerance 200 + \setpage + \output{\normaloutput\page\lheader\rheader} + \titletrue % prepare to output the table of contents + \pageno=\contentspagenumber \def\rhead{TABLE OF CONTENTS} + \message{Table of contents:} + \topofcontents + \line{\hfil Section\hbox to3em{\hss Page}} + \def\Z##1##2##3{\line{\ignorespaces##1 + \leaders\hbox to .5em{.\hfil}\hfil\ ##2\hbox to3em{\hss##3}}} + \readcontents\relax % read the contents info + \botofcontents \end} % print the contents page(s) and terminate +?endgroup @y - \def\note##1##2.{\hfil\penalty-1\hfilneg\quad{\eightrm##1~##2.}} +\begingroup \def\tt{\eighttt} \baselineskip9pt +\def\printmacs#1{\begingroup + \def\do##1{\catcode`##1=12 } \dospecials + \parskip 0pt \parindent 0pt + \catcode`\ =13 \catcode`\^^M=13 + \tt \verbatimdefs \input #1 \endgroup} +\printmacs{webmac} +\vskip6pt \baselineskip12pt +\section Hypertext and hyperdocumentation. +Many people have of course noticed analogies between \.{WEB} and the +World Wide Web. The following \.{WEB} macros \.{pwebmac.tex} are in fact +set up so that the output of \.{WEAVE} can be converted easily into +Portable Document Format, with clickable hyperlinks that can be read +with your favorite {\mc PDF} viewer. +After using \.{WEAVE} with command line option `\.{-p}' to convert +\.{cob.web} into \.{cob.tex}, you can prepare a hypertext version of +the program by giving the commands +$$\vbox{\halign{\.{#}\hfil\cr +tex "\\let\\pdf+ \\input cob"\cr +dvipdfm cob\cr}}$$ +instead of invoking \TeX\ in the normal way. +Alternatively you can generate \.{cob.pdf} in one step by simply saying +`\.{pdftex}~\.{cob}' or `\.{xetex}~\.{cob}' or `\.{luatex}~\.{cob}'. +(You are advised to use the command line option `\.{--shell-escape}' with +\.{pdftex} and \.{luatex} in order to receive ``valid'' {\mc PDF} output; +otherwise, the internal counter for the ``Names of the sections'' part +in the {\mc PDF} ``bookmarks'' will be incorrect.) + +Similar output for ``smart'' devices can be created with Martin Ruckert's +Hi\TeX\ and its dynamic \.{HINT} format; just say `\.{hitex}~\.{cob}'. +\.{HINT} files can be viewed with the \.{hintview} program, which is +available from +\pdfURL{\.{https://hint.userweb.mwn.de/hint/hintview.html}}% + {https://hint.userweb.mwn.de/hint/hintview.html}.% + +A more elaborate system called \.{TWILL}, which extends the usual cross +references of \.{WEAVE} by preparing links from the uses of identifiers +to their definitions, is also available---provided that you are willing +to work a bit harder in cases where an identifier is multiply defined. +\.{TWILL} is intended primarily for hardcopy output, but its principles +could be used for hypertext as well. It uses its own set of macros +`\.{twimac-web.tex}'. + +\vskip6pt \baselineskip9pt +\printmacs{pwebmac} +\endgroup +\vfill\eject @z -@x l.1414 -?endgroup +@x l.1418 +The macros in \.{webmac} make it possible to produce a variety of formats @y -?endgroup -\endgroup +The macros in \.{webmac} and \.{pwebmac} make it possible to produce +a variety of formats @z @x l.1425 @@ -362,6 +571,17 @@ for every starred module. For example, when \pdfURL{Appendix~D}{weave.pdf} was being generated, @z +@x l.569 +\.{\\ch}, \.{\\fin}, and \.{\\con}. \.{WEAVE} itself need not be changed. +@y +\.{\\ch}, \.{\\fin}, and \.{\\con}. \.{WEAVE} itself need not be changed. + +\point 15. In conjunction with `\.{weave -p}' and the \.{pwebmac} macros you +can say `\.{\\input pdfwebtocfront}' as the last command in the limbo section +and run \TeX\ \\{twice} on your woven \.{WEB} document, in order to shift the +table-of-contents to the front of the {\mc PDF} output. +@z + @x l.1583 dependencies'' in the index of Appendix~E above, and figure out what changes @y |