[NTG-context] lua and brackets

Martin Fechner fechner at bbaw.de
Thu Nov 3 15:10:15 CET 2011


> And if you want pure lua, you can do:
>
> \startluacode
> function document.pagesetup(ref_one,ref_two)
> local one, bug = structures.references.identify("",ref_one)
> if bug then
> context("[unknown reference: %s]",ref_one)
> return
> end
> local two, bug = structures.references.identify("",ref_two)
> if bug then
> context("[unknown reference: %s]",ref_two)
> return
> end
> structures.references.analyze(one)
> structures.references.analyze(two)
> local r_one = one.realpage
> local r_two = two.realpage
> if not r_one or not r_two then
> context("[unknown pagenumbers]")
> elseif r_one == r_two then
> context("[same pagenumbers]")
> else
> context("[different pagenumbers]")
> end
> end
> \stopluacode
>
> \ctxlua{document.pagesetup("one","two")}
> \ctxlua{document.pagesetup("one","two-a")}
> \ctxlua{document.pagesetup("two-a","two-b")}
>
> but the reference interface is not yet documented
>

Thanks, the lua solution works fine. One question: is the same possible 
with linereferences as with pagereferences? It's very important for the 
critical edition project I'm working at.

Greetings, Martin


More information about the ntg-context mailing list