From 48d2558c3ffad7abe989102c448a8f65f37e1faa Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 8 Nov 2010 23:39:23 +0000 Subject: new latex package luacode (8nov10) git-svn-id: svn://tug.org/texlive/trunk@20372 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/lualatex/luacode/luacode.sty | 140 +++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Master/texmf-dist/tex/lualatex/luacode/luacode.sty (limited to 'Master/texmf-dist/tex/lualatex/luacode') diff --git a/Master/texmf-dist/tex/lualatex/luacode/luacode.sty b/Master/texmf-dist/tex/lualatex/luacode/luacode.sty new file mode 100644 index 00000000000..8f513dd56ee --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/luacode/luacode.sty @@ -0,0 +1,140 @@ +%% +%% 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 + \catcode123 1 % { + \catcode125 2 % } + \catcode 35 6 % # + \toks0{}% + \def\x{}% + \def\y#1 #2 {% + \toks0\expandafter{\the\toks0 \catcode#1 \the\catcode#1}% + \edef\x{\x \catcode#1 #2}}% + \y 123 1 % { + \y 125 2 % } + \y 35 6 % # + \y 10 12 % ^^J + \y 34 12 % " + \y 36 3 % $ $ + \y 39 12 % ' + \y 40 12 % ( + \y 41 12 % ) + \y 42 12 % * + \y 43 12 % + + \y 44 12 % , + \y 45 12 % - + \y 46 12 % . + \y 47 12 % / + \y 60 12 % < + \y 61 12 % = + \y 64 11 % @ (letter) + \y 62 12 % > + \y 95 12 % _ (other!) + \y 96 12 % ` + \edef\y#1{\endgroup\edef#1{\the\toks0\relax}\x}% +\expandafter\y\csname luacode@AtEnd\endcsname +\ProvidesPackage{luacode}[2010/11/08 v1.0 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.} + \lltxb@core@AtEnd + \expandafter\endinput +\fi +\RequirePackage{luatexbase} +\luatexbase@ensure@primitive{scantextokens}% +\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 + \luatexbase@directlua{#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^^J#1}} +\newcommand \luacode@grab@body { + \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 +\setluatexcatcodetable \luacode@table@soft {% + \luatexcatcodetable\CatcodeTableOther + \catcode 92 0 + \catcode 123 1 + \catcode 125 2 + \setcatcoderange {65}{90} {11} + \setcatcoderange {97}{122}{11} +} +\@ifdefinable\luadirect {\let\luadirect\luatexbase@directlua} +\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*}} +\luacode@AtEnd +\endinput +%% +%% End of file `luacode.sty'. -- cgit v1.2.3