Hi all,

ConTeXt mkiv stores all sorts of things in Lua tables, but 'what goes
where' does not tend to be documented. So here is a function to print
out a table's contents to get something like the following excerpt.

The excerpt is from the output of
`userdata.showtable(structures.lists)` in a document with three
\placefigures and one \placeformula. Note the reference in
T.cached.1.references.reference, and the caption in
T.cached.1.titledata.title (T stands for the table yone passed to
showtables); and note how the tables of figures 2 and 3 are not
printed, because they follow the same pattern as table 1. (You can
tell showtable to print everything, natch.)

T.addto           : function: 0xa4c8818
T.analyze         : function: 0xb1c27b0
T.cached          : table: 0xb1c2240
T.cached.1 : table: 0xc3f7b18
T.cached.1.metadata   : table: 0xc3f7d58
T.cached.1.metadata.kind     : float
T.cached.1.metadata.name     : figure
T.cached.1.prefixdata : table: 0xc3f7c68
T.cached.1.prefixdata.connector : .
T.cached.1.prefixdata.prefix    : no
T.cached.1.references : table: 0xc3f7ba8
T.cached.1.references.reference : ref:asdf
T.cached.1.titledata  : table: 0xc3f7b40
T.cached.1.titledata.title : caption 1
T.cached.2 : table: 0xc467bb8 (like T.cached.1)
T.cached.3 : table: 0xc4731a8 (like T.cached.1)
T.cached.4 : table: 0xc47c988
T.cached.4.metadata   : table: 0xc47d628
T.cached.4.metadata.kind     : formula
T.cached.4.metadata.name     : formula

(You can't see it in this e-mail, but the colons of entries in the
same subtable nicely line up with each other.)

Usage: put showtable.lua in your working directory and run the following code:

\starttext
% \placefigure[][ref:asdf]{caption 1}{picture 1}
\startluacode
    require('showtable')
    userdata.showtable(structures.lists)
\stopluacode
\stoptext

Extra options can be passed as part of an options table. (This allows
overriding one option without respecifying the others.)
userdata.showtable(
    structures.lists,
    { everything=true, -- descend even into similar-looking siblings
    tablename='S.L' }
)

Output is printed to the terminal, alas, because I couldn't discover
how to print to the log. Anybody know anything about this?

Hopefully this may be useful to someone, next time they they're
hunting for something in the bowels of ConTeXt. Interesting tables to
look at:
* userdata.showtable(commands) contains a great miscellanea of helper commands
* userdata.showtable(context) also contains a great miscellanea of commands
* userdata.showtable(tex) seems to show lua access functions to some
plain tex stuff
* userdata.showtable(lxml) gives a list of lxml-related functions

Cheers,
Sietse

Attachment: showtable.lua
Description: Binary data

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to