%% %% This is file `luacode.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% luacode.dtx (with options: `texpackage') %% %% See the source file for author and licensing information. %% \begingroup\catcode61\catcode48\catcode32=10\relax% = and space \catcode123 1 % { \catcode125 2 % } \catcode 35 6 % # \toks0{\endlinechar\the\endlinechar}% \edef\x{\endlinechar13}% \def\y#1 #2 {% \toks0\expandafter{\the\toks0 \catcode#1 \the\catcode#1}% \edef\x{\x \catcode#1 #2}}% \y 13 5 % carriage return \y 61 12 % = \y 32 10 % space \y 123 1 % { \y 125 2 % } \y 35 6 % # \y 64 11 % @ (letter) \y 39 12 % ' \y 40 12 % ( \y 41 12 % ) \y 42 12 % * \y 45 12 % - \y 46 12 % . \y 47 12 % / \y 91 12 % [ \y 93 12 % ] \y 94 7 % ^ \y 96 12 % ` \y 126 13 % ~ \toks0\expandafter{\the\toks0 \relax\noexpand\endinput}% \edef\y#1{\noexpand\expandafter\endgroup% \noexpand\ifx#1\relax \edef#1{\the\toks0}\x\relax% \noexpand\else \noexpand\expandafter\noexpand\endinput% \noexpand\fi}% \expandafter\y\csname luacode@sty@endinput\endcsname% \ProvidesPackage{luacode}[2012/01/23 v1.2a lua-in-tex helpers (mpg)] \RequirePackage{ifluatex} \ifluatex\else \PackageError{luacode}{LuaTeX is required for this package. Aborting.}{% This package can only be used with the LuaTeX engine\MessageBreak (command `lualatex'). Package loading has been stopped\MessageBreak to prevent additional errors.} \expandafter\luacode@sty@endinput \fi \RequirePackage{luatexbase} \newcommand \luacode@printdbg [1] {% texio.write_nl('log', '-- BEGIN luacode debug (on input line \the\inputlineno)') texio.write_nl('log', "\luatexluaescapestring{#1}") texio.write_nl('log', '-- END luacode debug (on input line \the\inputlineno)') } \newcommand \luacode@dbg@exec [1] {% \directlua { \luacode@maybe@printdbg{#1} #1 }% } \begingroup \catcode`\~\active \expandafter\endgroup \@firstofone{% \newcommand \luacode@execute [1] {% \begingroup \escapechar92 \newlinechar10 \edef\\{\string\\}% \edef~{\string~}% \let\%=\luacode@percentchar \let\#=\luacode@sharpchar \expandafter\expandafter\expandafter\endgroup \luacode@dbg@exec{#1}} } \begingroup \escapechar\m@ne \edef\aux{\endgroup \unexpanded{\newcommand\luacode@percentchar}{\string\%}% \unexpanded{\newcommand\luacode@sharpchar }{\string\#}% }\aux \newcommand*\luacode@begin [1] {% \begingroup \escapechar92 \luatexcatcodetable#1\relax \edef\luacode@endmark{\string\end{\@currenvir}}% \expandafter\def \expandafter\luacode@endmark \expandafter{% \luatexscantextokens \expandafter{\luacode@endmark}}% \luacode@grab@body} \newcommand\luacode@end{% \edef\luacode@next{% \noexpand\luacode@execute{\the\luacode@lines}% \noexpand\end{\@currenvir}}% \expandafter\endgroup \luacode@next} \newtoks\luacode@lines \newcommand*\luacode@addline [1] {% \luacode@lines\expandafter{\the\luacode@lines#1^^J}} \newcommand \luacode@grab@body [1] {% \luacode@lines{}% \endlinechar10 \luacode@grab@lines} \long\def\luacode@grab@lines#1^^J{% \def\luacode@curr{#1}% \luacode@strip@spaces \ifx\luacode@curr\luacode@endmark \expandafter\luacode@end \else \expandafter\luacode@addline\expandafter{\luacode@curr}% \expandafter\luacode@grab@lines \fi} \begingroup\catcode32 12 \expandafter\endgroup \@firstofone{\newcommand\luacode@spaceother{ }} \newcommand \luacode@strip@spaces {% \expandafter\luacode@strip@sp@peek\luacode@curr\@nil} \newcommand \luacode@strip@sp@peek {% \futurelet\@let@token\luacode@strip@sp@look} \newcommand \luacode@strip@sp@look {% \expandafter\ifx\luacode@spaceother\@let@token \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi{% \afterassignment\luacode@strip@sp@peek \let\@let@token= }{% \luacode@strip@sp@def }} \@ifdefinable \luacode@strip@sp@def \relax \def \luacode@strip@sp@def #1\@nil{% \def\luacode@curr{#1}} \newluatexcatcodetable \luacode@table@soft \begingroup \ifdefined\SetCatcodeRange \else \let\SetCatcodeRange\setcatcoderange \fi \setluatexcatcodetable \luacode@table@soft {% \luatexcatcodetable\CatcodeTableOther \catcode 92 0 \catcode 123 1 \catcode 125 2 \SetCatcodeRange {65}{90} {11} \SetCatcodeRange {97}{122}{11} } \endgroup \newcommand \LuaCodeDebugOn {\let \luacode@maybe@printdbg \luacode@printdbg} \newcommand \LuaCodeDebugOff {\let \luacode@maybe@printdbg \@gobble} \LuaCodeDebugOff \@ifdefinable\luadirect {\let\luadirect\luacode@dbg@exec} \newcommand*\luaexec [1] {\luacode@execute{#1}} \newenvironment {luacode} {\luacode@begin\luacode@table@soft} {} \newenvironment {luacode*} {\luacode@begin\CatcodeTableOther} {} \newcommand \luacodestar {\@nameuse{luacode*}} \def \endluacodestar {\@nameuse{endluacode*}} \newcommand \luastring [1] {"\luatexluaescapestring{#1}"} \newcommand \luastringO [1] {\luastring{\unexpanded\expandafter{#1}}} \newcommand \luastringN [1] {\luastring{\unexpanded{#1}}} \luacode@sty@endinput \endinput %% %% End of file `luacode.sty'.