[NTG-context] Typing within doifmode leads to error

Christoph Reller christoph.reller at gmail.com
Sun Mar 21 15:44:00 CET 2021


On Sat, Mar 20, 2021 at 6:07 PM Hans Hagen <j.hagen at xs4all.nl> wrote:

> On 3/20/2021 4:00 PM, Christoph Reller wrote:
> > On Sat, Mar 20, 2021 at 12:12 PM Hans Hagen <j.hagen at xs4all.nl
> > <mailto:j.hagen at xs4all.nl>> wrote:
> >
> >     On 3/20/2021 8:24 AM, Aditya Mahajan wrote:
> >      > On Sat, 20 Mar 2021, Christoph Reller wrote:
> >      >> Of course we can do this in lua:
> >      >>
> >      >> if tex.modes["A"] and not tex.modes{"B"] then
> >      >> ...
> >      >> end
> >      >
> >      > ... which means that you can use that at the context end as well
> >     (old feature).
> >      > Save the following as test.mkix (or add "% macros=mkix" as the
> >     first line):
> >      >
> >      > ```
> >      > \starttext
> >      > <?lua if tex.modes["A"] and not tex.modes["B"] then ?>
> >      > \starttyping
> >      > A and not B
> >      > \stoptyping
> >      > <?lua else ?>
> >      > \starttyping
> >      > not (A and not B)
> >      > \stoptyping
> >      > <?lua end ?>
> >      > \stoptext
> >     a neat application!
> >
> >
> > Thank you for this hint, Aditya. This would be a very nice solution
> > indeed. But it does not seem to work:
> >
> > % macros=mkix
> > \definemode[A][yes]
> > \starttext
> > \startluacode
> >    if tex.modes['A'] then
> >      context("A")
> >    end
> > \stopluacode
> > <?lua if tex.modes['A'] then ?>
> > A
> > <?lua end ?>
> > \stoptext
> >
> > With ConTeXt LMTX 2021.03.17 the output of the above is a single "A". I
> > would expect two. What am I doing wrong?
>
> When the file gets preprocessed the mode is not known
>
> context --mode=A foo.tex
>
> it does of course also work when you set the mode in a parent file and
> then include foo.tex


For me this is good enough, because I define modes always in top-level
files or in modules. Thank you!

Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20210321/23950a76/attachment.htm>


More information about the ntg-context mailing list