This Perl script takes an ALLPROSE Noweb form of an Aldor source as standard input and transforms environments of the form
\begin{+++}
line 1 ... line n \end{+++} % empty lines or LaTeX comment lines <<some code chunk>>= ... @ |
into
<<some code chunk>>=
+++ line 1 +++ ... +++ line n @ % empty lines or LaTeX comment lines <<some code chunk>>= ... @ |
Note that both code chunks will have the same name so that the documentation in the tangled file comes immediately before the corresponding code.
Additionally note that the n-th input line corresponds to the n-th output line. Such a correspondence is important for the -L option that is given to NOTANGLE.
Now we run through the line. If we find
\begin{+++}
|
then the curresponding line number is remembered until the following code chunk. If we reach the beginning of a code chunk, the last
\begin{+++}
|
line is replaced by the current code-chunk-opening line and the corresponding
\end{+++}
|
is replaced by @. The lines inside the +++ environment are prepended by "+++ ".