From 3fe6e8a9e68e5380f6d352a30135fe83db9f3515 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 19 Jun 2008 00:13:44 +0000 Subject: environ 0.2 (18jun08) git-svn-id: svn://tug.org/texlive/trunk@8861 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/environ/environ.cfg | 30 ----------- Master/texmf-dist/tex/latex/environ/environ.sty | 68 ++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 36 deletions(-) delete mode 100644 Master/texmf-dist/tex/latex/environ/environ.cfg (limited to 'Master/texmf-dist/tex/latex/environ') diff --git a/Master/texmf-dist/tex/latex/environ/environ.cfg b/Master/texmf-dist/tex/latex/environ/environ.cfg deleted file mode 100644 index 51638f6a061..00000000000 --- a/Master/texmf-dist/tex/latex/environ/environ.cfg +++ /dev/null @@ -1,30 +0,0 @@ -%% -%% This is file `environ.cfg', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% environ.dtx (with options: `defaults') -%% -%% __________________________________ -%% Copyright (C) 2007 Will Robertson -%% -%% License information appended. -%% -%% -%% Copyright (C) 2007 by Will Robertson -%% -%% Distributable under the LaTeX Project Public License, -%% version 1.3c or higher (your choice). The latest version of -%% this license is at: http://www.latex-project.org/lppl.txt -%% -%% This work is "maintained" (as per LPPL maintenance status) -%% by Will Robertson. -%% -%% This work consists of the file environ.dtx -%% and the derived files environ.pdf, -%% environ.sty, and -%% environ.ins. -%% -%% -%% End of file `environ.cfg'. diff --git a/Master/texmf-dist/tex/latex/environ/environ.sty b/Master/texmf-dist/tex/latex/environ/environ.sty index 99469eb1f6b..6a576bf1a66 100644 --- a/Master/texmf-dist/tex/latex/environ/environ.sty +++ b/Master/texmf-dist/tex/latex/environ/environ.sty @@ -11,7 +11,19 @@ %% %% License information appended. %% -\ProvidesPackage{environ}[2007/09/23 v0.1 A new environment syntax] +\ProvidesPackage{environ}[2008/06/18 v0.2 A new way to define environments] +\def\environbodyname#1{\def\env@BODY{#1}} +\environbodyname\BODY +\def\environfinalcode#1{% + \def\env@finalcode{#1}} +\environfinalcode{\ignorespacesafterend} +\def\longdef@c#1{% + \expandafter\long\expandafter\def\csname#1\endcsname} +\catcode`\Q=3 +\long\def\trim@spaces#1{\romannumeral-`\q\trim@trim@\noexpand#1Q Q} +\long\def\trim@trim@#1 Q{\trim@trim@@#1Q} +\long\def\trim@trim@@#1Q#2{#1} +\catcode`\Q=11 \unless\ifdefined\collect@body \newtoks\@emptytoks \newtoks\@envbody @@ -21,7 +33,8 @@ \@envbody\@emptytoks \def\begin@stack{b}% \begingroup \expandafter\let\csname\@currenvir\endcsname\collect@@body - \edef\process@envbody{\expandafter\noexpand\csname\@currenvir\endcsname}% + \edef\process@envbody{% + \expandafter\noexpand\csname\@currenvir\endcsname}% \process@envbody } \def\push@begins#1\begin#2{% @@ -48,7 +61,8 @@ \@envbody\@emptytoks \def\begin@stack{b}% \begingroup \expandafter\let\csname\@currenvir\endcsname\Collect@@Body - \edef\process@envbody{\expandafter\noexpand\csname\@currenvir\endcsname}% + \edef\process@envbody{% + \expandafter\noexpand\csname\@currenvir\endcsname}% \process@envbody } \long\def\Push@Begins#1\begin#2{% @@ -68,6 +82,48 @@ \Addto@Envbody{#1\end{#2}}% \fi \process@envbody} +\def\NewEnviron{% + \let\env@newcommand\newcommand + \let\env@newenvironment\newenvironment + \env@NewEnviron} +\def\RenewEnviron{% + \let\env@newcommand\renewcommand + \let\env@newenvironment\renewenvironment + \env@NewEnviron} +\def\env@NewEnviron#1{% + \@ifnextchar[ + {\env@new@i{#1}} + {\env@new@iii{#1}{}}} +\def\env@new@i#1[#2]{% + \@ifnextchar[ + {\env@new@ii{#1}[#2]} + {\env@new@iii{#1}{[#2]}}} +\def\env@new@ii#1[#2][#3]{% + \env@new@iii{#1}{[#2][#3]}} +\long\def\env@new@iii#1#2#3{% + \@temptokena={\env@new{#1}{#2}{#3}}% + \@ifnextchar[{% + \the\@temptokena + }{% + \expandafter\the\expandafter + \@temptokena\expandafter[\env@finalcode]% + }} +\long\def\env@new#1#2#3[#4]{% + \env@newenvironment{#1}{% + \expandafter\Collect@Body\csname env@#1@parse\endcsname + }{#4} + \longdef@c{env@#1@parse}##1{% + \csname env@#1@save@env\endcsname##1\env@nil + \csname env@#1@process\endcsname##1\env@nil}% + \expandafter\env@newcommand + \csname env@#1@save@env\endcsname#2{\env@save}% + \expandafter\env@newcommand + \csname env@#1@process\endcsname#2{#3\env@ignore}} +\long\def\env@save#1\env@nil{% + \expandafter\edef\env@BODY{% + \unexpanded\expandafter + \expandafter\expandafter{\trim@spaces{#1}}}} +\long\def\env@ignore#1\env@nil{} \newcommand\NewEnvironment{% \let\env@newenvironment\newenvironment \let\env@newcommand\newcommand @@ -80,10 +136,10 @@ \expandafter\let\csname env@args@#1\endcsname\ignorespaces \env@newenvironment{#1}{% \expandafter\Collect@Body\csname env@@#1\endcsname}{\ignorespacesafterend}% - \expandafter\env@newcommand\csname env@@#1\endcsname[1]{% + \longdef@c{env@@#1}##1{% \csname env@@@#1\endcsname{% - \csname env@args@\@currenvir\endcsname##1\unskip}}% - \expandafter\env@newcommand\csname env@@@#1\endcsname[1]{#2}} + \csname env@args@#1\endcsname##1\unskip}}% + \longdef@c{env@@@#1}##1{#2}} \newcommand\EnvironArgs[1]{% \@ifnextchar[ {\Env@Args{#1}} -- cgit v1.2.3