summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/misc/comment.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/plain/contrib/misc/comment.tex')
-rw-r--r--macros/plain/contrib/misc/comment.tex42
1 files changed, 42 insertions, 0 deletions
diff --git a/macros/plain/contrib/misc/comment.tex b/macros/plain/contrib/misc/comment.tex
new file mode 100644
index 0000000000..e8606bfad2
--- /dev/null
+++ b/macros/plain/contrib/misc/comment.tex
@@ -0,0 +1,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