summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/misc/comment.tex
blob: e8606bfad20ec36fb4870a8986801b84e46c7732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
%       Comment.tex
% Macro to allow block comments in TeX
%
% Usage: Text between \begincomment and \endcomment is ignored; i.e.
%
% text
% \begincomment
%    this text is ignored
% \endcomment
% more text
%
% Notes: Do NOT nest.
%        The \endcomment MUST appear at the end of a line.
%        TeX processes each line of ignored text, so the macro
%           is not particularly fast.  Use sparingly.  The main use
%           is to cause TeX to pass over small blocks of text.
%
% J.C. Alexander,  May, 1986
%
\edef\Saveatcatcode{\the\catcode`\@}
\catcode`\@=11
\def\newcodes@{\edef\S@veslashcatcode{\the\catcode`\\}
               \edef\S@velbraccatcode{\the\catcode`\{}
               \edef\S@verbraccatcode{\the\catcode`\}}
               \edef\S@venumsgcatcode{\the\catcode`\#}
               \edef\S@veperctcatcode{\the\catcode`\%}
 \catcode`\\=12 \catcode`\{=12 \catcode`\}=12 \catcode`\#=12
 \catcode`\%=12\relax}
\def\oldcodes@{\catcode`\\=\S@veslashcatcode
               \catcode`\{=\S@velbraccatcode
               \catcode`\}=\S@verbraccatcode
               \catcode`\#=\S@venumsgcatcode
               \catcode`\%=\S@veperctcatcode
               \relax}
\def\begincomment{\newcodes@\endlinechar=10 \comment@}
{\lccode`\!=`\\
\lowercase{\gdef\comment@#1^^J{\comment@@#1!endcomment\comment@@@}%
\gdef\comment@@#1!endcomment{\futurelet\next\comment@@@}%
\gdef\comment@@@#1\comment@@@{\ifx\next\comment@@@\let
\next=\comment@\else\def\next{\oldcodes@\endlinechar=`\^^M\relax}%
 \fi\next}}}
\catcode`\@=\Saveatcatcode