diff options
Diffstat (limited to 'luatexbase-attr.dtx')
-rw-r--r-- | luatexbase-attr.dtx | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx index 6332260..194cb8d 100644 --- a/luatexbase-attr.dtx +++ b/luatexbase-attr.dtx @@ -8,7 +8,7 @@ % % This work consists of the main source file luatexbase-attr.dtx % and the derived files -% luatexbase-attr.sty luatexbase.attr.lua +% luatexbase-attr.sty attr.lua % test-regs-plain.tex test-regs-latex.tex % % Unpacking: @@ -66,7 +66,7 @@ See source file '\inFileName' for details. \generate{% \usedir{tex/luatex/luatexbase}% - \file{luatexbase.attr.lua}{\from{luatexbase-attr.dtx}{luamodule}}% + \file{attr.lua}{\from{luatexbase-attr.dtx}{luamodule}}% } \obeyspaces @@ -75,7 +75,7 @@ See source file '\inFileName' for details. \Msg{* To finish the installation you have to move the following} \Msg{* files into a directory searched by TeX:} \Msg{*} -\Msg{* luatexbase-attr.sty luatexbase.attr.lua} +\Msg{* luatexbase-attr.sty attr.lua} \Msg{*} \Msg{* Happy TeXing!} \Msg{*} @@ -127,6 +127,8 @@ See source file '\inFileName' for details. % just like Plain TeX and LaTeX do for other registers. % \end{abstract} % +% \tableofcontents +% % \section{Documentation} % % The main macro defined here is |\newluatexattribute|. It behaves in the same @@ -154,7 +156,7 @@ See source file '\inFileName' for details. % definition of |\fooattr| and remember it in a Lua variable. For your % convenience, this is automatically done by |\newluatexattribute|: the number % is remembered in a dedicated Lua table so that you can get it as -% |luatextra.attributes.foobar| (mind the absence of backslash here) at any +% |luatexbase.attributes.foobar| (mind the absence of backslash here) at any % time. % % \section{Implementation} @@ -221,7 +223,7 @@ See source file '\inFileName' for details. \let\x\ProvidesPackage \fi \expandafter\endgroup -\x{luatexbase-attr}[2010/03/11 v0.1 Attributes allocation for LuaTeX (mpg)] +\x{luatexbase-attr}[2010/03/11 v0.1 Attributes allocation for LuaTeX] % \end{macrocode} % % Make sure \luatex is used. @@ -248,9 +250,31 @@ See source file '\inFileName' for details. \fi % \end{macrocode} % -% \subsubsection{Main content} +% \subsubsection{Primitives needed} % -% Load the supporting Lua module. +% Load \pk{luatexbase-compat}. +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input luatexbase-compat.sty +\else + \RequirePackage{luatexbase-compat} +\fi +% \end{macrocode} +% +% Make sure the primitives we need are available. +% +% \begin{macrocode} +\luatexbase@ensure@primitive{luaescapestring} +\luatexbase@ensure@primitive{attributedef} +\luatexbase@ensure@primitive{attribute} +% \end{macrocode} +% +% \subsubsection{Load supporting Lua module} +% +% First load \pk{luatexbase-loader} (hence \pk{luatexbase-compat}), then +% the supporting Lua module. % % \begin{macrocode} \begingroup\expandafter\expandafter\expandafter\endgroup @@ -259,9 +283,11 @@ See source file '\inFileName' for details. \else \RequirePackage{luatexbase-loader} \fi -\directlua{require('luatexbase.attr.lua')} +\luatexbase@directlua{require('luatexbase.attr')} % \end{macrocode} % +% \subsection{User macros} +% % The allocaton macro. % % \begin{macrocode} @@ -273,9 +299,10 @@ See source file '\inFileName' for details. \allocationnumber\lltxb@attribute@alloc \global\luatexattributedef#1=\allocationnumber \unsetluatexattribute#1% - \begingroup\escapechar\m@ne \expandafter\endgroup - \directlua{luatextra.attributedef_from_tex( + \begingroup\escapechar\m@ne + \luatexbase@directlua{luatexbase.attributedef_from_tex( '\luatexluaescapestring{\string#1}', '\number\allocationnumber')}% + \endgroup \wlog{\string#1=\string\luatexattribute\the\allocationnumber}% \else \errmessage{No room for a new \string\attribute}% @@ -311,14 +338,13 @@ See source file '\inFileName' for details. % % \begin{macrocode} %<*luamodule> -module('luatextra', package.seeall) +module('luatexbase', package.seeall) % \end{macrocode} % % Record the allocation number in a Lua table. % % \begin{macrocode} attributes = {} -tex.attributenumber = attributes function attributedef_from_tex(name, number) attributes[name] = tonumber(number) end @@ -342,13 +368,14 @@ end \newluatexattribute\testattr \setluatexattribute\testattr{1} \unsetluatexattribute\testattr -\directlua{assert(luatextra.attributes.testattr)} +\catcode64 11 +\luatexbase@directlua{assert(luatexbase.attributes.testattr)} \begingroup \escapechar64 \newluatexattribute\anotherattr \endgroup \setluatexattribute\anotherattr{1} -\directlua{assert(luatextra.attributes.anotherattr)} +\luatexbase@directlua{assert(luatexbase.attributes.anotherattr)} %</testplain,testlatex> %<testplain>\bye %<testlatex>\stop |