From Wiki
Jump to navigation Jump to search


MkIV is the current branch of the Context typesetting environment. As its underlying engine is supposed to be Luatex, MkIV is to a large extent implemented in Lua, as opposed to the legacy MkII which was written for Pdftex and Xetex as target engines.

As of now, documentation on the Lua guts of Context is somewhat rare. The definite guide is still the source code itself which, unfortunately, tends to be undercommented in many places. This portal-like wiki page is meant to gather links to existing documentation on Lua programming for Context/Luatex.

Documentation Links



ConTeXt Lua Extensions

Context MkIV extends the vanilla Lua libraries by some very useful functionality. This pertains mostly to stuff people tend to implement over and over again because it is provided by default with other scripting languages. Thus, before you reimplement, say, a string stripping function for the thousandth time – have a look at these files:

File Content
l-boolean.lua toboolean() – equivalent of tonumber() and tostring();
util-dim.lua Tex dimensions (accessible as number.* namespace);
l-dir.lua directory handling (globbing &c., namespace: dir.*);
l-file.lua filesystem related functions (namespace: file.*);
l-io.lua file/stream handling;
l-lpeg.lua pattern helpers;
l-math.lua extra functions for the Lua math library;
l-md5.lua checksum comparison, loading and saving;
l-number.lua additions to the number.* namespace – bitset handling;
l-os.lua additions to the os.* library, platform initialization;
l-pdfview.lua --autopdf handling of mtxrun;
l-set.lua set handling (set.* namespace);
l-string.lua string manipulation;
l-table.lua Table manipulation;
l-unicode.lua extensions to the sln-unicode lib, converters for character encodings;
l-url.lua URI matching (namespace: url.*; also a nice tutorial on lpeg).
Lua Library Extensions.

Further Links

Places worth a visit when hunting for answers.


Luatex Libs