Commits

Martin Scharrer committed da61e1f

Added some experimental code for defining verbatim environments.

Comments (0)

Files changed (1)

 % \end{macro}
 %
 %
+% \begin{macro}{\collectverbenv}
+% Collects verbatim text which can be typeset.
+% Checks for an existing star.
+%    \begin{macrocode}
+\newcommand*\collectverbenv{%
+    \begingroup
+    \verbatim@font
+    \@ifstar
+        \@scollectverbenv
+        \@collectverbenv
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@collectverbenv}[1]{<code>}
+% Changes catcodes and ensures that spaces are displayed normally.
+%    \begin{macrocode}
+\def\@collectverbenv#1{%
+    \newverb@catcodes
+    \@vobeyspaces
+    \frenchspacing
+    \@noligs
+    \expandafter\@@collectverbenv\expandafter{\@currenvir}{#1}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@scollectverbenv}[1]{<code>}
+% Changes catcodes.
+%    \begin{macrocode}
+\def\@scollectverbenv#1{%
+    \newverb@catcodes
+    \@noligs
+    \expandafter\@@collectverbenv\expandafter{\@currenvir}{#1}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@collectverbenv}[2]{<envname>}{<code>}
+%    \begin{macrocode}
+\begingroup
+\catcode`\|=0
+\catcode`\(=1
+\catcode`\)=2
+\@makeother\{
+\@makeother\}
+\@makeother\\
+|catcode`|^^M=|active%
+|gdef|@@collectverbenv#1#2(%
+    |long|def|@@@collectverb##1^^M##2^^M\end{#1}(#2(##2)|endgroup|end(#1))%
+    |@@@collectverb%
+)%
+|endgroup%
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\Collectverb}
 % Collects argument as plain verbatim and feeds it to the given code.
 % The text is suitable to be printed to auxiliary files.
 %
 % \begin{macro}{\newverb@tab}
 %    \begin{macrocode}
-\edef\newverb@tab{\space\space\space\space}
+\edef\newverb@tab{\space}%\space\space\space}
 %    \end{macrocode}
 % \end{macro}
 %
 % \end{macro}
 %
 %
+% \begin{macro}{\newverbenvironment}
+%    \begin{macrocode}
+\newcommand\newverbenvironment{}
+\long\def\newverbenvironment#1#2#{%
+    \@newverbenvironment{#1}{#2}%
+}
+\long\def\@newverbenvironment#1#2#3#4{%
+    \newenvironment{#1}#2{%
+        \begingroup
+        \newverb@catcodes
+        \obeyspaces
+        #3%
+        \expandafter\@@Collectverbenv\expandafter{\@currenvir}{\long\def\BODY}%
+    }{#4}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\newverbsfont}
+%    \begin{macrocode}
+\newcommand\newverbsfont{%
+    \verbatim@font
+    \frenchspacing
+}
+%    \end{macrocode}
+% \end{macro}
+%
 %
 % \begin{macro}{\Verbdef}
 %    \begin{macrocode}