diff options
author | Karl Berry <karl@freefriends.org> | 2024-08-29 20:39:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-08-29 20:39:45 +0000 |
commit | 5356980faaec739ffb82f2f950a10257aef9a77d (patch) | |
tree | 3fbf6e9e8097f492ab51a5945c3cb0eef0dc87e6 /Master/texmf-dist/tex | |
parent | 6e0931c360d843dca63b865645eee56357719006 (diff) |
enverb (29aug24)
git-svn-id: svn://tug.org/texlive/trunk@72137 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/enverb/enverb.sty | 380 |
1 files changed, 380 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/enverb/enverb.sty b/Master/texmf-dist/tex/latex/enverb/enverb.sty new file mode 100644 index 00000000000..bb15d3fec61 --- /dev/null +++ b/Master/texmf-dist/tex/latex/enverb/enverb.sty @@ -0,0 +1,380 @@ +%% +%% This is file `enverb.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% enverb.dtx (with options: `pkg') +%% +%% -------------------------------------------------------------- +%% enverb -- read an environment verbatim +%% E-mail: jspratte@yahoo.de +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% -------------------------------------------------------------- +%% +%% Copyright (C) 2023-2024 Jonathan P. Spratte +%% +%% This work may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this license or +%% (at your option) any later version. The latest version of this license is in +%% the file: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Jonathan P. Spratte. +%% +%% This work consists of the files enverb.dtx +%% enverb-doc.tex +%% and the derived files enverb-doc.pdf +%% enverb.sty +%% +\newcommand*\enverb@date{2024-08-28} +\newcommand*\enverb@version{1.0} +\ProvidesPackage{enverb} + [\enverb@date\space v\enverb@version\space read an environment verbatim] +\providecommand\@thirdofthree[3]{#3} +\providecommand\@firstofnine[9]{#1} +\ExplSyntaxOn +\cs_new_eq:NN \enverb@count \tl_count:n +\cs_new_eq:NN \enverb@ifxTF \token_if_eq_meaning:NNTF +\cs_new_eq:NN \enverb@chargen \char_generate:nn +\cs_set:Npx \enverb@othercr { \char_generate:nn {13} {12} } +\ExplSyntaxOff +\RequirePackage{expkv-def} +\ekvdefinekeys{enverb} + { + protect code ignore = \let\enverb@ifautoignore\@secondoftwo + ,also eint ignore = \enverb@ignore + ,boolTF auto-ignore = \enverb@ifautoignore + ,initial auto-ignore + ,eint more-ignore = \enverb@moreignore + ,initial more-ignore = 2 + ,long store bol = \enverb@bol@content + ,long code bol+ = \enverb@add\enverb@bol@content{#1} + ,long code +bol = \enverb@pre\enverb@bol@content{#1} + ,long store eol = \enverb@eol@content + ,einitial eol = \enverb@othercr + ,long code eol+ = \enverb@add\enverb@eol@content{#1} + ,long code +eol = \enverb@pre\enverb@eol@content{#1} + ,protect code key-handler = \protected\long\def\enverb@keyhandler##1{#1} + ,protect code key-set = \protected\long\ekvsetdef\enverb@keyhandler{#1} + ,unknown code = \enverb@add\enverb@unknown@kv{, {#3} = {#2} } + ,unknown noval = \enverb@add\enverb@unknown@kv{, {#2} } + ,boolTF oarg-not-enverb = \enverb@ifoargtokeyhandler + } +\protected\long\ekvsetdef\enverbsetup{enverb} +\let\enverb@unknown@kv\@empty +\long\def\enverb@stop#1\enverb@stop{} +\protected\def\enverb@error{\PackageError{enverb}} +\protected\def\enverb@misused + {% + \enverb@error + {Misused \string\enverb. Input already tokenised}% + {% + It seems you used the \string\enverb\space based environment + {\@currenvir} inside another\MessageBreak + macro's or a primitive's argument; that doesn't work.% + }% + } +\protected\long\def\enverb@keyhandler#1% + {% + \if\relax\detokenize{#1}\relax + \expandafter\@gobbletwo + \fi + \@firstofone + {% + \enverb@error + {% + Unknown keys encountered: + \expanded + {% + \ekvparse + {\MessageBreak\@spaces\unexpanded}% + {\MessageBreak\@spaces\enverb@keyhandler@}% + {#1}% + }% + \@gobble + }% + {% + Perhaps you misspelled some key names? Or you forgot to set up + custom key\MessageBreak + parsing.% + }% + }% + } +\long\def\enverb@keyhandler@#1{\unexpanded{#1} = \unexpanded} +\begingroup +\lccode`\~=`\^^M +\catcode`\:=13 +\lccode`\:=`\ % <- space +\catcode`\;=13 +\lccode`\;=`\^^I % <- tab +\lowercase{\endgroup +\def\enverb@body@space{} +\def\enverb@body@tab{} +\def\enverb@body@newline{\enverb@collect} +\def\enverb@collect#1~% + {\enverb@ifnotend{#1}{\enverb@bol\unexpanded{#1}\enverb@eol\enverb@collect}} +\protected\def\enverb@body@setup + {% + \let\enverbBody\@empty + \let\do\@makeother\dospecials + \endlinechar=`\^^M + \catcode`\^^M=13 \let~\enverb@body@newline + \catcode`\ =13 \let:\enverb@body@space + \catcode`\^^I=13 \let;\enverb@body@tab + \let\enverb@bol\relax + \let\enverb@eol\relax + } +\long\def\enverb@ifxanyTF#1#2% + {\enverb@ifxanyTF@#1#2\enverb@ifxanyTF@} +\long\def\enverb@ifxanyTF@#1#2% + {% + \enverb@ifxanyTF@ifdone#2\enverb@ifxanyTF@F\enverb@ifxanyTF@ + \enverb@ifxTF#1#2\enverb@ifxanyTF@T{\enverb@ifxanyTF@#1}% + } +\long\def\enverb@ifxanyTF@ifdone#1\enverb@ifxanyTF@{} +\long\def\enverb@ifxanyTF@F + \enverb@ifxanyTF@\enverb@ifxTF#1\enverb@ifxanyTF@T#2#3#4% + {#4} +\long\def\enverb@ifxanyTF@T#1\enverb@ifxanyTF@#2#3{#2} +\def\enverb@search@oarg@ifx#1#2% + {% + \enverb@ifxTF#1\@let@token + {% + \ifenverb@firsteol#2\else\enverb@body@add{#1}\fi + \enverb@search@oarg@b + }% + } +\protected\def\enverb@search@oarg@a + {% + \enverb@search@oarg@ifx:{}% + {% + \enverb@search@oarg@ifx;{}% + {% + \enverb@search@oarg@ifx~\enverb@firsteolfalse + {% + \enverb@ifxTF{[}\@let@token + {\enverb@oarg}% + {% + \enverb@ifxanyTF\@let@token + {% + \@sptoken\par\bgroup\egroup$&##^_% $ + } + {% + \enverb@misused + \endgroup + }% + {% + \ifenverb@firsteol + \expandafter\enverb@body@after@begin + \else + \expandafter\enverb@body + \fi + }% + }% + }% + }% + }% + } +\protected\def\enverb@body + {\edef\enverbBody{\iffalse}\fi\expandafter\enverb@collect\enverbBody} +\def\enverb@body@after@oarg#1~% + {\enverb@ensure@blank{#1}{closing bracket}\enverb@body} +\def\enverb@body@after@begin#1~% + {\enverb@ensure@blank{#1}{\string\begin}\enverb@body} +} +\newcommand\enverb@ensure@blank[2] + {% + \expandafter\enverb@ifempty\expanded{{#1}}{}% + {% + \expanded + {% + \noexpand\enverb@error + {% + Line after #2 not empty.\noexpand\MessageBreak + Contains: \detokenize\expandafter{\romannumeral`\^^@#1}% + }% + {% + \noexpand\enverb will try to ignore this. You should clean up + your input.% + }% + }% + }% + } +\newcommand\enverb@ifempty[1] + {% + \enverb@ifempty@\enverb@ifempty@A#1\enverb@ifempty@B.\enverb@ifempty@true + \enverb@ifempty@A\enverb@ifempty@B + } +\def\enverb@ifempty@#1\enverb@ifempty@A\enverb@ifempty@B#2#3{#3} +\def\enverb@ifempty@true\enverb@ifempty@A\enverb@ifempty@B#1#2{#1} +\protected\long\def\enverb@add#1#2{\edef#1{\unexpanded\expandafter{#1#2}}} +\protected\long\def\enverb@pre#1#2% + {\edef#1{\unexpanded{#2}\unexpanded\expandafter{#1}}} +\protected\def\enverb@body@add{\enverb@add\enverbBody} +\NewDocumentCommand \enverb { s +m } + {% + \expandafter\enverb@ifnotend@setup@perhaps\expanded + {{\string{\@currenvir\string}}}% + \let\enverb@collected@oarg\@empty + \edef\enverb@collected@marg{\unexpanded{#2}}% + \begingroup + \enverb@body@setup + \IfBooleanTF{#1}% + {\enverb@body@after@begin}% + {% + \enverb@firsteoltrue + \enverb@search@oarg + }% + } +\newif\ifenverb@firsteol +\protected\def\enverb@search@oarg{\futurelet\@let@token\enverb@search@oarg@a} +\protected\def\enverb@search@oarg@b{\expandafter\enverb@search@oarg\@gobble} +\protected\def\enverb@oarg{\endgroup\enverb@oarg@} +\NewDocumentCommand\enverb@oarg@{+O{}} + {% + \enverb@add\enverb@collected@oarg{#1}% + \begingroup + \enverb@body@setup + \enverb@body@after@oarg + } +\newcommand\enverb@ifnotend[1]% + {% + \def\enverb@ifnotend##1% + {% + \enverb@ifnotend@ + ##1\enverb@mark\enverb@ifnotend@maybe + #1\enverb@mark\@thirdofthree + \enverb@stop + }% + \def\enverb@ifnotend@##1#1##2\enverb@mark##3##4\enverb@stop{##3{##1}{##2}}% + } +\expandafter\enverb@ifnotend\expanded{{\expandafter\@gobble\string\\end}} +\newcommand\enverb@ifnotend@maybe[2] + {\expandafter\enverb@ifnotend@perhaps\expandafter{\romannumeral`\^^@#2}{#1}} +\protected\def\enverb@ifnotend@setup@perhaps#1% + {% + \def\enverb@ifnotend@perhaps##1% + {% + \enverb@ifnotend@perhaps@\enverb@mark##1\enverb@mark\enverb@ifnotend@end + \enverb@mark#1\enverb@mark\@thirdofthree + \enverb@stop + }% + \def\enverb@ifnotend@perhaps@ + ##1\enverb@mark#1##2\enverb@mark##3##4\enverb@stop + {##3{##2}}% + } +\def\enverb@ifnotend@end#1#2#3% + {% + \iffalse{\fi}% + \enverb@ensure@blank{#1}{\string\end}% + \expandafter\enverb@finalise\expandafter{\enverbBody}{#2}% + } +\protected\def\enverb@finalise#1#2% + {% + \endgroup + \expandafter\enverbsetup\expandafter{\enverb@collected@marg}% + \enverb@ifoargtokeyhandler + {% + \expandafter\enverb@keyhandler\expanded + {{% + \unexpanded\expandafter{\enverb@unknown@kv},% + \unexpanded\expandafter{\enverb@collected@oarg}% + }}% + }% + {% + \expandafter\enverbsetup\expandafter{\enverb@collected@oarg}% + \expandafter\enverb@keyhandler\expandafter{\enverb@unknown@kv}% + }% + \enverb@ifautoignore + {\enverb@setup@ignore{\enverb@count{#2}+\enverb@moreignore}}% + {\enverb@setup@ignore\enverb@ignore}% + \edef\enverb@line##1\enverb@eol + {% + \noexpand\unexpanded{##1}% + %\noexpand\detokenize{##1}% % TODO + \noexpand\unexpanded{\unexpanded\expandafter{\enverb@eol@content}}% + }% + \edef\enverbBody{#1}% + \expandafter\end\expandafter{\@currenvir}% + } +\protected\def\enverb@setup@ignore#1% + {\expandafter\enverb@setup@ignore@\the\numexpr#1\relax;\enverb@line} +\protected\def\enverb@setup@ignore@#1;#2% + {% + \ifnum#1>9 + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + {\expandafter\enverb@setup@ignore@\the\numexpr#1-8;{\@firstofnine{#2}}}% + {% + \let\enverb@bol@gobble\@empty + \expanded + {% + \unexpanded{\renewcommand\enverb@bol@gobble}\ifnum#1>\z@[#1]\fi + {\unexpanded{#2}}% + \unexpanded{\def\enverb@bol##1\enverb@eol}% + {% + \noexpand\unexpanded + {\unexpanded\expandafter{\enverb@bol@content}}% + \unexpanded{\expandafter\enverb@ifempty\expanded}{{##1}}% + {\noexpand\enverb@line}% + {\noexpand\enverb@bol@gobble}% + ##1\noexpand\enverb@eol + }% + }% + }% + } +\def\enverb@rmeol + {% + \ifnum\catcode`\%=14 + \enverb@chargen{`\%}{12}% + \expandafter\enverb@stop + \fi + \enverb@rmeol@0;% + \enverb@stop + } +\def\enverb@rmeol@#1;% + {% + \ifnum#1=128 + \string\relax + \expandafter\enverb@stop + \fi + \@firstofone + {% + \ifnum\catcode`\%=14 + \enverb@chargen{#1}{12}% + \expandafter\enverb@stop + \fi + \expandafter\enverb@rmeol@\the\numexpr#1+1;% + }% + } +\NewDocumentCommand\enverbExecute{} + {% + \begingroup + \newlinechar=`\^^M + \expandafter + \endgroup + \scantokens\expanded + {{% + \detokenize\expandafter{\enverbBody}% + \enverb@rmeol + }}% + } +\NewDocumentCommand \enverbListing { m m } + {% + \scantokens\expanded + {{% + \string\begin{#1}\detokenize{#2}\enverb@othercr + \detokenize\expandafter{\enverbBody}% + \string\end{#1}\enverb@othercr + \enverb@rmeol + }}% + } +%% +%% +%% End of file `enverb.sty'. |