ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Typing within doifmode leads to error
Date: Sat, 20 Mar 2021 17:03:31 -0400 (EDT)	[thread overview]
Message-ID: <nycvar.YAK.7.78.908.2103201658450.819312@nqv-guvaxcnq> (raw)
In-Reply-To: <3be66a8e-15b0-148c-7a41-0ad1aa56aab9@xs4all.nl>

On Sat, 20 Mar 2021, Hans Hagen wrote:

> > 
> > I wonder if we could have an environment, say \startluatemplate ...
> > \stopluatemplate, which is evaluated on the fly rather than when loading a
> > file.
> 
> define 'evaluated on the fly'

Consider the following example:

\enablemode[A]
\starttext
\startluatemplate
  <?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 ?>
\stopluatemplate
\stoptext

What I am thinking is that \startluatemplate ... \stopluatemplate grabs the content (like a buffer) and then processes it using the mkix conversion mechanism. Thus, in terms of output, it should be equivalent to:

\enablemode[A]
\starttext
\startbuffer[luatemplate]
  <?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 ?>
\stopbuffer
\savebuffer[file={\jobname-luatemplate.mkix}, list={luatemplate}]
\input \jobname-luatemplate.mkix
\stoptext

but without the need to save to an external file. 

Aditya
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2021-03-20 21:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19  3:58 Christoph Reller
2021-03-19  4:37 ` Aditya Mahajan
2021-03-19  6:59   ` Christoph Reller
2021-03-19  8:49 ` Hans Hagen
2021-03-20  5:24   ` Christoph Reller
2021-03-20  7:24     ` Aditya Mahajan
2021-03-20 11:11       ` Hans Hagen
2021-03-20 15:00         ` Christoph Reller
2021-03-20 17:07           ` Hans Hagen
2021-03-20 20:23             ` Aditya Mahajan
2021-03-20 20:49               ` Hans Hagen
2021-03-20 21:03                 ` Aditya Mahajan [this message]
2021-03-21  1:43                   ` Hans Hagen
2021-03-21  2:40                     ` Aditya Mahajan
2021-03-21 14:44             ` Christoph Reller

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=nycvar.YAK.7.78.908.2103201658450.819312@nqv-guvaxcnq \
    --to=adityam@umich.edu \
    --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).