ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Exploring the Lua innards of ConTeXt: showtable
Date: Mon, 17 Sep 2012 18:45:08 +0200	[thread overview]
Message-ID: <50575394.6080705@wxs.nl> (raw)
In-Reply-To: <CAF=dkzxOCtxsBGiaHqUk-=idQWCp9s__8mPx3kaCgO_gEk3M9Q@mail.gmail.com>

On 17-9-2012 17:47, Sietse Brouwer wrote:
> 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.

Keep in mind that many datatables are not frozen in stone i.e. their 
structure might change at some point (I still need to finish cleaning up 
some structure related code, after that most will stay as it is).

In case you don't this one:

context s-inf-03.mkiv

It reports some info about what sits in a table (d means data).

> 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?

commands.writestatus("mylog",str)

or:

local myreporter = logs.reporter("tables")

myreporter(....)

> 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

the commands namespace is used for commands that pipe something to tex 
and/or are calles in a command at the tex end

> * userdata.showtable(context) also contains a great miscellanea of commands

this is the print-to-tex namespace

> * 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
>
>
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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	other threads:[~2012-09-17 16:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17 15:47 Sietse Brouwer
2012-09-17 16:45 ` Hans Hagen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50575394.6080705@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).