summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-03-27 14:10:02 +0100
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-03-27 14:10:02 +0100
commitc14ea2489bbb1db61dd27b861015cdd269c888bc (patch)
treec0a7d297c5c298988e3d3e7365f41c7a1c3ea677
parent695552b7e7619bb903bcfe61a3d4c16e156fb535 (diff)
downloadluatexbase-c14ea2489bbb1db61dd27b861015cdd269c888bc.tar.gz
Doc for cctb and additional code cleanup.
-rw-r--r--Changes2
-rw-r--r--TODO6
-rw-r--r--lltxb-dtxstyle.tex3
-rw-r--r--luatexbase-attr.dtx2
-rw-r--r--luatexbase-cctb.dtx101
5 files changed, 84 insertions, 30 deletions
diff --git a/Changes b/Changes
index 798660b..be473e4 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,7 @@
Changes in the luatexbase package/bundle
2010/03/26
- luatexbase-cctb
+ luatexbase-cctb 0.1
- add minimal test files for luatex and lualatex
- fix allocation range (1->65535)
- make sure newly allocated tables are initialised
diff --git a/TODO b/TODO
index d626596..27e0e7f 100644
--- a/TODO
+++ b/TODO
@@ -30,3 +30,9 @@ attr
---
- don't write in the tex table!
+
+cctb
+----
+
+- don't write in the tex table!
+- don't define macros starting with \luatex
diff --git a/lltxb-dtxstyle.tex b/lltxb-dtxstyle.tex
index fec762d..f3bafb4 100644
--- a/lltxb-dtxstyle.tex
+++ b/lltxb-dtxstyle.tex
@@ -5,7 +5,8 @@
\usepackage{geometry}
\usepackage{xspace}
\usepackage[english]{babel}
-\usepackage[colorlinks, bookmarks]{hyperref}
+\usepackage[colorlinks]{hyperref}
+\usepackage{bookmark}
% logos
\makeatletter
diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx
index 77c97ab..0fe7b98 100644
--- a/luatexbase-attr.dtx
+++ b/luatexbase-attr.dtx
@@ -122,7 +122,7 @@ and the derived files
% \title{The \pk{luatexbase-attr} package}
% \date{v0.1 2010-03-11}
% \author{%
-% Manuel P\'egouri\'e-Gonnard \\ \email{mpg@elzevir.fr} \and
+% Manuel P\'egouri\'e-Gonnard \\ \email{mpg@elzevir.fr} \and
% \'Elie Roux \\ \email{elie.roux@telecom-bretagne.eu}}
%
% \maketitle
diff --git a/luatexbase-cctb.dtx b/luatexbase-cctb.dtx
index 42a124e..5eeefc9 100644
--- a/luatexbase-cctb.dtx
+++ b/luatexbase-cctb.dtx
@@ -123,16 +123,70 @@ and the derived files
% \title{The \pk{luatexbase-cctb} package}
% \date{v0.1 2010-03-26}
% \author{%
-% Manuel P\'egouri\'e-Gonnard \\ \texttt{mpg@elzevir.fr} \and
+% Manuel P\'egouri\'e-Gonnard \\ \texttt{mpg@elzevir.fr} \and
% \'Elie Roux \\ \texttt{elie.roux@telecom-bretagne.eu}}
%
% \maketitle
%
% \begin{abstract}
+% In addition to the registers existing in \tex and \etex, \luatex introduces
+% a new concept: catcode tables. This package takes care of catcode table
+% allocation just like Plain TeX and LaTeX do for other registers.
% \end{abstract}
%
% \section{Documentation}
%
+% The main macro defined here is |\newluatexcatcodetable|. It behaves the same
+% as |\newbox|. Additonally, the newly allocated catcode table is initialised
+% to the catcodes of Ini\tex. In order to help you define the catcode tables
+% (once they are allocated), two helper macros are available.
+%
+% \begin{quote}
+% \cs{luatexsetcatcoderange}\marg{from}\marg{to}\marg{value}
+% \end{quote}
+% Set all characters code in the range \meta{from}--\meta{to} to the given
+% catcode \meta{value}.
+%
+% \begin{quote}
+% \cs{setluatexcatcodetable}\marg{table}\marg{catcode statements}
+% \end{quote}
+% Set a previously allocated \meta{table} to the catcodes given by executing
+% \meta{catcode statements}. Note that \meta{table} must not be the current
+% active catcode table. You may, however, load another catcode table in your
+% \meta{catcode statements}.
+%
+% For your convenience, a few catcode tables are prefined:
+% \begin{itemize}
+% \item |\CatcodeTableIniTeX|: Ini\tex catcodes.
+% \item |\CatcodeTableString|: the catcode regime used by |\string| and
+% |\meaning|: everything has catcode 12, except space (U+0020) that has
+% catcode 10.
+% \item |\CatcodeTableOther|: everything (included space) has catcode 12.
+% \item |\CatcodeTableLaTeX|: basic \LaTeXe\ catcodes.
+% \item |\CatcodeTableLaTeXAtLetter|: same as above, but |@| is a letter.
+% \item |\CatcodeTableExpl|: catcodes used by \latex{}3 with |\ExplSyntaxOn|.
+% Be aware that this does not provide the exact same environment as
+% |\ExplSyntaxOn|: most noticibly, some booleans are not set, and
+% |\endlinechar| is not adjusted (it should be 32).
+% \end{itemize}
+%
+% Various Lua function accept a catcode table number as argument. In order to
+% use them, the package writer needs to know the number of an allocated
+% catcode table. Since |\chardef| is used for the definition of the control
+% sequence, this is rather easy to do. However, for extra ease of use, the
+% numbers are also directly accessible from Lua as the value of the table
+% |luatextra.catcodetables|, whose keys is the name of the control sequence
+% (without any leading backslash). Moreover, nickames are available for the
+% predefined catcode tables:
+% \begin{itemize}
+% \item |CatcodeTableIniTeX| = |ini|,
+% \item |CatcodeTableString| = |string|,
+% \item |CatcodeTableOther| = |other|,
+% \item |CatcodeTableLaTeX| = |latex|,
+% \item |CatcodeTableLaTeXAtLetter| = |latex-atletter| = |latex-package|,
+% \item |CatcodeTableExpl| = |expl| = |expl3|,
+% \end{itemize}
+%
% \section{Implementation}
%
% \subsection{\tex package}
@@ -235,10 +289,7 @@ and the derived files
\fi
% \end{macrocode}
%
-% A macro that sets the catcode of a range of characters. The first
-% parameter is the character number of the first character of the range,
-% the second parameter is one for the last character, and the third
-% parameter is the catcode we want them to have.
+% Set the catcodes for a range of characters.
%
% \begin{macrocode}
\def\luatexsetcatcoderange#1#2#3{%
@@ -246,32 +297,18 @@ and the derived files
\noexpand\@tempcnta=\the\@tempcnta
\noexpand\@tempcntb=\the\@tempcntb
\noexpand\count@=\the\count@
- \relax
- }%
+ \relax}%
\@tempcnta=#1\relax
\@tempcntb=#2\relax
\count@=#3\relax
\loop\unless\ifnum\@tempcnta>\@tempcntb
\catcode\@tempcnta=\count@
- \advance\@tempcnta by 1\relax
+ \advance\@tempcnta\@ne
\repeat
\luaSCR@temp}
% \end{macrocode}
%
-% Finally we create several catcodetables that may be used by the user.
-% These are:
-%
-% \begin{itemize}
-% \item \texttt{\string\CatcodeTableIniTeX}: the base \TeX\ catcodes
-% \item \texttt{\string\CatcodeTableString}: almost all characters have
-% catcode 12
-% \item \texttt{\string\CatcodeTableOther}: all characters have catcode 12
-% (even space)
-% \item \texttt{\string\CatcodeTableLaTeX}: the \LaTeX\ classical catcodes
-% \item \texttt{\string\CatcodeTableLaTeXAtLetter}: the \LaTeX\ classical
-% catcodes and |@| letter
-% \item \texttt{\string\CatcodeTableExpl}: the expl3 catcodes
-% \end{itemize}
+% Set a catcode table.
%
% \begin{macrocode}
\def\setluatexcatcodetable#1#2{%
@@ -281,10 +318,14 @@ and the derived files
\endgroup}
% \end{macrocode}
%
+% The |IniTeX| catcode table needs no extra initialisation.
+%
% \begin{macrocode}
\newluatexcatcodetable\CatcodeTableIniTeX
% \end{macrocode}
%
+% The |String| and |Other| catcode tables.
+%
% \begin{macrocode}
\newluatexcatcodetable\CatcodeTableString
\setluatexcatcodetable\CatcodeTableString{%
@@ -305,6 +346,8 @@ and the derived files
\catcode32 12 }
% \end{macrocode}
%
+% Tables for \LaTeXe.
+%
% \begin{macrocode}
\newluatexcatcodetable\CatcodeTableLaTeX
\setluatexcatcodetable\CatcodeTableLaTeX{%
@@ -331,6 +374,8 @@ and the derived files
\catcode64=11 }
% \end{macrocode}
%
+% A table for \pk{expl3}.
+%
% \begin{macrocode}
\newluatexcatcodetable\CatcodeTableExpl
\setluatexcatcodetable\CatcodeTableExpl{%
@@ -343,6 +388,8 @@ and the derived files
}
% \end{macrocode}
%
+% Finally do the shortcuts.
+%
% \begin{macrocode}
\directlua{luatextra.catcodetable_do_shortcuts()}
%</texpackage>
@@ -360,10 +407,10 @@ module('luatextra', package.seeall)
% \texttt{\string\newluacatcodetable}.
%
% \begin{macrocode}
-luatextra.catcodetables = {}
-tex.catcodetablenumber = luatextra.catcodetables
-function luatextra.catcodetabledef_from_tex(name, number)
- luatextra.catcodetables[name] = tonumber(number)
+catcodetables = {}
+tex.catcodetablenumber = catcodetables
+function catcodetabledef_from_tex(name, number)
+ catcodetables[name] = tonumber(number)
end
% \end{macrocode}
%
@@ -372,7 +419,7 @@ end
% |tex.catcodetablenumber['CatcodeTableLaTeX']|.
%
% \begin{macrocode}
-function luatextra.catcodetable_do_shortcuts()
+function catcodetable_do_shortcuts()
local cat = luatextra.catcodetables
cat['latex'] = cat.CatcodeTableLaTeX
cat['latex-package'] = cat.CatcodeTableLaTeXAtLetter