summaryrefslogtreecommitdiff
path: root/luatexbase-mcb.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'luatexbase-mcb.dtx')
-rw-r--r--luatexbase-mcb.dtx136
1 files changed, 127 insertions, 9 deletions
diff --git a/luatexbase-mcb.dtx b/luatexbase-mcb.dtx
index d711ff1..4abe6db 100644
--- a/luatexbase-mcb.dtx
+++ b/luatexbase-mcb.dtx
@@ -1,6 +1,8 @@
% \iffalse meta-comment
%
-% Copyright (C) 2009 by Elie Roux <elie.roux@telecom-bretagne.eu>
+% Written in 2009, 2010 by Manuel Pégourié-Gonnard and Élie Roux.
+% <mpg@elzevir.fr>
+% <elie.roux@telecom-bretagne.eu>
%
% This work is under the CC0 license.
%
@@ -43,6 +45,11 @@ See source file '\inFileName' for details.
\let\MetaPrefix\DoubleperCent
\generate{%
+ \usedir{tex/luatex/luatexbase}%
+ \file{luatexbase-mcb.sty}{\from{luatexbase-mcb.dtx}{texpackage}}%
+}
+
+\generate{%
\usedir{doc/luatex/luatexbase}%
\file{test-mcb-plain.tex}{\from{luatexbase-mcb.dtx}{testplain}}%
\file{test-mcb-latex.tex}{\from{luatexbase-mcb.dtx}{testlatex}}%
@@ -108,7 +115,9 @@ See source file '\inFileName' for details.
%
% \title{The \textsf{luatexbase-mcb} package}
% \date{2009/09/18 v0.93}
-% \author{Elie Roux \\ \texttt{elie.roux@telecom-bretagne.eu}}
+% \author{%
+% Manuel P\'egouri\'e-Gonnard \\ \email{mpg@elzevir.fr} \and
+% \'Elie Roux \\ \email{elie.roux@telecom-bretagne.eu}}
%
% \maketitle
%
@@ -122,6 +131,8 @@ See source file '\inFileName' for details.
% has been previously loaded. (This is a temporary limitation.)
% \end{abstract}
%
+% \tableofcontents
+%
% \section{Documentation}
%
% Lua\TeX\ provides an extremely interesting feature, named callbacks. It
@@ -149,10 +160,7 @@ See source file '\inFileName' for details.
% This package also privides a way to create and call new callbacks, in
% addition to the default Lua\TeX\ callbacks.
%
-% This package contains only a \texttt{.lua} file, that can be called by
-% another lua script.
-%
-%\subsubsection*{Limitations}
+% \subsubsection*{Limitations}
%
% This package only works for callbacks where it's safe to add multiple
% functions without changing the functions' signatures. There are callbacks,
@@ -171,6 +179,117 @@ See source file '\inFileName' for details.
%
% \section{Implementation}
%
+% \subsection{\tex package}
+%
+% \begin{macrocode}
+%<*texpackage>
+% \end{macrocode}
+%
+% \subsubsection{Preliminaries}
+%
+% Reload protection, especially for \plaintex.
+%
+% \begin{macrocode}
+ \csname lltxb@mcb@loaded\endcsname
+\expandafter\let\csname lltxb@mcb@loaded\endcsname\endinput
+% \end{macrocode}
+%
+% Catcode defenses.
+%
+% \begin{macrocode}
+\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 lltxb@mcb@AtEnd\endcsname
+% \end{macrocode}
+%
+% Package declaration.
+%
+% \begin{macrocode}
+\begingroup
+ \expandafter\ifx\csname ProvidesPackage\endcsname\relax
+ \def\x#1[#2]{\immediate\write16{Package: #1 #2}}
+ \else
+ \let\x\ProvidesPackage
+ \fi
+\expandafter\endgroup
+\x{luatexbase-mcb}[2010/09/11 v0.93 Callbacks hanndling for LuaTeX (mpg)]
+% \end{macrocode}
+%
+% Make sure \luatex is used.
+%
+% \begin{macrocode}
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname RequirePackage\endcsname\relax
+ \input ifluatex.sty
+\else
+ \RequirePackage{ifluatex}
+\fi
+\ifluatex\else
+ \begingroup
+ \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
+ \def\x#1#2{\begingroup\newlinechar10
+ \immediate\write16{Package #1 warning: #2}\endgroup}
+ \else
+ \let\x\PackageWarningNoLine
+ \fi
+ \expandafter\endgroup
+ \x{luatexbase-mcb}{LuaTeX is required for this package. Aborting.}
+ \lltxb@mcb@AtEnd
+ \expandafter\endinput
+\fi
+% \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
+\expandafter\ifx\csname RequirePackage\endcsname\relax
+ \input luatexbase-modutils.sty
+\else
+ \RequirePackage{luatexbase-modutils}
+\fi
+\luatexbase@directlua{require('luatexbase.mcb')}
+% \end{macrocode}
+%
+% That's all folks!
+%
+% \begin{macrocode}
+\lltxb@mcb@AtEnd
+%</texpackage>
+% \end{macrocode}
+%
% \subsection{Lua module}
%
% Module identification.
@@ -681,12 +800,11 @@ end
% A few basic tests for Plain and LaTeX.
%
% \begin{macrocode}
-%<testplain>\input luatexbase-modutils.sty
-%<testlatex>\RequirePackage{luatexbase-modutils}
+%<testplain>\input luatexbase-mcb.sty
+%<testlatex>\RequirePackage{luatexbase-mcb}
%<*testplain,testlatex>
\catcode 64 11
\luatexbase@directlua{
- require "luatexbase.mcb"
local function one(head,...)
texio.write_nl("I'm number 1")
return head, true