summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/extract
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-12 23:55:29 +0000
committerKarl Berry <karl@freefriends.org>2006-01-12 23:55:29 +0000
commitadd048e43ff3b102377c17b6f18d71a5a5cde9a6 (patch)
tree4f26bd2ca7d7f51486c18f2c18f209847f2e583d /Master/texmf-dist/tex/latex/extract
parent31c444b613730d932dc09693185d48fd9f7abb2b (diff)
extract
git-svn-id: svn://tug.org/texlive/trunk@900 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/extract')
-rw-r--r--Master/texmf-dist/tex/latex/extract/extract.sty466
1 files changed, 466 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/extract/extract.sty b/Master/texmf-dist/tex/latex/extract/extract.sty
new file mode 100644
index 00000000000..994ba5c6f1c
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/extract/extract.sty
@@ -0,0 +1,466 @@
+%%
+%% This is file `extract.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% extract.dtx (with options: `extract')
+%%
+%% ---------------------------------------
+%% Copyright (C) 2004-2005 Hendri Adriaens
+%% ---------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% This Current Maintainer of this work is Hendri Adriaens.
+%%
+%% This work consists of the file extract.dtx and the derived files
+%% extract.sty, xtrex1.tex, xtrex2.tex, xtrex3.tex, xtrex4.tex,
+%% xtrex5.tex, xtrex6.tex and xtrex7.tex.
+%%
+%% The following files constitute the extract package and must be
+%% distributed as a whole: readme, extract.dtx, extract.pdf and
+%% extract.sty.
+%%
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesPackage{extract}[2005/02/14 v1.6 extract content from document (HA)]
+\RequirePackage{verbatim}
+\RequirePackage{xkeyval}
+\newwrite\XTR@out
+\newwrite\XTR@tmp
+\newif\ifXTR@st
+\newif\ifXTR@skip
+\newif\ifXTR@active
+\newif\ifXTR@extract
+\newif\ifXTR@header\XTR@headertrue
+\newif\ifXTR@handles\XTR@handlestrue
+\def\XTR@err#1{\PackageError{extract}{#1}\@ehc}
+\def\XTR@namelet#1#2{\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}
+\DeclareOptionX[XTR]{active}{\XTR@activetrue}
+\DeclareOptionX[XTR]{generate}{\lowercase{\def\XTR@file{#1}}}
+\DeclareOptionX[XTR]{no-header}[false]{\XKV@setbool{XTR@header}{#1}}
+\DeclareOptionX[XTR]{document-handles}[true]{\XKV@setbool{XTR@handles}{#1}}
+\DeclareOptionX[XTR]{extract-env}{%
+ \def\XTR@envs{#1}%
+ \@for\XTR@tempa:=\XTR@envs\do\XTR@tempb
+}
+\DeclareOptionX[XTR]{extract-cmd}{%
+ \def\XTR@cmdsargs{#1}%
+ \@for\XTR@tempa:=\XTR@cmdsargs\do\XTR@tempb
+}
+\DeclareOptionX[XTR]{extract-cmdline}{%
+ \def\XTR@cmdsline{#1}%
+ \@for\XTR@tempa:=\XTR@cmdsline\do\XTR@tempb
+}
+\def\XTR@tempb{%
+ \DeclareOptionX[XTR]{\XTR@tempa-nrs}{%
+ \expandafter\XKV@sp@deflist\csname XTR@\XKV@tkey\endcsname{##1}%
+ \XTR@namelet{XTR@\XKV@tkey @cnt}{z@}%
+ }%
+ \DeclareOptionX[XTR]{\XTR@tempa-labels}{%
+ \expandafter\XKV@sp@deflist\csname XTR@\XKV@tkey\endcsname{##1}%
+ }%
+}
+\def\XTR@tempa{line}\XTR@tempb
+\def\XTR@tempa{extract}\XTR@tempb
+\def\XTR@tempa{extractskip}\XTR@tempb
+\DeclareOptionX*{\XTR@err{Unknown option `\CurrentOption'}}
+\ProcessOptionsX[XTR]
+\def\XTR@opentmp{\immediate\openout\XTR@tmp\jobname.xtr\relax}
+\def\XTR@writetmp{\immediate\write\XTR@tmp}
+\def\XTR@closetmp{\immediate\closeout\XTR@tmp}
+\def\XTR@writeout{\immediate\write\XTR@out}
+\ifXTR@active
+ \XKV@ifundefined{XTR@file}{
+ \XTR@activefalse
+ \XTR@err{no file to generate; extract deactivated}
+ }{}
+ \XTR@opentmp
+ \XTR@writetmp{\string\lowercase{\string\def\string\XTR@tempa{\jobname}}}
+ \XTR@closetmp
+ \input{\jobname.xtr}
+ \ifx\XTR@tempa\XTR@file
+ \XTR@activefalse
+ \XTR@err{attempt to overwrite source file; extract deactivated}
+ \fi
+\fi
+\newcount\@envdepth\@envdepth\z@
+\def\begin#1{%
+ \@ifundefined{#1}%
+ {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}%
+ {\def\reserved@a{\def\@currenvir{#1}%
+ \edef\@currenvline{\on@line}%
+ \csname #1\endcsname}}%
+ \@ignorefalse
+ \begingroup\@endpefalse
+ \global\advance\@envdepth\@ne
+ \global\@namedef{@afterendenvhook@\romannumeral\@envdepth}{}%
+ \reserved@a}
+\def\end#1{%
+ \csname end#1\endcsname\@checkend{#1}%
+ \expandafter\endgroup\if@endpe\@doendpe\fi
+ \expandafter\let\expandafter\reserved@a
+ \csname @afterendenvhook@\romannumeral\@envdepth\endcsname
+ \global\advance\@envdepth\m@ne
+ \reserved@a\relax
+ \if@ignore\@ignorefalse\ignorespaces\fi}
+\def\AfterEndEnv{%
+ \expandafter\g@addto@macro
+ \csname @afterendenvhook@\romannumeral\@envdepth\endcsname
+}
+\def\XTR@checkxtr#1#2{%
+ \@nameuse{XTR@#1false}%
+ \XTR@namelet{XTR@maketrue}{XTR@#1true}%
+ \XKV@ifundefined{XTR@#2-nrs}{%
+ \XKV@ifundefined{XTR@#2-labels}\XTR@maketrue{}%
+ }{%
+ \begingroup
+ \expandafter\count@\csname XTR@#2-nrs@cnt\endcsname
+ \advance\count@\@ne
+ \edef\XTR@resa{\expandafter\noexpand\expandafter\gdef\expandafter
+ \noexpand\csname XTR@#2-nrs@cnt\endcsname{\the\count@}}%
+ \expandafter\endgroup\XTR@resa
+ }%
+ \@nameuse{ifXTR@#1}\else
+ \XKV@ifundefined{XTR@#2-labels}{}{%
+ \ifx\XTR@currentlabel\relax\else
+ \@expandtwoargs\in@{,\XTR@currentlabel,}{,\csname XTR@#2-labels\endcsname,}%
+ \ifin@\XTR@maketrue\fi
+ \fi
+ }%
+ \fi
+ \@nameuse{ifXTR@#1}\else
+ \XKV@ifundefined{XTR@#2-nrs}{}{%
+ \expandafter\XTR@ch@ckxtr\csname XTR@#2-nrs\expandafter
+ \endcsname\csname XTR@#2-nrs@cnt\endcsname
+ }%
+ \fi
+ \global\let\XTR@currentlabel\relax
+}
+\def\XTR@ch@ckxtr#1#2{%
+ \@for\XTR@resa:=#1\do{\expandafter\XTR@ch@ck@tr\XTR@resa--\@nil#2}%
+}
+\def\XTR@ch@ck@tr#1-#2-#3\@nil#4{%
+ \ifx\@empty#1\@empty
+ \ifnum#4>#2 \else\XTR@maketrue\fi
+ \else
+ \ifx\@empty#2\@empty
+ \ifx\@empty#3\@empty
+ \ifnum#4=#1 \XTR@maketrue\fi
+ \else
+ \ifnum#4<#1 \else\XTR@maketrue\fi
+ \fi
+ \else
+ \ifnum#4<#1 \else\ifnum#4>#2 \else\XTR@maketrue\fi\fi
+ \fi
+ \fi
+}
+\def\extractionlabel{\KV@@sp@def\XTR@currentlabel}
+\let\XTR@currentlabel\relax
+\def\extract{\XTR@stfalse\XTR@extract}
+\@namedef{extract*}{\XTR@sttrue\XTR@extract}
+\def\XTR@extract{%
+ \@bsphack
+ \let\do\@makeother\dospecials\catcode`\^^M\active
+ \@testopt\XTR@@xtract\@nil
+}
+\def\XTR@@xtract[#1]{%
+ \ifXTR@active
+ \def\XTR@tempa{#1}%
+ \ifx\XTR@tempa\@nnil\else
+ \KV@@sp@def\XTR@currentlabel{#1}%
+ \fi
+ \XTR@checkxtr{extract}{extract}%
+ \else
+ \XTR@extractfalse
+ \fi
+ \ifXTR@st\XTR@opentmp\fi
+ \let\verbatim@processline\XTR@processline@begin
+ \verbatim@start
+}
+\begingroup
+ \lccode`\!=`\\ \lccode`\(=`\{ \lccode`\)=`\}
+\lowercase{\endgroup
+\def\XTR@processline@begin{%
+ \@temptokena{}%
+ \expandafter\verbatim@line\expandafter{\expandafter}\expandafter
+ \XTR@testbegin\the\verbatim@line!begin(extractskip)\@nil
+}
+\def\XTR@testbegin#1!begin(extractskip)#2\@nil{%
+ \@temptokena\expandafter{\the\@temptokena#1}%
+ \verbatim@line\expandafter{\the\verbatim@line#1}%
+ \def\XTR@tempa{#2}%
+ \ifx\XTR@tempa\@empty\XTR@processline@write\else\XKV@afterfi
+ \XTR@skiplabel#2[]\@nil
+ \XTR@checkxtr{skip}{extractskip}%
+ \let\verbatim@processline\XTR@processline@end
+ \ifx\XTR@tempa\@nnil\XKV@afterelsefi
+ \XTR@t@stbegin#2\@nil
+ \else\XKV@afterfi
+ \expandafter\XTR@t@stbegin\XTR@tempa\@nil
+ \fi
+ \fi
+}
+\def\XTR@skiplabel#1[#2]#3\@nil{%
+ \def\XTR@tempa{#1}%
+ \def\XTR@tempb{#2}%
+ \ifx\XTR@tempa\@empty
+ \ifx\XTR@tempb\@empty
+ \let\XTR@tempa\@nnil
+ \else
+ \KV@@sp@def\XTR@currentlabel{#2}%
+ \XTR@sk@plabel#3\@nil
+ \fi
+ \else
+ \let\XTR@tempa\@nnil
+ \fi
+}
+\def\XTR@sk@plabel#1[]\@nil{\def\XTR@tempa{#1}}
+\def\XTR@t@stbegin#1!begin(extractskip)\@nil{\XTR@testend#1!end(extractskip)\@nil}
+\def\XTR@processline@end{%
+ \@temptokena{}%
+ \expandafter\verbatim@line\expandafter{\expandafter}\expandafter
+ \XTR@testend\the\verbatim@line!end(extractskip)\@nil
+}
+\def\XTR@testend#1!end(extractskip)#2\@nil{%
+ \@temptokena\expandafter{\the\@temptokena#1}%
+ \ifXTR@skip\else\verbatim@line\expandafter{\the\verbatim@line#1}\fi
+ \def\XTR@tempa{#2}%
+ \ifx\XTR@tempa\@empty\XTR@processline@write\else\XKV@afterfi
+ \let\verbatim@processline\XTR@processline@begin
+ \XTR@t@stend#2\@nil
+ \fi
+}
+\def\XTR@t@stend#1!end(extractskip)\@nil{\XTR@testbegin#1!begin(extractskip)\@nil}
+\def\XTR@processline@write{%
+ \ifXTR@st\ifcat$\the\@temptokena$\else
+ \XTR@writetmp{\the\@temptokena}%
+ \fi\fi
+ \ifXTR@extract\ifcat$\the\verbatim@line$\else
+ \XTR@writeout{\the\verbatim@line}%
+ \fi\fi
+}}
+\def\endextract{\XTR@stfalse\XTR@endextract}
+\@namedef{endextract*}{\XTR@sttrue\XTR@endextract}
+\def\XTR@endextract{%
+ \@esphack
+ \ifXTR@st
+ \XTR@closetmp
+ \AfterEndEnv{\input{\jobname.xtr}}%
+ \fi
+}
+\@namedef{extractskip}{\XTR@activefalse\@nameuse{extract*}}
+\XTR@namelet{endextractskip}{endextract*}
+\def\extractline{%
+ \XKV@ifstar{\XTR@sttrue\XTR@extractline}{\XTR@stfalse\XTR@extractline}%
+}
+\def\XTR@extractline{%
+ \begingroup
+ \let\do\@makeother\dospecials\catcode`\^^M\active
+ \@testopt\XTR@@xtractline\@nil
+}
+\begingroup
+ \catcode`\~=\active\lccode`\~=`\^^M
+\lowercase{\endgroup
+ \def\XTR@@xtractline[#1]#2~{%
+ \ifXTR@active
+ \def\XTR@tempa{#1}%
+ \ifx\XTR@tempa\@nnil\else
+ \KV@@sp@def\XTR@currentlabel{#1}%
+ \fi
+ \XTR@checkxtr{extract}{line}%
+ \else
+ \XTR@extractfalse
+ \fi
+ \ifXTR@extract\XTR@writeout{#2}\fi
+ \ifXTR@st\XTR@opentmp\XTR@writetmp{#2}\XTR@closetmp\fi
+ \endgroup
+ \ifXTR@st
+ \input{\jobname.xtr}%
+ \fi
+ }%
+}
+\ifXTR@active
+\immediate\openout\XTR@out\XTR@file\relax
+\ifXTR@header
+ \begingroup
+ \catcode`\%=12
+ \gdef\XTR@tempa{%%\space}
+ \@tempcnta\time
+ \divide\@tempcnta 60
+ \edef\XTR@tempb{\the\year/\the\month/\the\day, \the\@tempcnta:}
+ \multiply\@tempcnta 60
+ \@tempcntb\time
+ \advance\@tempcntb-\@tempcnta
+ \ifnum\@tempcntb<10
+ \xdef\XTR@tempb{\XTR@tempb0\the\@tempcntb}
+ \else
+ \xdef\XTR@tempb{\XTR@tempb\the\@tempcntb}
+ \fi
+ \endgroup
+ \XTR@writeout{\XTR@tempa}
+ \filename@parse\XTR@file
+ \ifx\filename@ext\relax\def\filename@ext{tex}\fi
+ \XTR@writeout{\XTR@tempa This is file, `\filename@base.\filename@ext',}
+ \XTR@writeout{\XTR@tempa generated with the extract package.^^J\XTR@tempa}
+ \XTR@writeout{\XTR@tempa Generated on : \space\XTR@tempb}
+ \filename@parse\jobname
+ \ifx\filename@ext\relax\def\filename@ext{tex}\fi
+ \XTR@writeout{\XTR@tempa From source \space: \space\filename@base.\filename@ext}
+ \XTR@writeout{\XTR@tempa Using options: \space\csname opt@extract.sty\endcsname}
+ \XTR@writeout{\XTR@tempa}
+\fi
+\AtBeginDocument{%
+ \ifXTR@handles
+ \XTR@writeout{}%
+ \XTR@writeout{\string\begin{document}}%
+ \fi
+ \XKV@ifundefined{XTR@envs}{}{%
+ \@for\XTR@tempa:=\XTR@envs\do{%
+ \XKV@ifundefined\XTR@tempa{%
+ \XTR@err{environment `\XTR@tempa' not defined; extraction canceled}%
+ }{%
+ \XTR@namelet{XTR\XTR@tempa}{\XTR@tempa}%
+ \@namedef{\XTR@tempa\expandafter}\expandafter{\expandafter
+ \def\expandafter\XTR@tempa\expandafter{\XTR@tempa}%
+ \XTR@checkxtr{extract}\XTR@tempa
+ \ifXTR@extract
+ \XTR@writeout{}\XTR@opentmp
+ \@bsphack
+ \let\do\@makeother\dospecials\catcode`\^^M\active
+ \def\verbatim@processline{%
+ \let\verbatim@processline\XTR@processline@begin
+ \XTR@writeout{\string\begin{\XTR@tempa}\the\verbatim@line}%
+ \XTR@writetmp{\string\begin{XTR\XTR@tempa}\the\verbatim@line}%
+ }%
+ \XTR@sttrue\let\XTR@tempb\verbatim@
+ \else
+ \edef\XTR@tempb{\noexpand\begin{XTR\XTR@tempa}}%
+ \fi
+ \XTR@tempb
+ }%
+ \XTR@namelet{endXTR\XTR@tempa}{end\XTR@tempa}%
+ \@namedef{end\XTR@tempa\expandafter}\expandafter{\expandafter
+ \def\expandafter\XTR@tempa\expandafter{\XTR@tempa}%
+ \ifXTR@extract
+ \@esphack
+ \XTR@writeout{\string\end{\XTR@tempa}}%
+ \XTR@writetmp{\string\end{XTR\XTR@tempa}}%
+ \XTR@closetmp
+ \AfterEndEnv{\input{\jobname.xtr}}%
+ \else
+ \edef\XTR@tempa{\noexpand\end{XTR\XTR@tempa}}%
+ \expandafter\XTR@tempa
+ \fi
+ }%
+ }%
+ }%
+ }%
+ \XKV@ifundefined{XTR@cmdsargs}{}{%
+ \let\XTR@sect\@sect
+ \let\XTR@chapter\@chapter
+ \def\XTR@tempb{chapter}%
+ \@for\XTR@tempa:=\XTR@cmdsargs\do{%
+ \XKV@ifundefined\XTR@tempa{%
+ \XTR@err{command `\@backslashchar\XTR@tempa' not defined; extraction canceled}%
+ }{%
+ \@expandtwoargs\in@{,\XTR@tempa,}{,chapter,section,subsection,subsubsection,}%
+ \ifin@
+ \ifx\XTR@tempa\XTR@tempb
+ \def\@chapter[#1]#2{%
+ \XTR@checkxtr{extract}{chapter}%
+ \ifXTR@extract
+ \XTR@writeout{}%
+ \def\XTR@tempa{#1}%
+ \def\XTR@tempb{#2}%
+ \ifx\XTR@tempa\XTR@tempb
+ \@temptokena{{#2}}%
+ \else
+ \@temptokena{[#1]{#2}}%
+ \fi
+ \XTR@writeout{\string\chapter\the\@temptokena}%
+ \fi
+ \XTR@chapter[#1]{#2}%
+ }%
+ \else
+ \def\@sect#1#2#3#4#5#6[#7]#8{%
+ \@expandtwoargs\in@{,#1,}{,\XTR@cmdsargs,}%
+ \ifin@
+ \XTR@checkxtr{extract}{#1}%
+ \ifXTR@extract
+ \XTR@writeout{}%
+ \def\XTR@tempa{#7}%
+ \def\XTR@tempb{#8}%
+ \ifx\XTR@tempa\XTR@tempb
+ \@temptokena{{#8}}%
+ \else
+ \@temptokena{[#7]{#8}}%
+ \fi
+ \XTR@writeout{\expandafter
+ \string\csname#1\endcsname\the\@temptokena}%
+ \fi
+ \fi
+ \XTR@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}%
+ }%
+ \fi
+ \else
+ \XTR@err{unsupported command `\XTR@tempa'; try the `extract-cmdline option}%
+ \fi
+ }%
+ }%
+ }%
+ \XKV@ifundefined{XTR@cmdsline}{}{%
+ \@for\XTR@tempa:=\XTR@cmdsline\do{%
+ \XKV@ifundefined\XTR@tempa{%
+ \XTR@err{command `\@backslashchar\XTR@tempa' not defined; extraction canceled}%
+ }{%
+ \@expandtwoargs\in@{,\XTR@tempa,}{,chapter,section,subsection,subsubsection,}%
+ \ifin@
+ \XTR@err{use the `extract-cmd' option for command `\XTR@tempa'}%
+ \else
+ \XTR@namelet{XTR\XTR@tempa}{\XTR@tempa}%
+ \@namedef{\XTR@tempa\expandafter}\expandafter{\expandafter
+ \def\expandafter\XTR@tempa\expandafter{\XTR@tempa}%
+ \XTR@checkxtr{extract}\XTR@tempa
+ \begingroup
+ \let\do\@makeother\dospecials\catcode`\^^M\active
+ \XTR@extractcmdline
+ }%
+ \fi
+ }%
+ }%
+ \begingroup
+ \catcode`\~=\active\lccode`\~=`\^^M
+ \lowercase{\endgroup
+ \def\XTR@extractcmdline#1~{\verbatim@line{#1}\XTR@@xtractcmdline}%
+ }%
+ \def\XTR@@xtractcmdline{%
+ \XTR@writeout{}%
+ \XTR@writeout{\expandafter\string\csname\XTR@tempa\endcsname\the\verbatim@line}%
+ \XTR@opentmp
+ \XTR@writetmp{\expandafter\string\csname XTR\XTR@tempa\endcsname\the\verbatim@line}%
+ \XTR@closetmp
+ \endgroup
+ \input{\jobname.xtr}%
+ }%
+ }%
+}
+\AtEndDocument{%
+ \ifXTR@handles
+ \XTR@writeout{}%
+ \XTR@writeout{\string\end{document}}%
+ \fi
+ \immediate\closeout\XTR@out
+}
+\fi
+\endinput
+%%
+%% End of file `extract.sty'.