Debian Codegraph @

texmf-dist/tex/lualatex/luacode/luacode.sty

raw
1 %%
2 %% This is file `luacode.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% luacode.dtx (with options: `texpackage')
8 %%
9 %% See the source file for author and licensing information.
10 %%
11 \begingroup\catcode61\catcode48\catcode32=10\relax% = and space
12 \catcode123 1 % {
13 \catcode125 2 % }
14 \catcode 35 6 % #
15 \toks0{\endlinechar\the\endlinechar}%
16 \edef\x{\endlinechar13}%
17 \def\y#1 #2 {%
18 \toks0\expandafter{\the\toks0 \catcode#1 \the\catcode#1}%
19 \edef\x{\x \catcode#1 #2}}%
20 \y 13 5 % carriage return
21 \y 61 12 % =
22 \y 32 10 % space
23 \y 123 1 % {
24 \y 125 2 % }
25 \y 35 6 % #
26 \y 64 11 % @ (letter)
27 \y 39 12 % '
28 \y 40 12 % (
29 \y 41 12 % )
30 \y 42 12 % *
31 \y 45 12 % -
32 \y 46 12 % .
33 \y 47 12 % /
34 \y 91 12 % [
35 \y 93 12 % ]
36 \y 94 7 % ^
37 \y 96 12 % `
38 \y 126 13 % ~
39 \toks0\expandafter{\the\toks0 \relax\noexpand\endinput}%
40 \edef\y#1{\noexpand\expandafter\endgroup%
41 \noexpand\ifx#1\relax \edef#1{\the\toks0}\x\relax%
42 \noexpand\else \noexpand\expandafter\noexpand\endinput%
43 \noexpand\fi}%
44 \expandafter\y\csname luacode@sty@endinput\endcsname%
45 \ProvidesPackage{luacode}[2012/01/23 v1.2a lua-in-tex helpers (mpg)]
46 \RequirePackage{ifluatex}
47 \ifluatex\else
48 \PackageError{luacode}{LuaTeX is required for this package. Aborting.}{%
49 This package can only be used with the LuaTeX engine\MessageBreak
50 (command `lualatex'). Package loading has been stopped\MessageBreak
51 to prevent additional errors.}
52 \expandafter\luacode@sty@endinput
53 \fi
54 \RequirePackage{luatexbase}
55 \newcommand \luacode@printdbg [1] {%
56 texio.write_nl('log',
57 '-- BEGIN luacode debug (on input line \the\inputlineno)')
58 texio.write_nl('log', "\luatexluaescapestring{#1}")
59 texio.write_nl('log',
60 '-- END luacode debug (on input line \the\inputlineno)')
61 }
62 \newcommand \luacode@dbg@exec [1] {%
63 \directlua {
64 \luacode@maybe@printdbg{#1}
65 #1
66 }%
67 }
68 \begingroup \catcode`\~\active \expandafter\endgroup
69 \@firstofone{%
70 \newcommand \luacode@execute [1] {%
71 \begingroup
72 \escapechar92
73 \newlinechar10
74 \edef\\{\string\\}%
75 \edef~{\string~}%
76 \let\%=\luacode@percentchar
77 \let\#=\luacode@sharpchar
78 \expandafter\expandafter\expandafter\endgroup
79 \luacode@dbg@exec{#1}}
80 }
81 \begingroup \escapechar\m@ne \edef\aux{\endgroup
82 \unexpanded{\newcommand\luacode@percentchar}{\string\%}%
83 \unexpanded{\newcommand\luacode@sharpchar }{\string\#}%
84 }\aux
85 \newcommand*\luacode@begin [1] {%
86 \begingroup
87 \escapechar92
88 \luatexcatcodetable#1\relax
89 \edef\luacode@endmark{\string\end{\@currenvir}}%
90 \expandafter\def \expandafter\luacode@endmark \expandafter{%
91 \luatexscantextokens \expandafter{\luacode@endmark}}%
92 \luacode@grab@body}
93 \newcommand\luacode@end{%
94 \edef\luacode@next{%
95 \noexpand\luacode@execute{\the\luacode@lines}%
96 \noexpand\end{\@currenvir}}%
97 \expandafter\endgroup
98 \luacode@next}
99 \newtoks\luacode@lines
100 \newcommand*\luacode@addline [1] {%
101 \luacode@lines\expandafter{\the\luacode@lines#1^^J}}
102 \newcommand \luacode@grab@body [1] {%
103 \luacode@lines{}%
104 \endlinechar10
105 \luacode@grab@lines}
106 \long\def\luacode@grab@lines#1^^J{%
107 \def\luacode@curr{#1}%
108 \luacode@strip@spaces
109 \ifx\luacode@curr\luacode@endmark
110 \expandafter\luacode@end
111 \else
112 \expandafter\luacode@addline\expandafter{\luacode@curr}%
113 \expandafter\luacode@grab@lines
114 \fi}
115 \begingroup\catcode32 12 \expandafter\endgroup
116 \@firstofone{\newcommand\luacode@spaceother{ }}
117 \newcommand \luacode@strip@spaces {%
118 \expandafter\luacode@strip@sp@peek\luacode@curr\@nil}
119 \newcommand \luacode@strip@sp@peek {%
120 \futurelet\@let@token\luacode@strip@sp@look}
121 \newcommand \luacode@strip@sp@look {%
122 \expandafter\ifx\luacode@spaceother\@let@token
123 \expandafter\@firstoftwo
124 \else
125 \expandafter\@secondoftwo
126 \fi{%
127 \afterassignment\luacode@strip@sp@peek
128 \let\@let@token=
129 }{%
130 \luacode@strip@sp@def
131 }}
132 \@ifdefinable \luacode@strip@sp@def \relax
133 \def \luacode@strip@sp@def #1\@nil{%
134 \def\luacode@curr{#1}}
135 \newluatexcatcodetable \luacode@table@soft
136 \begingroup
137 \ifdefined\SetCatcodeRange \else
138 \let\SetCatcodeRange\setcatcoderange
139 \fi
140 \setluatexcatcodetable \luacode@table@soft {%
141 \luatexcatcodetable\CatcodeTableOther
142 \catcode 92 0
143 \catcode 123 1
144 \catcode 125 2
145 \SetCatcodeRange {65}{90} {11}
146 \SetCatcodeRange {97}{122}{11}
147 }
148 \endgroup
149 \newcommand \LuaCodeDebugOn {\let \luacode@maybe@printdbg \luacode@printdbg}
150 \newcommand \LuaCodeDebugOff {\let \luacode@maybe@printdbg \@gobble}
151 \LuaCodeDebugOff
152 \@ifdefinable\luadirect {\let\luadirect\luacode@dbg@exec}
153 \newcommand*\luaexec [1] {\luacode@execute{#1}}
154 \newenvironment {luacode} {\luacode@begin\luacode@table@soft} {}
155 \newenvironment {luacode*} {\luacode@begin\CatcodeTableOther} {}
156 \newcommand \luacodestar {\@nameuse{luacode*}}
157 \def \endluacodestar {\@nameuse{endluacode*}}
158 \newcommand \luastring [1] {"\luatexluaescapestring{#1}"}
159 \newcommand \luastringO [1] {\luastring{\unexpanded\expandafter{#1}}}
160 \newcommand \luastringN [1] {\luastring{\unexpanded{#1}}}
161 \luacode@sty@endinput
162 \endinput
163 %%
164 %% End of file `luacode.sty'.