ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Problem calling Lua during \startsetups
Date: Tue, 25 Jan 2011 09:34:43 +0100	[thread overview]
Message-ID: <687AABEF-5154-45F8-B703-551F6D934642@gmail.com> (raw)
In-Reply-To: <op.vputvws9wshuv7@lpr>


Am 25.01.2011 um 09:00 schrieb Procházka Lukáš Ing. - Pontex s. r. o.:

> Thank you, Wolfgang, this works better.
> 
> Actually I need to use '%' in the condition and that fails:
> 
> ---
> ...
> \startrawsetups layer
>  % The value of 'n' is used here to set the appropriate background,
>  % = n-th page of a PDF, and also to draw a filled rectangle on
>  % the left or right side (depending on whether n is even or odd)
> 
>  % The code bellow fails
> 
>  \startluacode
>    print("N=", n)
> 
>    if n % 2 == 1 then
> 
>    else
> 
>    end
>  \stopluacode
> \stoprawsetups
> ...
> ---
> 
> with:
> 
> ---
> ! LuaTeX error <main ctx instance>:1: 'then' expected near 'else'.
> ---
> 
> So like '%' was still treated as TeX comment char.
> 
> How to enable '%'?

You can’t use % in the luacode environment when you write it inside
of another environment because TeX can change the meaning of % but
this should works (untested):

\startbuffer[lualayer]

% …

\startluacode
…
\stopluacode
\stopbuffer

\doifmode{foo}{\ctxluabuffer[lualayer]}

Wolfgang

___________________________________________________________________________________
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:[~2011-01-25  8:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25  7:33 Procházka Lukáš Ing. - Pontex s. r. o.
2011-01-25  7:44 ` Wolfgang Schuster
2011-01-25  8:00   ` Procházka Lukáš Ing. - Pontex s. r. o.
2011-01-25  8:34     ` Wolfgang Schuster [this message]
2011-01-25  8:33   ` Hans Hagen
2011-01-25 13:01     ` Procházka Lukáš Ing. - Pontex s. r. o.

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=687AABEF-5154-45F8-B703-551F6D934642@gmail.com \
    --to=schuster.wolfgang@googlemail.com \
    --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).