Created
December 31, 2012 15:20
-
-
Save zr-tex8r/4420657 to your computer and use it in GitHub Desktop.
LaTeX: bxluaembed (Test Edition)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% bxluaembed.sty | |
% | |
%% package declaration | |
\NeedsTeXFormat{LaTeX2e} | |
\ProvidesPackage{bxluaembed}[2012/05/02 v0.2a] | |
%% preparation | |
\def\bxim@pkgname{bxluaembed} | |
\def\bxim@error{\PackageError\bxim@pkgname} | |
%% engine check | |
\ifx\luatexversion\@undefined | |
\bxltz@error{LuaTeX is required} | |
{Package loading is aborted right now.} | |
\expandafter\endinput\fi\relax | |
\ifnum\luatexversion<65 | |
\bxltz@error{This LuaTeX is too old (<v0.65)} | |
{Package loading is aborted right now.} | |
\expandafter\endinput\fi\relax | |
% prerequisite packages | |
\RequirePackage{etoolbox} | |
\RequirePackage{luatexbase-regs} | |
\RequirePackage{luatexbase-cctb} | |
\RequirePackage{luatexbase-modutils} | |
\RequireLuaModule{bxluaembed} | |
% | |
\edef\bxim@restore@codes{% | |
\endlinechar=\the\endlinechar% | |
\relax} | |
\endlinechar=-1 % | |
%--------------------------------------- mini-bxluavienv | |
%% \bxim@decl@vienv | |
% Same as \DeclareVerbInputEnvironment (of bxluavienv package) | |
% with no optional arguments. | |
\def\bxim@decl@vienv#1{ | |
\csdef{#1}{\bxim@begin{#1}} | |
\edef\bxim@next{ | |
\def\expandonce{\csname bxim@grab@#1\endcsname} | |
####1\detokenize\expandafter{\string\end{#1}} | |
{\unexpanded{\bxim@grabbed{##1}}}} | |
\bxim@next | |
\csdef{bxim@body@#1}##1 | |
} | |
%% \bxim@begin{<name>} | |
\def\bxim@begin#1{ | |
\letcs\bxim@next{bxim@grab@#1} | |
\global\letcs\bxim@g@do{bxim@body@#1} | |
\endlinechar=13 % | |
\luatexcatcodetable\CatcodeTableOther | |
\bxim@next | |
} | |
%% \bxim@grabbed | |
\def\bxim@grabbed{ | |
\endgroup | |
\bxim@g@do | |
} | |
%--------------------------------------- main | |
%%<*> 'luaembed' environment | |
\bxim@decl@vienv{luaembed}{ | |
\directlua name{(luaembed)}{ | |
bxluaembed._process("\luatexluaescapestring{#1}", | |
\the\inputlineno) | |
} | |
} | |
%--------------------------------------- done | |
\bxim@restore@codes | |
\endinput | |
%% EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment