Debian Codegraph @

texmf-dist/tex/generic/etoolbox-generic/etoolbox-generic.tex

raw
1 % etoolbox-generic.tex 2023/10/10 v2.5k
2 %
3 % This is a loader for etoolbox.sty 2020/10/05 v2.5k in non-LaTeX formats.
4 %
5 % Copyright (c) 2023- Saso Zivanovic <[email protected]>
6 %
7 % This work may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License, either version 1.3c of this license or (at
9 % your option) any later version. The latest version of this license is in
10 % https://www.latex-project.org/lppl.txt and version 1.3c or later is part of
11 % all distributions of LaTeX version 2008 or later.
12 %
13 % This work has the LPPL maintenance status `maintained`.
14 % The Current Maintainer of this work is Saso Zivanovic.
15 %
16 % This work consist of this file and README.md.
17 %
18 % Prevent double-loading.
19 \ifcsname [email protected]\endcsname
20 \expandafter\endinput
21 \fi
22 % We need miniltx and a couple of auxiliary macros.
23 \input miniltx
24 \def\newif#1{%
25 \count@\escapechar \escapechar\m@ne
26 \let#1\iffalse
27 \@if#1\iftrue
28 \@if#1\iffalse
29 \escapechar\count@}
30 \def\@if#1#2{%
31 \expandafter\def\csname\expandafter\@gobbletwo\string#1%
32 \expandafter\@gobbletwo\string#2\endcsname
33 {\let#1#2}}
34 % We need to define \AtEndOfPackage; etoolbox uses it to undefine its
35 % catcodes. We're careful and restore the old (probably empty) definition at
36 % the end.
37 \let\etb@AtEndOfPackage\AtEndOfPackage
38 \def\AtEndOfPackage#1{\def\AtEndOfPackageDo{#1}}
39 % Kindly, all the LaTeX-specific code in etoolbox.sty occurs after
40 % the call to \IfFormatAtLeastTF. Redefining this macro to \endinput will
41 % therefore remove the LaTeX-specific part of the package:
42 \def\IfFormatAtLeastTF#1#2#3{\endinput}
43 \let\etb@extrafloats\extrafloats
44 \let\extrafloats\relax
45 \input etoolbox.sty
46 % Restore what we changed, and execute the end-of-package code.
47 \let\extrafloats\etb@extrafloats
48 \AtEndOfPackageDo
49 \let\AtEndOfPackage\etb@AtEndOfPackage
50 \let\AtEndOfPackageDo\relax
51 \cslet{[email protected]}\relax
52 % To have this package work in ConTeXt, we must patch the macros by replacing
53 % \unexpanded with \normalunexpanded.
54 \ifcsname normalunexpanded\endcsname
55 \def\etb@patchunexpanded#1{%
56 \patchcmd#1\unexpanded\normalunexpanded{}{%
57 \PackageError{etoolbox}{Cannot adapt command \string#1 to ConTeXt}{}%
58 }%
59 }
60 % \patchcmd itself uses \etb@patchcmd@scantoks which uses \unexpanded; so we
61 % temporarily redefine \unexpanded to patch \etb@patchcmd@scantoks.
62 \let\unexpanded\normalunexpanded
63 \etb@patchunexpanded\etb@patchcmd@scantoks
64 \let\unexpanded\protected
65 % Now we can patch the rest.
66 \etb@patchunexpanded\expandonce
67 \etb@patchunexpanded\etb@unexpandable
68 \etb@patchunexpanded\appto\etb@patchunexpanded\appto
69 \etb@patchunexpanded\gappto\etb@patchunexpanded\gappto
70 \etb@patchunexpanded\preto\etb@patchunexpanded\preto
71 \etb@patchunexpanded\gpreto\etb@patchunexpanded\gpreto
72 \etb@patchunexpanded\etb@hooktocmd
73 % Patching \protecting is a bit involved, as its parameters text is #.
74 \expandafter\def\expandafter\protecting\expandafter{\protecting{}}
75 \etb@patchunexpanded\protecting
76 \patchcmd\protecting{{}}{}{}{}%
77 \expandafter\def\expandafter\protecting\expandafter#\expandafter{\protecting}
78 \fi
79 \resetatcatcode
80 \endinput