[NTG-context] fix for verbatim

Hans Hagen pragma at wxs.nl
Wed Nov 9 11:33:53 CET 2005


Hans Hagen wrote:

> The following patch

oeps, little bug,

here is the complete version:

\unprotect

\bgroup
\catcode`\[=\@@begingroup
\catcode`\]=\@@endgroup
\catcode`\{=\@@active
\catcode`\}=\@@active
\gdef\initializetypegrouping%
  [\ifnum\catcode`\{=\@@active
     \let\normalactivebgroup{%
     \let\normalactiveegroup}%
   \else
     \catcode`\{=\@@active
     \catcode`\}=\@@active
     \let\normalactivebgroup\leftargument
     \let\normalactiveegroup\rightargument
   \fi
   \def\activeleftargument%
     [\bgroup
      \let}\activerightargument
      \normalactivebgroup
     ]%
   \def\activerightargument%
     [\normalactiveegroup
      \egroup]%
   \let{=\activeleftargument
   \let}=\egroup
  ]
\egroup

\chardef\recodeverbatimmode\zerocount % 0=nothing 1=rescan 2=autorescan

\def\dodotypeA
  {\initializetype
   \initializetypegrouping
   \verbatimcolor
   \ifcase\recodeverbatimmode
     \@EA\dodotypeAA
   \or
     \@EA\dodotypeAB
   \or
     \ifnum\catcode`\{=\@@active
       \@EAEAEA\dodotypeAB
     \else
       \@EAEAEA\dodotypeAA
     \fi
   \else
     \@EA\dodotypeAA
   \fi}

\def\dodotypeAA
  {\afterassignment\protectfirsttype\let\next=}

\def\dodotypeAB
  {\bgroup
   \catcode`\}=\@@endgroup
   \catcode`\{=\@@begingroup
   \afterassignment\redotypeAB\global\globalscratchtoks}

\def\redotypeAB
  {\egroup
   \expandafter\convertargument\the\globalscratchtoks\to\ascii
   
\ifx\scantokens\undefined\ascii\else\everyeof{\hskip-\spaceskip}\scantokens\expandafter{\ascii}\fi
   \egroup}

\appendtoks \chardef\recodeverbatimmode\plustwo \to \everytabulate
\appendtoks \chardef\recodeverbatimmode\plustwo \to \everytable

\protect

\type (including colorization)  should work ok in tabulate and tables

(btw, it becomes time to drop non-etex code -)

Hans


More information about the ntg-context mailing list