* \placelist summary alternative solution
@ 2011-12-14 16:50 Felix Ingram
2011-12-14 22:00 ` Hans Hagen
0 siblings, 1 reply; 2+ messages in thread
From: Felix Ingram @ 2011-12-14 16:50 UTC (permalink / raw)
To: mailing list for ConTeXt users
I've ended up delving into the dark art that is Lua for this solution:
\define[0]\SummaryTable{%
\placetable[force, none]{}{%
\setupTABLE[frame=off]
\bTABLE
\bTABLEhead
\bTR\bTH Reference\eTH\bTH Title\eTH\bTH Page\eTH\eTR
\eTABLEhead
\bTABLEbody
\startluacode
for k, v in ipairs(structures.lists.collected) do
if v.metadata.kind == "section" and v.metadata.name == "section" then
context.bTR()
context.bTD()
context("REFREF")
context.eTD()
context.bTD()
context(v.titledata.title)
context.eTD()
context.bTD()
context(v.references.realpage)
context.eTD()
context.eTR()
end
end
\stopluacode%
\eTABLEbody
\eTABLE
}%
}%
\starttext
\section{Test}
\input{knuth}
\section{Test}
\input{knuth}
\section{Test}
\input{knuth}
\section{Test}
\input{knuth}
\section{Test}
\input{knuth}
\section{Test}
\input{knuth}
\section{Test}
\input{knuth}
\SummaryTable
\stoptext
This works to some degree though I have the following questions about it:
1. Is there a way to access a document global variable from Lua? I
will use this to replace the REFREF text.
2. v.references.realpage isn't the actual page of the title. How can I
access the page number that would have appeared in the ToC? (I've
restarted the page numbering in my master doc, the above example works
fine)
3. Is there a way to store some metadata along with my title? I'd like
something similar to this:
\myheader[author=me, date=2011-12-14]{This is my header with meta-data}
and then be able to access it from Lua again.
Thanks for any help you can give with this.
Felix
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: \placelist summary alternative solution
2011-12-14 16:50 \placelist summary alternative solution Felix Ingram
@ 2011-12-14 22:00 ` Hans Hagen
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2011-12-14 22:00 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Felix Ingram
On 14-12-2011 17:50, Felix Ingram wrote:
> I've ended up delving into the dark art that is Lua for this solution:
>
> \define[0]\SummaryTable{%
> \placetable[force, none]{}{%
> \setupTABLE[frame=off]
> \bTABLE
> \bTABLEhead
> \bTR\bTH Reference\eTH\bTH Title\eTH\bTH Page\eTH\eTR
> \eTABLEhead
> \bTABLEbody
> \startluacode
> for k, v in ipairs(structures.lists.collected) do
> if v.metadata.kind == "section" and v.metadata.name == "section" then
> context.bTR()
> context.bTD()
> context("REFREF")
> context.eTD()
> context.bTD()
> context(v.titledata.title)
> context.eTD()
> context.bTD()
> context(v.references.realpage)
> context.eTD()
> context.eTR()
> end
> end
> \stopluacode%
> \eTABLEbody
> \eTABLE
> }%
> }%
> \starttext
> \section{Test}
> \input{knuth}
> \section{Test}
> \input{knuth}
> \section{Test}
> \input{knuth}
> \section{Test}
> \input{knuth}
> \section{Test}
> \input{knuth}
> \section{Test}
> \input{knuth}
> \section{Test}
> \input{knuth}
> \SummaryTable
> \stoptext
>
> This works to some degree though I have the following questions about it:
>
> 1. Is there a way to access a document global variable from Lua? I
> will use this to replace the REFREF text.
\startluacode
document.myvariables = { }
document.myvariables.whatever = "SOME TEXT"
\stopluacode
...
context(document.myvariables.whatever)
> 2. v.references.realpage isn't the actual page of the title. How can I
> access the page number that would have appeared in the ToC? (I've
> restarted the page numbering in my master doc, the above example works
> fine)
as you're looking into the code ... search for helpers like
lists.prefixedpage
keep in mind that this is not yet an official api (although it will
probably stay this way)
> 3. Is there a way to store some metadata along with my title? I'd like
> something similar to this:
> \myheader[author=me, date=2011-12-14]{This is my header with meta-data}
> and then be able to access it from Lua again.
it's called userdata (third argument to \startchapter etc) .. it travels
with the rest
Hans
-----------------------------------------------------------------
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-14 22:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-14 16:50 \placelist summary alternative solution Felix Ingram
2011-12-14 22:00 ` Hans Hagen
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).