summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-03-07 22:41:13 +0000
committerKarl Berry <karl@freefriends.org>2008-03-07 22:41:13 +0000
commitfe3a7bca0ce98ed78818421d9d6d9870823546e6 (patch)
treee75f688110f6f22308d8a516f967b564a0da97f2
parent677aa4ea5fd346dc1f078049584a09e11d342d17 (diff)
ted update (7mar08)
git-svn-id: svn://tug.org/texlive/trunk@6884 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/ted/README17
-rw-r--r--Master/texmf-dist/doc/latex/ted/ted-fr.pdfbin49813 -> 61561 bytes
-rw-r--r--Master/texmf-dist/doc/latex/ted/ted.pdfbin129411 -> 143368 bytes
-rw-r--r--Master/texmf-dist/source/latex/ted/ted.dtx1040
-rw-r--r--Master/texmf-dist/tex/latex/ted/ted.sty59
5 files changed, 653 insertions, 463 deletions
diff --git a/Master/texmf-dist/doc/latex/ted/README b/Master/texmf-dist/doc/latex/ted/README
index 16453f8795a..71f7c3598a1 100644
--- a/Master/texmf-dist/doc/latex/ted/README
+++ b/Master/texmf-dist/doc/latex/ted/README
@@ -3,13 +3,13 @@
A (primitive) token list editor
- Manuel P\'egouri\'e-Gonnard <mpg@math.jussieu.fr>
+ Manuel P\'egouri\'e-Gonnard <mpg@elzevir.fr>
Presentation
------------
Just like sed is a stream editor, ted is a token list editor. Actually, it is
-not as powerfull as sed, but its main feature is that it really works with
+not as powerful as sed, but its main feature is that it really works with
tokens, not only characters.
The ted package provides two user macros: \Substitute and \ShowTokens. The first
@@ -26,16 +26,21 @@ Contents
--------
ted.sty: the package itself
-ted.pdf: the (english) documentation and commented code
-ted-fr.pdf: the french documentation
+ted.pdf: the (English) documentation and commented code
+ted-fr.pdf: the French documentation
ted.dtx: single source for both documentations and package
Version info
------------
-2007-12-09 v1.0 first release
-2007-12-12 v1.01 trivial bug fix
+2007-12-09 v1.0 First release.
+2007-12-12 v1.01 Fixed a stupid bug.
+2008-03-02 v1.05 - Fixed a bug when trying to substitute AA in a
+ string ending with A. Also removed a spurious space.
+ - Added an occurrence counter.
+2008-03-07 v1.06 - Fixed a bug in \ShowTokens with active spaces.
+ - Slightly expanded the doc (examples).
License
-------
diff --git a/Master/texmf-dist/doc/latex/ted/ted-fr.pdf b/Master/texmf-dist/doc/latex/ted/ted-fr.pdf
index f6fa6c0bb6e..d49e62c6ef7 100644
--- a/Master/texmf-dist/doc/latex/ted/ted-fr.pdf
+++ b/Master/texmf-dist/doc/latex/ted/ted-fr.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/ted/ted.pdf b/Master/texmf-dist/doc/latex/ted/ted.pdf
index 5084ebbd0bb..247e70e9e81 100644
--- a/Master/texmf-dist/doc/latex/ted/ted.pdf
+++ b/Master/texmf-dist/doc/latex/ted/ted.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/ted/ted.dtx b/Master/texmf-dist/source/latex/ted/ted.dtx
index 310f37c967c..4916436ade3 100644
--- a/Master/texmf-dist/source/latex/ted/ted.dtx
+++ b/Master/texmf-dist/source/latex/ted/ted.dtx
@@ -1,17 +1,18 @@
%
-% \iffalse /!\ utf-8 encoded file /!\
-%
-% ted package by Manuel P\'egouri\'e-Gonnard <mpg@math.jussieu.fr>
-% ----------------------------------------------------------------
+% \iffalse /!\ this file contains non-ascii -- encoding is utf-8 /!\
+%
+% ted package by Manuel P\'egouri\'e-Gonnard <mpg@elzevir.fr>
+% -----------------------------------------------------------
%
-% This work may be distributed and/or modified under the conditions of the
-% LaTeX Project Public License, either version 1.3c of this license or (at
-% your option) any later version. The latest version of this license is in:
+% This work may be distributed and/or modified under the conditions of
+% the LaTeX Project Public License, either version 1.3c of this license
+% or (at your option) any later version. The latest version of this
+% license is in:
%
-% http://www.latex-project.org/lppl.txt
+% http://www.latex-project.org/lppl.txt
%
-% and version 1.3c or later is part of all distributions of LaTeX version
-% 2006/05/20 or later.
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2006/05/20 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
@@ -29,11 +30,11 @@
%<*package>
% \fi
% \ProvidesFile{ted.dtx}
- [2007/12/12 v1.01 \space token list editor \space (mpg)]
+ [2008/03/07 v1.06 \space a token list editor \space (mpg)]
% \iffalse
%</package>
% \fi
-% \CheckSum{774}
+% \CheckSum{816}
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -59,7 +60,7 @@
\preamble
ted package by Manuel P\string\'egouri\string\'e-Gonnard %
-<mpg@math.jussieu.fr>
+<mpg@elzevir.fr>
This is a generated file. See ted.dtx for license information.
\endpreamble
@@ -78,10 +79,8 @@ This is a generated file. See ted.dtx for license information.
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[babel=true, expansion=false]{microtype}
-\usepackage[bookmarks=false, colorlinks=true,
- linkcolor=black, urlcolor=black]{hyperref}
\usepackage{fixltx2e}
-\expandafter\newif\csname iffrenchdoc\endcsname % just hiding this if
+\expandafter\newif\csname iffrenchdoc\endcsname % cachez ce if...
%<pilote>\frenchdoctrue
%</driver|pilote>
%<*gobble>
@@ -91,8 +90,12 @@ This is a generated file. See ted.dtx for license information.
\usepackage[lmargin=4.5cm, rmargin=3cm]{geometry}
\OnlyDescription
\usepackage[english, french]{babel}
-\FrenchFootnotes
+\FrenchFootnotes \AddThinSpaceBeforeFootnotes
\newcommand*\eng[1]{\emph{\foreignlanguage{english}{#1}}}
+\usepackage[bookmarks=false]{hyperref}
+\hypersetup{%
+ pdftitle=L'extension ted
+ pdfsubject=Un éditeur de liste de lexèmes pour LaTeX2e}
%</pilote>
%<*gobble>
\else
@@ -100,16 +103,36 @@ This is a generated file. See ted.dtx for license information.
%<*driver>
\AlsoImplementation
\usepackage[english]{babel}
+\usepackage[bookmarks=true, bookmarksnumbered=true, bookmarksopen=true,
+ bookmarksopenlevel=2]{hyperref}
+\hypersetup{%
+ pdftitle=The ted package,
+ pdfsubject=A token list editor for LaTex2e}
+\settowidth\MacroIndent{\rmfamily\scriptsize 000\ }
+\setlength\MacroTopsep{0pt}
+\setcounter{tocdepth}{1}
+\usepackage[nohints, english]{minitoc}
+\mtcsetpagenumbers{secttoc}{off}
+\mtcsetrules{secttoc}{off}
+\mtcsetdepth{secttoc}{3}
+\setlength{\stcindent}{0pt}
+\mtcsetfont{secttoc}{subsection}{\normalfont}
+\newcommand\tocwithmini{%
+ \dosecttoc[n]
+ \setcounter{tocdepth}{1}\tableofcontents
+ \setcounter{tocdepth}{3}\faketableofcontents
+ }
%</driver>
%<*gobble>
\fi
%</gobble>
%<*driver|pilote>
+\hypersetup{%
+ colorlinks=true, linkcolor=black, urlcolor=black,
+ pdfauthor=Manuel Pégourié-Gonnard}
\newcommand\pf{\textsf}
-\setcounter{tocdepth}{1}
-\renewcommand\thesubsubsection{\alph{subsubsection}}
-\settowidth\MacroIndent{\rmfamily\scriptsize 000\ }
-\setlength\MacroTopsep{0pt}
+\newcommand\optstar{\meta{$*$}}
+\newcommand\topcs[1]{\texorpdfstring{\cs{#1}}{#1}}
\begin{document}
\DocInput{ted.dtx}
\end{document}
@@ -121,44 +144,43 @@ This is a generated file. See ted.dtx for license information.
%
% \title{\iffrenchdoc L'extension \pf{ted}\else The \pf{ted} package\fi}
% \author{Manuel Pégourié-Gonnard\\
-% \href{mailto:mpg@math.jussieu.fr}{mpg@math.jussieu.fr}}
+% \href{mailto:mpg@elzevir.fr}{mpg@elzevir.fr}}
% \date{\fileversion\ (\filedate)}
%
% \maketitle
-% \tracingmacros1
-% \iffrenchdoc\else \tableofcontents \fi
-% \tracingmacros0
+% \iffrenchdoc\else \tocwithmini \fi
%
% \section{Introduction}
%
% \iffrenchdoc
%
-% Le nom de l'extension \pf{ted} signifie \eng{token list editor}, soit en
-% français \og éditeur de listes de lexèmes \fg{}. Comparé à \texttt{sed} dont
-% son nom s'inspire, il n'est pas très puissant : il ne sait faire
-% actuellement que deux choses avec les listes de lexèmes, à savoir les
-% afficher en détail, et y opérer des substitutions. Toutefois, sa
-% caractéristique principale est de travailler vraiment au niveau des lexèmes,
-% et non des simples caractères.
+% Le nom de l'extension \pf{ted} signifie \eng{token list editor}, soit
+% en français \og éditeur de listes de lexèmes \fg{}. Comparé à
+% \texttt{sed} dont son nom s'inspire, il n'est pas très puissant : il
+% ne sait faire actuellement que deux choses avec les listes de lexèmes,
+% à savoir les afficher en détail, et y opérer des substitutions.
+% Toutefois, sa caractéristique principale est de travailler vraiment au
+% niveau des lexèmes, et non des simples caractères.
%
% L'extension \pf{ted} est capable de faire des substitutions même à
% l'intérieur d'une paire d'accolades, et n'a pas de problèmes avec des
-% lexèmes particuliers. En fait, elle est conçue pour fonctionner même avec
-% des listes comportant des lexèmes très exotiques.
+% lexèmes particuliers. En fait, elle est conçue pour fonctionner même
+% avec des listes comportant des lexèmes très exotiques.
%
% \else
%
-% Just like \texttt{sed} is a stream editor, \pf{ted} is a token list editor.
-% Actually, it is not as powerfull as \texttt{sed}, but its main feature is
-% that it really works with tokens, not only characters. At the moment, it can
-% do only two things with token lists: display it with full information on
-% each token, and perform substitutions (that is, replacing every occurence of
-% a sublist with another token list).
+% Just like \texttt{sed} is a stream editor, \pf{ted} is a token list
+% editor. Actually, it is not as powerful as \texttt{sed}, but its
+% main feature is that it really works with tokens, not only characters.
+% At the moment, it can do only two things with token lists: display it
+% with full information on each token, and perform substitutions (that
+% is, replacing every occurrence of a sublist with another token list).
%
-% The \pf{ted} package can perform substitutions inside groups, and don't
-% forbid any token in the lists. Actually, \pf{ted} is designed to work well
-% even if strange tokens (that is, unusual (charcode, \cs{catcode}) pairs or
-% tokens with a confusing \cs{meaning}) occur in the list.
+% The \pf{ted} package can perform substitutions inside groups, and
+% don't forbid any token in the lists. Actually, \pf{ted} is designed to
+% work well even if strange tokens (that is, unusual (charcode,
+% \cs{catcode}) pairs or tokens with a confusing \cs{meaning}) occur in
+% the list.
%
% \fi
%
@@ -167,107 +189,166 @@ This is a generated file. See ted.dtx for license information.
% \iffrenchdoc
%
% L'extension \pf{ted} définit essentiellement deux macros publiques :
-% \cs{Substitute} et \cs{ShowTokens}. La première est la raison d'être de
-% \pf{ted}, mais au cours du développement de l'extension, la partie la plus
-% difficile et intéressante a été d'être capable d'écrire la deuxième. J'ai
-% donc décidé de la proposer à l'utilisateur, car je pense qu'elle peut être
-% utile, soit pour déboguer du code, soit pour apprendre \TeX.
+% \cs{Substitute} et \cs{ShowTokens}. La première est la raison d'être
+% de \pf{ted}, mais au cours du développement de l'extension, la partie
+% la plus difficile et intéressante a été d'être capable d'écrire la
+% deuxième. J'ai donc décidé de la proposer à l'utilisateur, car je
+% pense qu'elle peut être utile, soit pour déboguer du code, soit pour
+% apprendre \TeX.
+%
+% \subsection{\topcs{Substitute}}
%
-% \medskip
% \DescribeMacro{\Substitute}
% La syntaxe de \cs{Substitute} est la suivante.
% \begin{quote}
-% \cs{Substitute}\meta{*}\oarg{sortie}\marg{entrée}\marg{de}\marg{vers}
+% \cs{Substitute}\optstar\oarg{sortie}\marg{entrée}\marg{de}\marg{vers}
% \end{quote}
-% Commençons par l'usage le plus simple : sans étoile ni argument optionel.
-% Sous cette forme, \cs{Substitute} remplace chaque occurence de la sous-liste
-% \meta{de} par \meta{vers} dans l'\meta{entrée}, et place le résultat dans le
-% registre à lexèmes \cs{ted@toks}. Comme \cs{Substitute} est sans doute
-% destiné à être utilisé par des auteurs de classe ou d'extensions, le |@|
-% dans le nom de ce registre ne devrait pas poser de problèmes la plupart du
-% temps.
+% Commençons par l'usage le plus simple : sans étoile ni argument
+% optionel. Sous cette forme, \cs{Substitute} remplace chaque occurrence
+% de la sous-liste \meta{de} par \meta{vers} dans l'\meta{entrée}, et
+% place le résultat dans le registre à lexèmes \cs{ted@toks}. Comme
+% \cs{Substitute} est sans doute destiné à être utilisé par des auteurs
+% de classe ou d'extensions, le |@| dans le nom de ce registre ne
+% devrait pas poser de problèmes la plupart du temps.
%
% Quoi qu'il en soit, vous pouvez changer facilement le nom du registre
-% utilisé pour la sortie avec l'argument optionel en spécifiant le nom d'un
-% registre à lexèmes dans \meta{sortie}. En fait, vous voulez peut-être que la
-% sortie soit placée dans une macro et non un registre : dans ce cas, vous
-% pouvez spécifier par exemple \cs{def}\cs{macro} (ou
-% \cs{long}\cs{def}\cs{macro} etc.) comme argument optionel. Dans tous les
-% cas, \meta{sortie}|{trucs}| doit être une syntaxe légale d'affectation de
-% |truc| dans la sortie. Bien sûr, si vous demandez à ce que la sortie soit
-% placée dans une macro, vous devez veiller à ce qu'elle ne contienne pas de
-% dièses (caractère de paramètre) mal placés.
-%
-% La version étoilée de \cs{Substitute} a pour but de vous simplifier la vie
-% quand vous ne voulez pas spécifier explicitement une liste de lexèmes en
-% entrée, mais plutôt utiliser le contenu d'une macro ou d'un registre, en
-% développant une fois son premeir argument obligatoire avant de commancer à
-% travailler dessus. Ceci vous évite d'avoir à placer vous-même des
-% \cs{expandafter}, surtout dans le cas ou vous souhaitez utiliser l'argument
-% optionel. Cette fois, l'usage est inversé par rapport à l'argument optionel
-% : c'est la cas d'une macro qui est le plus naturel. Pour un registre de
-% lexèmes, vous devez écrire le \cs{the} vous même : ainsi, votre \meta{entrée}
-% pourra être de la forme \cs{macro}, ou \cs{the}\cs{toksreg}, ou toute autre
-% chose dont le 1-développement donne ce que vous voulez.
-%
-% La version avec deux étoiles a aussi pour but de vous épargner la peine
-% de contrôler vous-même le développement des arguments. Elle fonctionne comme
-% la version étoilée simple, mais développe cette fois ses trois arguments
-% obligatoires une fois avant de commencer à travailler. La même remarque que
-% pour la version étoilée simple s'applique concernant les macros et les
-% registres à lexèmes. J'espère que ces trois cas (de zéro à deux étoiles)
-% couvriront la plupart des usage courants. Pour une gestion plus souple du
-% développement des arguments, attendez \LaTeX$3$ !
-%
-% Le comportement de \cs{Substitute} devrait être évident la pluart du temps.
-% seul un cas particulier mérite sans doute une patite remarque : dans le cas
-% ou la liste \meta{de} est vide, la liste \meta{vers} est insérée entre
-% chaque paire de lexèmes de l'\meta{entrée} : en particulier elle n'est pas
-% insérée au début ni à la fin. Par exemple, |\Substitute{abc}{}{1}| placera
-% |a1b1c| dans \cs{ted@toks}.
+% utilisé pour la sortie avec l'argument optionnel en spécifiant le nom
+% d'un registre à lexèmes dans \meta{sortie}. En fait, vous voulez
+% peut-être que la sortie soit placée dans une macro et non un registre
+% : dans ce cas, vous pouvez spécifier par exemple \cs{def}\cs{macro}
+% (ou \cs{long}\cs{def}\cs{macro} etc.) comme argument optionnel. Dans
+% tous les cas, \meta{sortie}|{trucs}| doit être une syntaxe légale
+% d'affectation de |truc| dans la sortie. Bien sûr, si vous demandez à
+% ce que la sortie soit placée dans une macro, vous devez veiller à ce
+% qu'elle ne contienne pas de dièses (caractère de paramètre) mal
+% placés. Exemples :
+%
+% \begin{quote}
+% |\Substitute{a#b#c}{a}{A}|\\
+% |\newtoks\vostoks \Substitute[\vostoks]{a#b#c}{a}{A}|\\
+% |\Substitute[\def\votremacro]{a#b#c}{#}{##}|
+% \end{quote}
+%
+% La version étoilée de \cs{Substitute} a pour but de vous simplifier la
+% vie quand vous ne voulez pas spécifier explicitement une liste de
+% lexèmes en entrée, mais plutôt utiliser le contenu d'une macro ou d'un
+% registre, en développant une fois son premier argument obligatoire
+% avant de commencer à travailler dessus. Ceci vous évite d'avoir à
+% placer vous-même des \cs{expandafter}, surtout dans le cas ou vous
+% souhaitez utiliser l'argument optionnel. Cette fois, l'usage est
+% inversé par rapport à l'argument optionnel : c'est la cas d'une macro
+% qui est le plus naturel. Pour un registre de lexèmes, vous devez
+% écrire le \cs{the} vous même : ainsi, votre \meta{entrée} pourra être
+% de la forme \cs{macro}, ou \cs{the}\cs{toksreg}, ou toute autre chose
+% dont le 1-développement donne ce que vous voulez. Par exemple :
+%
+% \begin{quote}
+% |\def\abc{abccdef} \newtoks\abctoks \abctoks{abc}|\\
+% |\Substitute{\abc}{cc}{C} %| donne |\abc|\\
+% |\Substitute*{\abc}{cc}{C} %| donne |abCdef|\\
+% |\Substitute*{\the\abctoks}{cc}{C} %| aussi
+% \end{quote}
+%
+% La version avec deux étoiles a aussi pour but de vous épargner la
+% peine de contrôler vous-même le développement des arguments. Elle
+% fonctionne comme la version étoilée simple, mais développe cette fois
+% ses trois arguments obligatoires une fois avant de commencer à
+% travailler. La même remarque que pour la version étoilée simple
+% s'applique concernant les macros et les registres à lexèmes. J'espère
+% que ces trois cas (de zéro à deux étoiles) couvriront la plupart des
+% usage courants. Pour une gestion plus souple du développement des
+% arguments, attendez \LaTeX$3$ !
+%
+% Le comportement de \cs{Substitute} devrait être évident la plupart du
+% temps. Seul un cas particulier mérite sans doute une petite remarque :
+% dans le cas ou la liste \meta{de} est vide, la liste \meta{vers} est
+% insérée entre chaque paire de lexèmes de l'\meta{entrée} : en
+% particulier elle n'est pas insérée au début ni à la fin. Par exemple,
+% |\Substitute{abc}{}{1}| placera |a1b1c| dans \cs{ted@toks}.
+%
+% Enfin, il peut être utile de savoir qu'une fois que \cs{Substitute} a
+% fini son travail, le nombre de substitutions effectuées est accessible
+% dans le registre \cs{ted@count}. On peut ainsi s'en servir pour
+% compter, par exemple, le nombre d'espaces (donc approximativement de
+% mots) dans un texte, en faisant semblant d'opérer une substitution
+% dessus.
+%
+% \subsection{\topcs{ShowTokens}}
%
-% \medskip
% \DescribeMacro{\ShowTokens}
% La syntaxe de \cs{ShowTokens} est la suivante.
% \begin{quote}
-% \cs{ShowTokens}\meta{*}\marg{liste}
+% \cs{ShowTokens}\optstar\marg{liste}
% \end{quote}
-% Dans sa forme simple, \cs{ShowTokens} se contente d'afficher la liste de
-% lexème, un par ligne. Pour les lexèmes de type caractère, l'affichage
-% comprte le caractère lui-même, suivi de l'indication de son code de
-% catégorie sous forme parlante (comme |blank space|, |letter|, etc.). Pour
-% les séquence de contrôles et les carctères actifs, le (début du)
-% \cs{meaning} est également affiché, sans dépasser les 80 colonnes de large
-% afin de ne pas perturber l'affichage par ligne.
+% Dans sa forme simple, \cs{ShowTokens} se contente d'afficher la liste
+% de lexèmes, un par ligne. Pour les lexèmes de type caractère,
+% l'affichage comporte le caractère lui-même, suivi de l'indication de
+% son code de catégorie sous la forme utilisée par \cs{show}. Je
+% rappelle ci-dessous (table~\ref{cc}) pour la commodité du lecteur les
+% différents \cs{catcode}s possibles dans une liste de lexème, ainsi
+% qu'un exemple et la façon dont ils sont affichés par \cs{ShowTokens}.
+%
+% \begin{table}
+% \begin{tabular}{rcl}
+% 1 & |{| & |(begin-group character {)|\\
+% 2 & |}| & |(end-group character })|\\
+% 3 & |$| & |(math shift character $)|\\
+% 4 & |&| & |(alignment tab character &)|\\
+% 6 & |#| & |(macro parameter character #)|\\
+% 7 & |^| & |(superscript character ^)|\\
+% 8 & |_| & |(subscript character _)|\\
+% 10 & | | & |(blank space )|\\
+% 11 & |a| & |(the letter a)|\\
+% 12 & |0| & |(the character 0)|\\
+% 13 & |~| & |(active character=macro:->\nobreakspace {})|\\
+% \end{tabular}
+% \caption{Les \cs{catcode} : code, exemple, et description.}\label{cc}
+% \end{table}
%
-% \DescribeMacro{\ShowTokensLogonly}
-% \DescribeMacro{\ShowTokensOnline}
+% Pour les séquence de contrôles et les caractères actifs, le (début du)
+% \cs{meaning} est également affiché, sans dépasser les~$80$ colonnes de
+% large afin de ne pas perturber l'affichage par ligne. Il s'agit bien
+% sûr du sens courant au moment de l'appel à \cs{ShowTokens}.
+%
+% \DescribeMacro{\ShowTokensLogonly} \DescribeMacro{\ShowTokensOnline}
% Le comportement par défaut est d'afficher ces listes à la fois sur le
-% terminal et dans le fichier log. Si vous préférez que l'affichage n'ait lieu
-% que dans le fichier log, vous n'avez qu'à dire \cs{ShowTokensLogonly}. Si
-% vous souhaitez ensuite revenir au comportement par défaut, dites seulement
-% \cs{ShowTokensOnline}.
-%
-% La version étoilée de \cs{ShowTokens} fonctionne de la même façon que dans
-% le cas de \cs{Substitute} en développant son argument une fois avant d'en
-% commencer l'analyse. La même remarque que précédemment s'applique concernant
-% les macros et les registres.
+% terminal et dans le fichier log. Si vous préférez que l'affichage
+% n'ait lieu que dans le fichier log, vous n'avez qu'à dire
+% \cs{ShowTokensLogonly}. Si vous souhaitez ensuite revenir au
+% comportement par défaut, dites seulement \cs{ShowTokensOnline}.
+%
+% La version étoilée de \cs{ShowTokens} fonctionne de la même façon que
+% dans le cas de \cs{Substitute} en développant son argument une fois
+% avant d'en commencer l'analyse. La même remarque que précédemment
+% s'applique concernant les macros et les registres. Imaginons par
+% exemple que vous vouliez vérifier, après la définition d'une macro,
+% que vous avez bien les bons \cs{catcode}s :
%
+% \begin{quote}
+% |\begingroup \uccode`\~=32 \uppercase{\endgroup|\\
+% | \def\macro{1~2}}|\\
+% |\ShowTokens*{\macro} %| donne à l'écran : [...]\\
+% |1 (the character 1)|\\
+% | (active character=macro:-> )|\\
+% |2 (the character 2)|
+% \end{quote}
+%
% \medskip
-% J'aimerais conclure par la remarque suivante : au cours de la conception de
-% \pf{ted}, j'ai vraiment essayé de ne faire aucune hypothèse sur les lexèmes
-% présents dans la liste. Ainsi, vous pouvez utiliser librement des accolades,
-% des dièses, des espaces, des \cs{par}, des \cs{if}s, des \cs{bgroup} ou
-% \cs{egroup} dans toutes les listes de lexèmes. À ma connaissance à ce jour,
-% la seule limitation est que les séquences de contrôle qui apparaissent ne
-% doivent pas être (ou être \cs{let}-égales à) certaines des macros intimes de
-% \pf{ted}, commençant par \cs{ted@@}.
+% J'aimerais conclure par la remarque suivante : au cours de la
+% conception de \pf{ted}, j'ai vraiment essayé de ne faire aucune
+% hypothèse sur les lexèmes présents dans la liste. Ainsi, vous pouvez
+% utiliser librement des accolades, des dièses, des espaces, des
+% \cs{par}, des \cs{if}s, des \cs{bgroup} ou \cs{egroup} dans toutes les
+% listes de lexèmes. À ma connaissance à ce jour, la seule limitation
+% est que les séquences de contrôle qui apparaissent ne doivent pas être
+% (ou être \cs{let}-égales à) des macros intimes de \pf{ted},
+% c'est-à-dire celles commençant par \cs{ted@@}.
%
% \begin{quote}
% Vous savez maintenant tout ce qu'il y a à savoir sur l'utilisation de
-% \pf{ted}. Si vous souhaitez vous pencher sur son implémentation, il vous
-% faudra lire les commentaires en anglais car je n'ai pas eu le courage de
-% documenter mon code en deux langues.
+% \pf{ted}. Si vous souhaitez vous pencher sur son implémentation, il
+% vous faudra lire les commentaires en anglais car je n'ai pas eu le
+% courage de documenter mon code en deux langues.
% \end{quote}
%
% \begin{center}\large
@@ -278,91 +359,143 @@ This is a generated file. See ted.dtx for license information.
% \else
%
% The \pf{ted} package provides two user macros: \cs{Substitute} and
-% \cs{ShowTokens}. The first one is the primary goal of the package, but to be
-% able to do the second was the more difficult and interesting part while
-% writing the package. I made it into a user macro since I believe it can be
-% useful for debugging things, or for learning \TeX.
+% \cs{ShowTokens}. The first one is the primary goal of the package, but
+% to be able to do the second was the more interesting part while
+% writing the package. I made it into a user macro since I believe it
+% can be useful for debugging things, or for learning \TeX.
+%
+% \subsection{\topcs{Substitute}}
%
-% \medskip
% \DescribeMacro{\Substitute}
% The syntax of \cs{Substitute} is as follows.
% \begin{quote}
-% \cs{Substitute}\meta{*}\oarg{output}\marg{input}\marg{from}\marg{to}
+% \cs{Substitute}\optstar\oarg{output}\marg{input}\marg{from}\marg{to}
% \end{quote}
% Let's begin with the basics. Without star or optional argument, the
-% \cs{Substitute} macro will replace each occurence of the \meta{from} token
-% list with \marg{to} in the \meta{input}, and put the result in the
-% \cs{toks} register \cs{ted@toks}. This macro has a |@| in its name, but
-% since I think the \cs{Substitute} macro will be essentially be used by class
-% or package writers, this should be ok.
+% \cs{Substitute} macro will replace each occurrence of the \meta{from}
+% token list with \marg{to} in the \meta{input}, and put the result in
+% the \cs{toks} register \cs{ted@toks}. This macro has a |@| in its
+% name, but since I think the \cs{Substitute} macro will be essentially
+% be used by class or package writers, this should be ok.
%
% Anyway, if you don't like this name, you can specify another one as
-% \meta{output} using the optional argument. Your \meta{output} should be the
-% name of a \cs{toks} register. If you want the output to be put in a macro,
-% use \cs{def}\cs{macro} (or \cs{long}\cs{def}\cs{macro} or\ldots) as the
-% optional argument. Anyway, \meta{output}\marg{stuff} must be a legal syntax
-% for an assignment: using \cs{macro} as optional argument will not work (and
-% may actually result in chaos). Of course, if you want your output to be
-% placed in a macro, it should not contain unproperly placed hash signs
-% (that is, macro parameter tokens).
+% \meta{output} using the optional argument. Your \meta{output} should
+% be the name of a \cs{toks} register. If you want the output to be put
+% in a macro, use \cs{def}\cs{macro} (or \cs{long}\cs{def}\cs{macro}
+% or\ldots) as the optional argument. Anyway, \meta{output}\marg{stuff}
+% must be a legal syntax for an assignment: using \cs{macro} as optional
+% argument will not work (and may actually result in chaos). Of course,
+% if you want your output to be placed in a macro, it should not contain
+% improperly placed hash signs (that is, macro parameter tokens).
+%
+% \begin{quote}
+% |\Substitute{a#b#c}{a}{A}|\\
+% |\newtoks\yourtoks \Substitute[\yourtoks]{a#b#c}{a}{A}|\\
+% |\Substitute[\def\yourmacro]{a#b#c}{#}{##}|
+% \end{quote}
%
% The one-starred form of \cs{Substitute} is meant to help you when your
-% \meta{input} is not an explicit token list, but the contents of either a
-% macro or a \cs{toks} register, by expanding once its first mandatory
-% argument before proceeding. It spares you the pain of
-% using \cs{expandafter}s, especially in case you want to use the optional
+% \meta{input} is not an explicit token list, but the contents of either
+% a macro or a \cs{toks} register, by expanding once its first mandatory
+% argument before proceeding. It spares you the pain of using
+% \cs{expandafter}s, especially in case you want to use the optional
% argument too. This time, things are reversed compared to the optional
-% argument : using a macro instead of a toks register is easier. Actually,
-% with the starred form, the first argument can be \cs{macro} or
-% \cs{the}\cs{toksreg}, or anything whose one-time expansion is the token list
-% you want \cs{Substitute} to act upon.
-%
-% The two-starred form is also meant to avoid you trouble with development. It
-% expands its three mandatory arguments once before executiing. The remark
-% about macros and \cs{toks} register still holds. I hope this three cases
-% (from zero to two stars) will suffice for most purpose. For a better
-% handling of arguments expansion, wait for \LaTeX$3$!
-%
-% The action of \cs{Substitute} is pretty obvious most of the time. Maybe a
-% particular case needs some precision: when \meta{from} is empty, then the
-% \meta{to} list gets inserted between each two tokens of the \cs{input}, but
-% not before the first one. For example, \cs{Substitute}|{abc}{}{1}| puts
-% |a1b1c| in \cs{ted@toks}.
+% argument : using a macro instead of a toks register is easier.
+% Actually, with the starred form, the first argument can be \cs{macro}
+% or \cs{the}\cs{toksreg}, or anything whose one-time expansion is the
+% token list you want \cs{Substitute} to act upon.
+%
+% \begin{quote}
+% |\def\abc{abccdef} \newtoks\abctoks \abctoks{abc}|\\
+% |\Substitute{\abc}{cc}{C} %| gives |\abc|\\
+% |\Substitute*{\abc}{cc}{C} %| gives |abCdef|\\
+% |\Substitute*{\the\abctoks}{cc}{C} %| too
+% \end{quote}
+%
+% The two-starred form is also meant to avoid you trouble with
+% development. It expands its three mandatory arguments once before
+% executing. The remark about macros and \cs{toks} register still
+% holds. I hope this three cases (from zero to two stars) will suffice
+% for most purpose. For a better handling of arguments expansion, wait
+% for \LaTeX$3$!
+%
+% The action of \cs{Substitute} is pretty obvious most of the time.
+% Maybe a particular case needs some precision: when \meta{from} is
+% empty, then the \meta{to} list gets inserted between each two tokens
+% of the \cs{input}, but not before the first one. For example,
+% \cs{Substitute}|{abc}{}{1}| puts |a1b1c| in \cs{ted@toks}.
+%
+% Finally, it may be useful to know that, after \cs{Subsitute} finished
+% its job, it leaves the number of replaced occurrences in the count
+% register \cs{ted@count}. This can be used, for example, to count
+% spaces (hence words) in a text, by making a fake substitution on it.
+%
+% \subsection{\topcs{ShowTokens}}
%
-% \medskip
% \DescribeMacro{\ShowTokens}
% The syntax of \cs{ShowTokens} is as follows.
% \begin{quote}
-% \cs{ShowTokens}\meta{*}\marg{list}
+% \cs{ShowTokens}\optstar\marg{list}
% \end{quote}
-% In its simple form, \cs{ShowTokens} just shows the list, one token per line.
-% For characters tokens, its prints the character, and its category code in
-% human-friedly form (such as ``blank space'', ``letter'', etc.). For control
-% sequences and active characters, it also prints (the beginning of) their
-% current \cs{meaning} as a bonus.
+% In its simple form, \cs{ShowTokens} just shows the list, one token per
+% line. For characters tokens, its prints the character, and its
+% category code in human-friendly form. For the sake of readability,
+% here is (table~\ref{cc}) a reminder of the possible \cs{catcode}s,
+% with an exemple and the way \cs{ShowTokens} displays them.
+%
+% \begin{table}
+% \begin{tabular}{rcl}
+% 1 & |{| & |(begin-group character {)|\\
+% 2 & |}| & |(end-group character })|\\
+% 3 & |$| & |(math shift character $)|\\
+% 4 & |&| & |(alignment tab character &)|\\
+% 6 & |#| & |(macro parameter character #)|\\
+% 7 & |^| & |(superscript character ^)|\\
+% 8 & |_| & |(subscript character _)|\\
+% 10 & | | & |(blank space )|\\
+% 11 & |a| & |(the letter a)|\\
+% 12 & |0| & |(the character 0)|\\
+% 13 & |~| & |(active character=macro:->\nobreakspace {})|\\
+% \end{tabular}
+% \caption{Possible \cs{catcode}s: code, example, and description.}\label{cc}
+% \end{table}
+%
+% For control sequences and active characters, it
+% also prints their current \cs{meaning} as a bonus, or only the
+% beginning of it (ending with \cs{ETC.}) if it is more than one line
+% ($80$ columns) long.
%
% \DescribeMacro{\ShowTokensLogonly}
% \DescribeMacro{\ShowTokensOnline}
-% The default is to show this list both in the terminal and in the log file.
-% If you don't want it to be printed on the terminal, just say
-% \cs{ShowTokensLogonly}. If you change your mind latter, you can restore the
-% default behaviour with \cs{ShowTokensOnline}.
+% The default is to show this list both in the terminal and in the log
+% file. If you don't want it to be printed on the terminal, just say
+% \cs{ShowTokensLogonly}. If you change your mind latter, you can
+% restore the default behaviour with \cs{ShowTokensOnline}.
%
-% The starred form of \cs{ShowTokens} works the same as for \cs{Substitute}:
-% it expands its argument once before analysing and displaying it. The same
-% remarks hold: use \cs{macro} or \cs{the}\cs{toksreg} in the argument.
+% The starred form of \cs{ShowTokens} works the same as for
+% \cs{Substitute}: it expands its argument once before analysing and
+% displaying it. The same remarks hold: use \cs{macro} or
+% \cs{the}\cs{toksreg} in the argument.
+%
+% \begin{quote}
+% |\begingroup \uccode`\~=32 \uppercase{\endgroup|\\
+% | \def\macro{1~2}}|\\
+% |\ShowTokens*{\macro} %| prints on screen: [...]\\
+% |1 (the character 1)|\\
+% | (active character=macro:-> )|\\
+% |2 (the character 2)|
+% \end{quote}
%
% \medskip
-% I would like to conclude with the following remark: I have really tried to
-% make sure \pf{ted}'s macros will work fine even with the wierdest token list.
-% In particular, you can freely use begin-group and end-group characters, hash
-% signs, spaces, \cs{bgroup} and \cs{egroup}, \cs{par}, \cs{if}s, as well as
-% exotic charcode-\cs{catcode} pairs in every argument of the macros. As far
-% as I am aware, the only restriction is you should not use
-% some\footnote{Precisely, none of the control sequence in the token lists
-% should be \cs{let}-equal to \cs{ted@@end}, \cs{ted@@special},
-% \cs{ted@@active} as defined below.} of the very private macros of \pf{ted}
-% (those beginning with \cs{ted@@}) in your token lists.
+% I would like to conclude with the following remark: I have really
+% tried to make sure \pf{ted}'s macros will work fine even with the
+% wierdest token list. In particular, you can freely use begin-group
+% and end-group characters, hash signs, spaces, \cs{bgroup} and
+% \cs{egroup}, \cs{par}, \cs{if}s, as well as exotic
+% charcode-\cs{catcode} pairs in every argument of the macros. As far as
+% I am aware, the only restriction is you should not use the very
+% private macros of \pf{ted} (those beginning with \cs{ted@@}) in your
+% token lists.
%
% \fi
%
@@ -370,61 +503,59 @@ This is a generated file. See ted.dtx for license information.
%
% \section{Implementation}
%
-% A important problem, when trying to substitute things in token lists, is to
-% handle begin-group and end-group tokens, since prevent us from to reading
-% the tokens one by one, and tend to be difficult to handle individually. Two
-% more kinds of tokens are special: the space tokens, since
-% they\footnote{Actually, only tokens with charcode $32$ and \cs{catcode}~$10$
-% (i.e. $32_{10}$ tokens) are concerned. However, we will process all
-% \cs{catcode}-$10$ tokens the same way.} cannot be grabbed as the undelimited
-% argument of a macro, and the parameter tokens (hash signs), since they
-% cannot be part of the delimiters in the parameter text of a macro. From now
-% on, ``special tokens'' thus denotes tokens with \cs{catcode} $1$, $2$, $6$
-% or $10$.
-%
-% To get rid of these problems, the \cs{Substitute} command procedes in three
-% steps. First, encode the input, replacing all special tokens with nice
-% control sequences representing them, then do the actual substitution, and
-% finally decode the output, replacing the special control sequences with the
-% initial special tokens.
-%
-% Encoding is the hard part. The idea is to try reading the tokens one by one;
-% for this we have two means: using a macro with one undelimited argument, or
-% something like \cs{let}. The former doesn't work well with \cs{catcode}~$1$,
-% $2$ or $10$ tokens, and the later do not see the name of the token (its
-% character code, or its name for a CS). So we need to use both
-% \cs{futurelet}, a ``grabbing'' macro with argument, and \cs{string} in order
-% to scan the tokens. Actually, the encoding procedes in two passes: in the
-% first, we try and detect the special tokens, storing their character codes
-% for later use, then do the the actual encoding in the last pass.
-%
-% Decoding also processes the tokens one by one, and is simpler, since special
-% cases are allready detected. There is, however, a trick with groups since,
-% when we encouter a begin-group character, we have to wait for the
-% corresponding end-group before adding the whole thing to the output. There
-% is also a simpler version of decoding, for \cs{ShowTokens}, for screen/log
-% output, with no need to use this trick, since it only outputs
-% \cs{catcode}-$12$ charachters. Finally, the substitution part uses a macro
-% with delimited argument, defined on the fly, using an idea of Jean-Côme
-% Charpentier.
+% A important problem, when trying to substitute things in token lists,
+% is to handle begin-group and end-group tokens, since they prevent us
+% from to reading the tokens one by one, and tend to be difficult to
+% handle individually. Two more kinds of tokens are special: the space
+% tokens, since they\footnote{Actually, only tokens with charcode $32$
+% and \cs{catcode}~$10$ (i.e. $32_{10}$ tokens) are concerned.} cannot
+% be grabbed as the non-delimited argument of a macro, and the parameter
+% tokens (hash signs), since they cannot be part of the delimiters in
+% the parameter text of a macro. From now on, ``special tokens'' thus
+% denotes tokens with \cs{catcode} $1$, $2$, $6$ or $10$.
+%
+% To get rid of these problems, the \cs{Substitute} command proceeds in
+% three steps. First, encode the input, replacing all special tokens
+% with nice control sequences representing them, then do the actual
+% substitution, and finally decode the output, replacing the special
+% control sequences with the initial special tokens.
+%
+% Encoding is the hard part. The idea is to try reading the tokens one
+% by one; for this we have two means: using a macro with one
+% non-delimited argument, or something like \cs{let}. The former doesn't
+% work well with \cs{catcode}~$1$, $2$ or $10$ tokens, and the later do
+% not see the name of the token (its character code, or its name for a
+% CS). So we need to use both \cs{futurelet}, a ``grabbing'' macro with
+% argument, and \cs{string} in order to scan the tokens. Actually, the
+% encoding proceeds in two passes: in the first, we try and detect the
+% special tokens, storing their character codes for later use, then do
+% the actual encoding in the last pass.
+%
+% Decoding also processes the tokens one by one, and is simpler, since
+% special cases are already detected. There is, however, a trick with
+% groups since, when we encounter a begin-group character, we have to
+% wait for the corresponding end-group before adding the whole thing to
+% the output. There is also a simpler version of decoding, for
+% \cs{ShowTokens}, for screen/log output, with no need to use this
+% trick, since it only outputs \cs{catcode}-$12$ characters. Finally,
+% the substitution part uses a macro with delimited argument, defined on
+% the fly.
%
% The code is divided as follows.
-% \begin{enumerate} \setlength\itemsep{0pt}%
-% \item Encoding -- (a) pre-scan (b) encode
-% \item Decoding
-% \item Substitution
-% \item Screen display for \cs{ShowTokens}
-% \item Definition of the user commands
-% \end{enumerate}
+% \par\vspace{-0.5\baselineskip}
+% \secttoc
+% \par\vspace{-0.5\baselineskip}
%
% \begin{macro}{\ted@toks}
% \begin{macro}{\ted@list}
% \begin{macro}{\ted@code}
-% Before we begin, just allocate (or give a nice name to) a few registers.
+% Before we begin, just allocate (or give a nice name to) a few
+% registers.
% \begin{macrocode}
\@ifdefinable\ted@toks{\newtoks\ted@toks}
\@ifdefinable\ted@list{\let\ted@list\toks@}
\@ifdefinable\ted@code{\let\ted@code\count@}
+\@ifdefinable\ted@count{\newcount\ted@count}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -434,17 +565,19 @@ This is a generated file. See ted.dtx for license information.
%
% \begin{macro}{\ted@encloop}
% \begin{macro}{\ted@encloop@}
-% The two passes use the same loop for reading the input allmost token by
-% token. This loop grabs the next token through a \cs{futurelet}\ldots
+% The two passes use the same loop for reading the input almost token
+% by token. This loop grabs the next token through a
+% \cs{futurelet}\ldots
% \begin{macrocode}
\newcommand\ted@encloop{%
\futurelet\@let@token
\ted@encloop@}
% \end{macrocode}
-% \ldots then looks at it with some \cs{ifx} and \cs{ifcat} (non nested, since
-% the token could be an \cs{if} itself), in order to distinguish between
-% three cases: normal token, end reached, or special token. In the later case,
-% remember wich kind of special token it is, using a numeric code.
+% \ldots then looks at it with some \cs{ifx} and \cs{ifcat} (non nested,
+% since the token could be an \cs{if} itself), in order to distinguish
+% between three cases: normal token, end reached, or special token. In
+% the later case, remember which kind of special token it is, using a
+% numeric code.
% \begin{macrocode}
\newcommand\ted@encloop@{%
\let\next\ted@do@normal
@@ -473,7 +606,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ted@@end}
% \begin{macro}{\ted@gobble@end}
-% Here we used the following to detect the end, then gobble it when reached.
+% Here we used the following to detect the end, then gobble it when
+% reached.
% \begin{macrocode}
\newcommand\ted@@end{\ted@@end@}
% \end{macrocode}
@@ -486,12 +620,13 @@ This is a generated file. See ted.dtx for license information.
%
% \begin{macro}{\ted@sanitize}
% \begin{macro}{\ted@@active}
-% Now, this detection method, with \cs{futurelet} and \cs{ifcat}, is unable to
-% distinguish the following three cases for potential special tokens: (i) a
-% ``true'' (explicit) special token, (ii) a CS \cs{let}-equal to a special
-% token, (iii) an active character \cs{let}-equal to a special token. While
-% this is pre-scanning's job to detect the (ii) case, the (iii) can be easily
-% got rid of by redefining locally all active characters.
+% Now, this detection method, with \cs{futurelet} and \cs{ifcat}, is
+% unable to distinguish the following three cases for potential special
+% tokens: (i) a ``true'' (explicit) special token, (ii) a CS
+% \cs{let}-equal to a special token, (iii) an active character
+% \cs{let}-equal to a special token. While this is pre-scanning's job
+% to detect the (ii) case, the (iii) can be easily got rid of by
+% redefining locally all active characters.
% \begin{macrocode}
\count@\catcode\z@ \catcode\z@\active
\newcommand\ted@sanitize{%
@@ -504,22 +639,18 @@ This is a generated file. See ted.dtx for license information.
% \begin{macrocode}
\newcommand\ted@@active{\ted@@active@}
% \end{macrocode}
-% This sanitizing macro also mark active characters by \cs{let}-ing them equal
-% to \cs{ted@@active} in ordrer to detect them easily later, for exemple while
-% displaying on-screen token analysis.
-% All operations (scanning, replacing, display and decoding) are going to
-% happen inside a group where \cs{ted@sanitize} has been executed, so that
-% active characters are no longer an issue.
-% \end{macro}
-% \end{macro}
+% This sanitizing macro also mark active characters by \cs{let}-ing them
+% equal to \cs{ted@@active} in order to detect them easily later, for
+% example while displaying on-screen token analysis. All operations
+% (scanning, replacing, display and decoding) are going to happen inside
+% a group where \cs{ted@sanitize} has been executed, so that active
+% characters are no longer an issue. \end{macro} \end{macro}
%
-% \begin{macro}{\ted@encode}
-% \begin{macro}{\ted@do@normal}
-% \begin{macro}{\ted@do@special}
-% The \cs{ted@encode} macro is the master macro for encoding. It only
-% initialise a few things and launches the two loops. We select one of the
-% tree stpes by \cs{let}-ing \cs{ted@do@normal} and \cs{ted@do@special} to
-% the appropriate action.
+% \begin{macro}{\ted@encode} \begin{macro}{\ted@do@normal}
+% \begin{macro}{\ted@do@special} The \cs{ted@encode} macro is the master
+% macro for encoding. It only initialise a few things and launches the
+% two loops. We select one of the tree steps by \cs{let}-ing
+% \cs{ted@do@normal} and \cs{ted@do@special} to the appropriate action.
% \begin{macrocode}
\newcommand\ted@encode[1]{%
\ted@list{}%
@@ -536,9 +667,9 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \end{macro}
% \begin{macro}{\ted@assert@listempty}
-% After the last loop, \cs{ted@list} should be empty. If it's not, it means
-% something very weird happened during the encoding procedure. I hope the code
-% below will never be executed :)
+% After the last loop, \cs{ted@list} should be empty. If it's not, it
+% means something very weird happened during the encoding procedure. I
+% hope the code below will never be executed :)
% \begin{macrocode}
\newcommand\ted@assert@listempty{%
\edef\next{\the\ted@list}%
@@ -563,13 +694,14 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ted@scan@special}
% For special tokens, it's harder. We must distinguish explicit
-% character tokens from control sequences \cs{let}-equal to special tokens.
-% For this, we use \cs{string}, then grab the next character to see wether its
-% code is \cs{escapechar} or not. Actually, things are not this easy, for two
-% reasons. First, we have to make sure the next character's code is not
-% allready \cs{escapechar} before the \cs{string}, by accident. For this
-% purpose, we set \cs{escapechar} to~$0$ except if next character's code is
-% also~$0$, in which case we prefer~$1$.
+% character tokens from control sequences \cs{let}-equal to special
+% tokens. For this, we use \cs{string}, then grab the next character to
+% see whether its code is \cs{escapechar} or not. Actually, things are
+% not this easy, for two reasons. First, we have to make sure the next
+% character's code is not already \cs{escapechar} before the
+% \cs{string}, by accident. For this purpose, we set \cs{escapechar}
+% to~$0$ except if next character's code is also~$0$, in which case we
+% prefer~$1$.
% \begin{macrocode}
\count@\catcode\z@ \catcode\z@ 12
\newcommand\ted@scan@special{%
@@ -581,12 +713,13 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ted@check@space}
% \begin{macro}{\ted@check@space@}
-% Second, we have to handle carefully the case of the next token being the
-% $32_{10}$ token, since we cannot grab this one with a macro. We are in this
-% case if and only if the token we just \cs{string}ed was a character token
-% with code $32$, and it is enough to check if next token's \cs{catcode} is
-% $10$ in order to detect it, since it will be $12$ otherwise. In order to
-% check this, we use \cs{futurelet} again for pre-scanning.
+% Second, we have to handle carefully the case of the next token being
+% the $32_{10}$ token, since we cannot grab this one with a macro. We
+% are in this case if and only if the token we just \cs{string}ed was a
+% character token with code $32$, and it is enough to check if next
+% token's \cs{catcode} is $10$ in order to detect it, since it will be
+% $12$ otherwise. In order to check this, we use \cs{futurelet} again
+% for pre-scanning.
% \begin{macrocode}
\newcommand\ted@check@space{%
\futurelet\@let@token
@@ -605,12 +738,13 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \end{macro}
% \begin{macro}{\ted@list@special}
-% Now that we got rid of this nasty space problem, we know for sure that the
-% next token has \cs{catcode} $12$, so we can easily grab it as an argument,
-% find its charcode, and decide wether the original token was a control
-% sequence or not. Note the \cs{expandafter} over \cs{endgroup} trick, since
-% we need to add the charcode to the list outside the group (opened for the
-% modified \cs{escapechar}) though it was set inside.
+% Now that we got rid of this nasty space problem, we know for sure that
+% the next token has \cs{catcode} $12$, so we can easily grab it as an
+% argument, find its charcode, and decide whether the original token was
+% a control sequence or not. Note the \cs{expandafter} over
+% \cs{endgroup} trick, since we need to add the charcode to the list
+% outside the group (opened for the modified \cs{escapechar}) though it
+% was set inside.
% \begin{macrocode}
\newcommand*\ted@list@special[1]{%
\ted@code`#1\relax
@@ -625,8 +759,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@addlist}
-% Here we used the following macro to add an element to the list, which is
-% space-separated.
+% Here we used the following macro to add an element to the list, which
+% is space-separated.
% \begin{macrocode}
\newcommand*\ted@addlist[1]{%
\ted@list\expandafter{\the\ted@list#1 }}
@@ -642,8 +776,8 @@ This is a generated file. See ted.dtx for license information.
% \cs{let}\cs{ted@do@special}\cs{ted@special@out}
% \end{quote}
% \begin{macro}{\ted@addtoks@encloop}
-% The first one is very easy : normal tokens are just grabbed as arguments and
-% appended to the output, then the loop continues.
+% The first one is very easy : normal tokens are just grabbed as
+% arguments and appended to the output, then the loop continues.
% \begin{macrocode}
\newcommand\ted@addtoks@encloop[1]{%
\ted@toks\expandafter{\the\ted@toks#1}%
@@ -651,8 +785,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@special@out}
-% Special tokens need to be encoded, but before, just check if they are really
-% special: they aren't if the corresponding code is $-1$.
+% Special tokens need to be encoded, but before, just check if they are
+% really special: they aren't if the corresponding code is $-1$.
% \begin{macrocode}
\newcommand\ted@special@out{%
\ifnum\ted@list@read=\m@ne
@@ -664,12 +798,12 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@cs@clean}
-% Even if the potentially special token was not a real one, we have work to
-% do. Indeed, in the first pass we did break it using a \cs{string}, and thus
-% we introduced some foreign tokens in the stream. Most of them are not
-% important since they have \cs{catcode}~$12$. Anyway, some of them may be
-% space tokens : in this case we have extra $32$'s in our list. So, we need to
-% check this before going any further.
+% Even if the potentially special token was not a real one, we have work
+% to do. Indeed, in the first pass we did break it using a \cs{string},
+% and thus we introduced some foreign tokens in the stream. Most of them
+% are not important since they have \cs{catcode}~$12$. Anyway, some of
+% them may be space tokens : in this case we have extra $32$'s in our
+% list. So, we need to check this before going any further.
% \begin{macrocode}
\newcommand\ted@cs@clean[1]{%
\expandafter\ted@add@toks{#1}%
@@ -677,9 +811,9 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@cscl@loop}
-% We first add the CS to the output, then break it with a \cs{string} in order
-% to look at its name with the folowing loop. It first grabs everything to the
-% first space\ldots
+% We first add the CS to the output, then break it with a \cs{string} in
+% order to look at its name with the following loop. It first grabs
+% everything to the first space\ldots
% \begin{macrocode}
\@ifdefinable\ted@cscl@loop{%
\def\ted@cscl@loop#1 {%
@@ -702,10 +836,10 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
%
% \begin{macro}{\ted@special@encode}
-% Now, let's come back to the special tokens. As we don't need the token to
-% encode it (we allready know its \cs{catcode} from \cs{ted@code}, and its
-% charcode is stored in the list), we first gobble it in order to prepare for
-% next iteration.
+% Now, let's come back to the special tokens. As we don't need the token
+% to encode it (we already know its \cs{catcode} from \cs{ted@code},
+% and its charcode is stored in the list), we first gobble it in order
+% to prepare for next iteration.
% \begin{macrocode}
\newcommand\ted@special@encode{%
\afterassignment\ted@special@encode@
@@ -713,12 +847,12 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@special@encode@}
-% Then we encode it in two steps : first, create a control sequence with name
-% \cs{ted@@}\meta{code}\meta{charcode}, where code is a digit
-% denoting\footnote{I don't store the \cs{catcode} for two reasons : first,
-% having a single digit is easier; second, having the true catcode would be
-% useless (though it could maybe make the code more readable).} the
-% \cs{catcode} of the special token, \ldots
+% Then we encode it in two steps : first, create a control sequence with
+% name \cs{ted@@}\meta{code}\meta{charcode}, where code is a digit
+% denoting\footnote{I don't store the \cs{catcode} for two reasons:
+% first, having a single digit is easier; second, having the true
+% catcode would be useless (though it could maybe make the code more
+% readable).} the \cs{catcode} of the special token, \ldots
% \begin{macrocode}
\newcommand\ted@special@encode@{%
\expandafter\ted@special@encode@@\expandafter{%
@@ -727,8 +861,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ted@special@encode@@}
% \begin{macro}{\ted@@special}
-% \ldots then, mark this CS as a special token encoding, in order to make it
-% easier to detect later, add it to the output and loop again.
+% \ldots then, mark this CS as a special token encoding, in order to
+% make it easier to detect later, add it to the output and loop again.
% \begin{macrocode}
\newcommand*\ted@special@encode@@[1]{%
\ted@list@advance
@@ -743,8 +877,8 @@ This is a generated file. See ted.dtx for license information.
%
% \begin{macro}{\ted@list@read}
% \begin{macro}{\ted@list@read@}
-% Here we used the folowing macros in order to manage our charcode list. The
-% reading one is fully expandable.
+% Here we used the following macros in order to manage our charcode list.
+% The reading one is fully expandable.
% \begin{macrocode}
\newcommand\ted@list@read{%
\expandafter\ted@list@read@\the\ted@list\@nil}
@@ -758,8 +892,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ted@list@advance}
% \begin{macro}{\ted@list@advance@}
-% Since it's expandable, it cannot change the list, so we need a separate
-% macro to remove the first element from the list, once read.
+% Since it's expandable, it cannot change the list, so we need a
+% separate macro to remove the first element from the list, once read.
% \begin{macrocode}
\newcommand\ted@list@advance{%
\expandafter\ted@list@advance@\the\ted@list\@nil}
@@ -775,20 +909,20 @@ This is a generated file. See ted.dtx for license information.
% \subsection{Decoding}
%
% \begin{macro}{\ted@add@toks}
-% Main decoding macro is \cs{ted@decode}. It is again a loop, processing the
-% token list one by one. For normal tokens, things are easy as allways: just
-% add them to the output, via
+% Main decoding macro is \cs{ted@decode}. It is again a loop, processing
+% the token list one by one. For normal tokens, things are easy as
+% always: just add them to the output, via
% \begin{macrocode}
\newcommand\ted@add@toks[1]{%
\ted@toks\expandafter{\the\ted@toks#1}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@decode}
-% Encoded special tokens are easily recognized, since they were \cs{let} equal
-% to \cs{ted@@special}. In order to decode it, we use the name of the CS. The
-% following macro uses \LaTeX-style \cs{if} in order to avoid potential
-% nesting problems when \cs{ifs} are present in the token list being
-% processed.
+% Encoded special tokens are easily recognized, since they were \cs{let}
+% equal to \cs{ted@@special}. In order to decode it, we use the name of
+% the CS. The following macro uses \LaTeX-style \cs{if} in order to
+% avoid potential nesting problems when \cs{ifs} are present in the
+% token list being processed.
% \begin{macrocode}
\newcommand\ted@decode[1]{%
\ifx#1\ted@@end \expandafter\@gobble\else\expandafter\@firstofone\fi{%
@@ -805,17 +939,18 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@decode@special}
-% The next macro should then gobble the |ted@@| part of the CS name, and use
-% the last part as two numeric codes (here we use the fact that the first one
-% is only a digit).
+% The next macro should then gobble the |ted@@| part of the CS name, and
+% use the last part as two numeric codes (here we use the fact that the
+% first one is only a digit).
% \begin{macrocode}
\@ifdefinable\ted@decode@special{%
\begingroup\escapechar\m@ne \expandafter\endgroup\expandafter
\def\expandafter\ted@decode@special\string\ted@@#1#2\@nil{%
% \end{macrocode}
-% It then prodeces according to the first code, building back the original
-% token and adding it to the output. The first two kinds of tokens (macro
-% parameter characters and blank spaces) are easily dealt with.
+% It then proceeds according to the first code, building back the
+% original token and adding it to the output. The first two kinds of
+% tokens (macro parameter characters and blank spaces) are easily dealt
+% with.
% \begin{macrocode}
\ifcase#1
\begingroup \uccode`##=#2 \uppercase{\endgroup
@@ -825,20 +960,21 @@ This is a generated file. See ted.dtx for license information.
\ted@add@toks{ }}%
\or
% \end{macrocode}
-% For begin-group and end-group characters, we have a problem, since they are
-% impossible to handle individually: we can only add a \meta{balanced text} to
-% the output. So, when we find a begin-group character, we just open a group
-% (a real one), and start decoding again inside the group, until we find the
-% correponding end-group character. Then, we enclose the local decoded list
-% of tokens into the correct begin-group/end-group pair, and then add it to
-% the output one group level below, using the
-% \cs{expandafter}-over-\cs{endgroup} trick (essential here).
+% For begin-group and end-group characters, we have a problem, since
+% they are impossible to handle individually: we can only add a
+% \meta{balanced text} to the output. So, when we find a begin-group
+% character, we just open a group (a real one), and start decoding again
+% inside the group, until we find the corresponding end-group character.
+% Then, we enclose the local decoded list of tokens into the correct
+% begin-group/end-group pair, and then add it to the output one group
+% level below, using the \cs{expandafter}-over-\cs{endgroup} trick
+% (essential here).
% \begin{macrocode}
\begingroup \ted@toks{}%
\uccode`{=#2
\or
\uccode`}=#2
- \uppercase{\ted@toks\expandafter{\expandafter{\the\ted@toks}}}
+ \uppercase{\ted@toks\expandafter{\expandafter{\the\ted@toks}}}%
\expandafter\endgroup
\expandafter\ted@add@toks\expandafter{\the\ted@toks}%
\fi}}
@@ -848,18 +984,19 @@ This is a generated file. See ted.dtx for license information.
% \subsection{Substitution}
%
% For this part, the idea\footnote{for which I am grateful to Jean-Côme
-% Charpentier, who first taught me the clever use delimited arguments (and lots
-% of other wonderful things) in \nolinkurl{fr.comp.text.tex}} is to use a macro
-% whose first argument is delimited with the \meta{from} string, wich outputs
-% the first argument followed by the \meta{to} string, and loops. Obviously
-% this macro has to be defined on the fly. All tokens lists need to be encoded
-% first, and the output decoded at end. Since all this needs to happens inside
-% a group (for \cs{ted@sanitize} and the marking up of special-charaters
-% control sequences), remember to ``export'' \cs{ted@toks} when done.
+% Charpentier, who first taught me the clever use delimited arguments
+% (and lots of other wonderful things) in \nolinkurl{fr.comp.text.tex}}
+% is to use a macro whose first argument is delimited with the
+% \meta{from} string, which outputs the first argument followed by the
+% \meta{to} string, and loops. Obviously this macro has to be defined on
+% the fly. All tokens lists need to be encoded first, and the output
+% decoded at end. Since all this needs to happens inside a group (for
+% \cs{ted@sanitize} and the marking up of special-characters control
+% sequences), remember to ``export'' \cs{ted@toks} when done.
%
% \begin{macro}{\ted@Substitude}
% The main substitution macro is as follows. Arguments are \meta{input},
-% \meta{from}, \meta{to}. \cs{ted@output} will be discussed later.
+% \meta{from}, \meta{to}. \cs{ted@output} will be discussed later.
% \begin{macrocode}
\newcommand\ted@Substitute[3]{%
\begingroup \ted@sanitize
@@ -874,9 +1011,9 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@def@subsmac}
-% The actual iterative substitution macro is defined by the folowing macro,
-% whose arguments are the \meta{to} string, encoded, and the plain \meta{from}
-% string.
+% The actual iterative substitution macro is defined by the following
+% macro, whose arguments are the \meta{to} string, encoded, and the
+% plain \meta{from} string.
% \begin{macrocode}
\newcommand\ted@def@subsmac[2]{%
\ted@encode{#2}%
@@ -884,34 +1021,49 @@ This is a generated file. See ted.dtx for license information.
\expandafter##\expandafter1\the\ted@toks##2{%
\ted@add@toks{##1}%
\ifx##2\ted@@end
- \expandafter\@gobble
+ \expandafter\@firstoftwo
\else
- \expandafter\@firstofone
+ \expandafter\@secondoftwo
\fi{%
+ \expandafter\ted@remove@nil\the\ted@toks
+ }{%
+ \global\advance\ted@count\@ne
\ted@add@toks{#1}\ted@subsmac@loop##2}}%
\expandafter\ted@def@subsmac@\expandafter{\the\ted@toks}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@def@subsmac@}
-% While we have the encoded \meta{from} string at hand, define the start-loop
-% macro.
+% While we have the encoded \meta{from} string at hand, define the
+% start-loop macro.
% \begin{macrocode}
\newcommand\ted@def@subsmac@[1]{%
\def\ted@subsmac{%
+ \global\ted@count\z@
\ted@toks\expandafter{\expandafter}%
- \expandafter\ted@subsmac@loop\the\ted@toks#1\ted@@end}}
+ \expandafter\ted@subsmac@loop\the\ted@toks\ted@@nil#1\ted@@end}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ted@remove@nil}
+% You probably noticed the \cs{ted@@nil} after \cs{ted@toks} in the
+% above definition. This is to avoid problems while trying to
+% substitute something like ``AA'' in a list ending with ``A'' (new in
+% v1.05). We need to remove it when finished.
+% \begin{macrocode}
+\@ifdefinable\ted@remove@nil{%
+ \long\def\ted@remove@nil#1\ted@@nil{%
+ \ted@toks{#1}}}
% \end{macrocode}
% \end{macro}
%
% \subsection{Display}
%
% \begin{macro}{\ted@ShowTokens}
-% In order to display the tokens one by one, we first encode the string
+% In order to display the tokens one by one, we first encode the string.
% \begin{macrocode}
\newcommand\ted@ShowTokens[1]{%
\begingroup \ted@sanitize
\ted@toks{#1}%
- \ted@typeout{--- Begin token decompositon of:}%
+ \ted@typeout{--- Begin token decomposition of:}%
\ted@typeout{\@spaces \the\ted@toks}%
\ted@encode{#1}%
\expandafter\ted@show@toks\the\ted@toks\ted@@end
@@ -920,28 +1072,51 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@show@toks}
-% Then we proceed, allmost like decoding, iteratively, processing the encoded
-% tokens one by one. We detect control sequences the same way as in
-% pre-scanning.
+% Then we proceed, almost like decoding, iteratively, processing the
+% encoded tokens one by one. We detect control sequences the same way as
+% in pre-scanning. For our tests (and also for use in
+% \cs{ted@show@toks@}) we embed |#1| into \cs{ted@toks} in order to
+% nest the \cs{if}s without fear. There are four cases that need to be
+% typeset in different ways : active character, CS that represent a
+% special token, normal CS, normal character token. However, we need to
+% do one more test to detect the character tokens whose charcode is
+% $32$, before we apply \cs{string} to it in order to check if it was a
+% control sequence.
% \begin{macrocode}
\count@\catcode\z@ \catcode\z@ 12
\newcommand\ted@show@toks[1]{%
- \ifx#1\ted@@end \expandafter\@gobble\else\expandafter\@firstofone\fi{%
- \ted@toks{#1}%
- \begingroup
- \escapechar\if\noexpand#1^^00 \@ne \else \z@ \fi
- \expandafter\ted@show@toks@\string#1\@nil
- \ted@show@toks}}
+ \ted@toks{#1}\expandafter
+ \ifx\the\ted@toks\ted@@end \else\expandafter
+ \ifx\the\ted@toks\ted@@active
+% \end{macrocode}
+% It's time to think about the following: we are inside a group where
+% all active characters were redefined, but we nonetheless want to
+% display their meaning. In order to do this, the display need to
+% actually happen after the current group is finished. For this we use
+% \cs{aftergroup} (with specialized macro for displaying each kind of
+% token).
+% \begin{macrocode}
+ \aftergroup\ted@type@active
+ \expandafter\aftergroup\the\ted@toks
+ \else
+ \if\expandafter\noexpand\the\ted@toks\@sptoken
+ \aftergroup\ted@type@normal
+ \expandafter\aftergroup\the\ted@toks
+ \else
+ \begingroup
+ \escapechar\if\noexpand#1^^00 \@ne \else \z@ \fi
+ \expandafter\expandafter\expandafter\ted@show@toks@
+ \expandafter\string\the\ted@toks\@nil
+ \fi
+ \fi
+ \expandafter\ted@show@toks
+ \fi}
\catcode\z@\count@
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@show@toks@}
-% We stored the current token so that it can be used in the next macro, though
-% previously broken by the \cs{string}, and moreover we can nest the \cs{if}s
-% freely since it is hidden in a register (in case it would be a \cs{if}
-% itself). The four cases are : CS representing a special token, normal CS,
-% active character (since we cannot show its category with \cs{meaning}), and
-% finally normal character token.
+% Now test the remaining cases : special CS, normal CS, or normal
+% character.
% \begin{macrocode}
\@ifdefinable\ted@show@toks@{%
\long\def\ted@show@toks@#1#2\@nil{%
@@ -950,32 +1125,21 @@ This is a generated file. See ted.dtx for license information.
\expandafter\ifx\the\ted@toks\ted@@special
\ted@show@special#2\@nil
\else
-% \end{macrocode}
-% It's time to think about the following: we are inside a group where all
-% active characters were redefined, but we nonetheless want to display their
-% meaning. In order to do this, the display need to actually happen after the
-% current group is finished. For this we use \cs{aftergroup} (with specialized
-% macro for displaying each kind of token).
-% \begin{macrocode}
\aftergroup\ted@type@cs
\expandafter\aftergroup\the\ted@toks
\fi
- \else \expandafter
- \ifx\the\ted@toks\ted@@active
- \aftergroup\ted@type@active
- \expandafter\aftergroup\the\ted@toks
- \else
- \aftergroup\ted@type@normal
- \expandafter\aftergroup\the\ted@toks
- \fi
+ \else
+ \aftergroup\ted@type@normal
+ \expandafter\aftergroup\the\ted@toks
\fi}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@show@special}
-% Let's begin our tour of specialized display macro with the most important
-% one: \cs{ted@show@special}. Displaying the special token goes mostly the
-% same way as decoding them, but is far easier, since we don't need to care
-% about groups: display is done with \cs{catcode}~$12$ characters.
+% Let's begin our tour of specialized display macro with the most
+% important one: \cs{ted@show@special}. Displaying the special token
+% goes mostly the same way as decoding them, but is far easier, since we
+% don't need to care about groups: display is done with
+% \cs{catcode}~$12$ characters.
% \begin{macrocode}
\@ifdefinable\ted@show@special{%
\begingroup\escapechar\m@ne \expandafter\endgroup
@@ -998,11 +1162,12 @@ This is a generated file. See ted.dtx for license information.
% \begin{macro}{\ted@type@bgroup}
% \begin{macro}{\ted@type@egroup}
% \begin{macro}{\ted@type@normal}
-% The four macros for special tokens are obvious. So is the macro for normal
-% tokens. By the way, \cs{ted@typeout} will be discussed in the next section.
+% The four macros for special tokens are obvious. So is the macro for
+% normal tokens. By the way, \cs{ted@typeout} will be discussed in the
+% next section.
% \begin{macrocode}
\newcommand\ted@type@hash[1]{%
- \ted@typeout{#1 (macro paramater character #1)}}
+ \ted@typeout{#1 (macro parameter character #1)}}
% \end{macrocode}
% \begin{macrocode}
\newcommand\ted@type@blank[1]{%
@@ -1028,10 +1193,10 @@ This is a generated file. See ted.dtx for license information.
% \begin{macro}{\ted@type@cs}
% \begin{macro}{\ted@type@active}
% For control sequences and active characters, we use more sophisticated
-% macros. Indeed, their \cs{meaning} can be quite long, and since it is not so
-% important (\pf{ted}'s work is lexical analysis, displaying the \cs{meaning}
-% is just an add-on), we cut it so that lines are shorter than $80$ colons, in
-% order to save our one-token-a-line presentation.
+% macros. Indeed, their \cs{meaning} can be quite long, and since it is
+% not so important (\pf{ted}'s work is lexical analysis, displaying the
+% \cs{meaning} is just an add-on), we cut it so that lines are shorter
+% than~$80$ colons, in order to save our one-token-a-line presentation.
% \begin{macrocode}
\newcommand\ted@type@cs[1]{%
\ted@type@long{\string#1 (control sequence=\meaning#1}}%
@@ -1043,9 +1208,10 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \end{macro}
% \begin{macro}{\ted@type@long}
-% Lines are cut and displayed by \cs{ted@type@long}. This macro uses a loop,
-% conting down how many columns remain on the current line. The input need to
-% be fully expanded first, and the output is stored in \cs{ted@toks}.
+% Lines are cut and displayed by \cs{ted@type@long}. This macro uses a
+% loop, counting down how many columns remain on the current line. The
+% input need to be fully expanded first, and the output is stored in
+% \cs{ted@toks}.
% \begin{macrocode}
\newcommand\ted@type@long[1]{%
\ted@toks{}%
@@ -1055,8 +1221,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ted@tl@loop}
-% The only difficult thing in this loop is to take care of space tokens. For
-% this we use again our \cs{futurelet} trick:
+% The only difficult thing in this loop is to take care of space tokens.
+% For this we use again our \cs{futurelet} trick:
% \begin{macrocode}
\newcommand\ted@tl@loop{%
\futurelet\@let@token
@@ -1086,8 +1252,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ted@tl@add}
% \begin{macro}{\ted@tl@space}
-% Normal characters are just grabbed and added without care, and spaces are
-% gobbled with a special macro which also add a space to the output.
+% Normal characters are just grabbed and added without care, and spaces
+% are gobbled with a special macro which also add a space to the output.
% \begin{macrocode}
\newcommand*\ted@tl@add[1]{%
\ted@toks\expandafter{\the\ted@toks #1}%
@@ -1101,9 +1267,10 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \end{macro}
% \begin{macro}{\ted@tl@finish}
-% When the end has been reached (either because a \cs{@nil} was encountered or
-% because the line is allmost full), it's time to actually display the result.
-% We add \cs{ETC.} at the end when the full \cs{meaning} isn't displayed.
+% When the end has been reached (either because a \cs{@nil} was
+% encountered or because the line is almost full), it's time to
+% actually display the result. We add \cs{ETC.} at the end when the
+% full \cs{meaning} isn't displayed.
% \begin{macrocode}
\@ifdefinable\ted@tl@finish{%
\def\ted@tl@finish#1\@nil{%
@@ -1118,8 +1285,8 @@ This is a generated file. See ted.dtx for license information.
% \subsection{User macros}
%
% \begin{macro}{\ted@typeout}
-% Since we just discussed display, let's see the related user commands. Output
-% is done with
+% Since we just discussed display, let's see the related user commands.
+% Output is done with
% \begin{macrocode}
\newcommand\ted@typeout{%
\immediate\write\ted@outfile}
@@ -1127,8 +1294,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ShowTokensOnline}
% \begin{macro}{\ShowTokensLogonly}
-% allowing the user to choose between online display, or log output. Default
-% is online.
+% allowing the user to choose between online display, or log output.
+% Default is online.
% \begin{macrocode}
\newcommand\ShowTokensOnline{%
\let\ted@outfile\@unused}
@@ -1144,8 +1311,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ShowTokens}
% \begin{macro}{\ted@ShowTokens@exp}
-% The user macro for showing tokens is a simple call to the internal macro,
-% just expanding its argument once in its stared form.
+% The user macro for showing tokens is a simple call to the internal
+% macro, just expanding its argument once in its stared form.
% \begin{macrocode}
\newcommand\ShowTokens{%
\@ifstar{\ted@ShowTokens@exp}{\ted@ShowTokens}}
@@ -1159,8 +1326,8 @@ This is a generated file. See ted.dtx for license information.
%
% \begin{macro}{\Substitute}
% \begin{macro}{\ted@Subs@star}
-% Now, the user macro for substitution. First, check how many stars there are,
-% if any, and set \cs{ted@subs@cmd} accordingly.
+% Now, the user macro for substitution. First, check how many stars
+% there are, if any, and set \cs{ted@subs@cmd} accordingly.
% \begin{macrocode}
\newcommand\Substitute{%
\@ifstar
@@ -1177,8 +1344,8 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \begin{macro}{\ted@Subs@exp@i}
% \begin{macro}{\ted@Subs@exp@iii}
-% Here are the intermediate macros that expand either the first or all three
-% arguments before calling \cs{ted@Substitute}.
+% Here are the intermediate macros that expand either the first or all
+% three arguments before calling \cs{ted@Substitute}.
% \begin{macrocode}
\newcommand\ted@Subs@exp@i{%
\expandafter\ted@Substitute\expandafter}
@@ -1197,8 +1364,9 @@ This is a generated file. See ted.dtx for license information.
% \end{macro}
% \end{macro}
% \begin{macro}{\ted@Subs}
-% Now, the last macro checks and process the optional argument. Here we set
-% \cs{ted@output}, which will be used at the end of \cs{ted@Substitute}.
+% Now, the last macro checks and process the optional argument. Here we
+% set \cs{ted@output}, which will be used at the end of
+% \cs{ted@Substitute}.
% \begin{macrocode}
\newcommand\ted@Subs[1][\ted@toks]{%
\def\ted@output{#1}%
@@ -1225,21 +1393,23 @@ This is a generated file. See ted.dtx for license information.
%</package>
%<*batchfile>
% \fi
-\typeout{**************************************************}
-\typeout{*}
-\typeout{* To finish the installation you have to move the}
-\typeout{* following file into a directory searched by TeX:}
-\typeout{*}
-\typeout{* \space\space\space\space ted.sty}
-\typeout{*}
-\typeout{* Documentation is in ted.dvi or ted.pdf}
-\typeout{*}
-\typeout{* To produce french documentation, run}
-\typeout{* \space\space \space\space (pdf)latex ted-fr.drv}
-\typeout{*}
-\typeout{* Happy TeXing!}
-\typeout{*}
-\typeout{**************************************************}
+% \begingroup\obeyspaces
+% \typeout{*****************************************************}
+% \typeout{* *}
+% \typeout{* To finish the installation you have to move the *}
+% \typeout{* following file into a directory searched by TeX: *}
+% \typeout{* *}
+% \typeout{* ted.sty *}
+% \typeout{* *}
+% \typeout{* Documentation is in ted.dvi or ted.pdf *}
+% \typeout{* *}
+% \typeout{* To produce the french documentation, run *}
+% \typeout{* (pdf)latex ted-fr.drv *}
+% \typeout{* *}
+% \typeout{* Happy TeXing! *}
+% \typeout{* *}
+% \typeout{*****************************************************}
+% \endgroup
% \iffalse
%</batchfile>
% \fi
diff --git a/Master/texmf-dist/tex/latex/ted/ted.sty b/Master/texmf-dist/tex/latex/ted/ted.sty
index f86a33ddaf0..3ef652ff82c 100644
--- a/Master/texmf-dist/tex/latex/ted/ted.sty
+++ b/Master/texmf-dist/tex/latex/ted/ted.sty
@@ -6,15 +6,16 @@
%%
%% ted.dtx (with options: `package')
%%
-%% ted package by Manuel P\'egouri\'e-Gonnard <mpg@math.jussieu.fr>
+%% ted package by Manuel P\'egouri\'e-Gonnard <mpg@elzevir.fr>
%% This is a generated file. See ted.dtx for license information.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ted}
- [2007/12/12 v1.01 \space token list editor \space (mpg)]
+ [2008/03/07 v1.06 \space a token list editor \space (mpg)]
\@ifdefinable\ted@toks{\newtoks\ted@toks}
\@ifdefinable\ted@list{\let\ted@list\toks@}
\@ifdefinable\ted@code{\let\ted@code\count@}
+\@ifdefinable\ted@count{\newcount\ted@count}
\newcommand\ted@encloop{%
\futurelet\@let@token
\ted@encloop@}
@@ -174,7 +175,7 @@
\uccode`{=#2
\or
\uccode`}=#2
- \uppercase{\ted@toks\expandafter{\expandafter{\the\ted@toks}}}
+ \uppercase{\ted@toks\expandafter{\expandafter{\the\ted@toks}}}%
\expandafter\endgroup
\expandafter\ted@add@toks\expandafter{\the\ted@toks}%
\fi}}
@@ -194,20 +195,27 @@
\expandafter##\expandafter1\the\ted@toks##2{%
\ted@add@toks{##1}%
\ifx##2\ted@@end
- \expandafter\@gobble
+ \expandafter\@firstoftwo
\else
- \expandafter\@firstofone
+ \expandafter\@secondoftwo
\fi{%
+ \expandafter\ted@remove@nil\the\ted@toks
+ }{%
+ \global\advance\ted@count\@ne
\ted@add@toks{#1}\ted@subsmac@loop##2}}%
\expandafter\ted@def@subsmac@\expandafter{\the\ted@toks}}
\newcommand\ted@def@subsmac@[1]{%
\def\ted@subsmac{%
+ \global\ted@count\z@
\ted@toks\expandafter{\expandafter}%
- \expandafter\ted@subsmac@loop\the\ted@toks#1\ted@@end}}
+ \expandafter\ted@subsmac@loop\the\ted@toks\ted@@nil#1\ted@@end}}
+\@ifdefinable\ted@remove@nil{%
+ \long\def\ted@remove@nil#1\ted@@nil{%
+ \ted@toks{#1}}}
\newcommand\ted@ShowTokens[1]{%
\begingroup \ted@sanitize
\ted@toks{#1}%
- \ted@typeout{--- Begin token decompositon of:}%
+ \ted@typeout{--- Begin token decomposition of:}%
\ted@typeout{\@spaces \the\ted@toks}%
\ted@encode{#1}%
\expandafter\ted@show@toks\the\ted@toks\ted@@end
@@ -215,12 +223,24 @@
\ted@typeout{--- End token decomposition.}}
\count@\catcode\z@ \catcode\z@ 12
\newcommand\ted@show@toks[1]{%
- \ifx#1\ted@@end \expandafter\@gobble\else\expandafter\@firstofone\fi{%
- \ted@toks{#1}%
- \begingroup
- \escapechar\if\noexpand#1^^00 \@ne \else \z@ \fi
- \expandafter\ted@show@toks@\string#1\@nil
- \ted@show@toks}}
+ \ted@toks{#1}\expandafter
+ \ifx\the\ted@toks\ted@@end \else\expandafter
+ \ifx\the\ted@toks\ted@@active
+ \aftergroup\ted@type@active
+ \expandafter\aftergroup\the\ted@toks
+ \else
+ \if\expandafter\noexpand\the\ted@toks\@sptoken
+ \aftergroup\ted@type@normal
+ \expandafter\aftergroup\the\ted@toks
+ \else
+ \begingroup
+ \escapechar\if\noexpand#1^^00 \@ne \else \z@ \fi
+ \expandafter\expandafter\expandafter\ted@show@toks@
+ \expandafter\string\the\ted@toks\@nil
+ \fi
+ \fi
+ \expandafter\ted@show@toks
+ \fi}
\catcode\z@\count@
\@ifdefinable\ted@show@toks@{%
\long\def\ted@show@toks@#1#2\@nil{%
@@ -232,14 +252,9 @@
\aftergroup\ted@type@cs
\expandafter\aftergroup\the\ted@toks
\fi
- \else \expandafter
- \ifx\the\ted@toks\ted@@active
- \aftergroup\ted@type@active
- \expandafter\aftergroup\the\ted@toks
- \else
- \aftergroup\ted@type@normal
- \expandafter\aftergroup\the\ted@toks
- \fi
+ \else
+ \aftergroup\ted@type@normal
+ \expandafter\aftergroup\the\ted@toks
\fi}}
\@ifdefinable\ted@show@special{%
\begingroup\escapechar\m@ne \expandafter\endgroup
@@ -256,7 +271,7 @@
\begingroup \uccode`1#2
\uppercase{\endgroup\aftergroup1}}}
\newcommand\ted@type@hash[1]{%
- \ted@typeout{#1 (macro paramater character #1)}}
+ \ted@typeout{#1 (macro parameter character #1)}}
\newcommand\ted@type@blank[1]{%
\ted@typeout{#1 (blank space #1)}}
\newcommand\ted@type@bgroup[1]{%