From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Problem Passing \starttabulate into Lua
Date: Mon, 29 Dec 2008 14:28:49 +0100 [thread overview]
Message-ID: <F1163D1E-F1AD-4E63-BCBE-F54E295C4957@gmail.com> (raw)
In-Reply-To: <68E5AC30CE6FA94DB0C3B4E3294B5D3103754222EA@ES01SNLNT.srn.sandia.gov>
Am 29.12.2008 um 13:56 schrieb Ashlock, Tad A:
> On 2008-12-28 at 15:33, Wolfgang Schuster wrote:
>> Am 27.12.2008 um 12:20 schrieb Tad Ashlock:
>>> I'm trying to create a ConTeXt macro (mkiv) that will manipulate the
>>> macro argument's text with Lua and then feed it back into ConTeXt
>>> with tex.print(). My approach worked correctly until I called the
>>> macro with \starttabulate ... \stoptabulate in the macro's
>>> argument. So I started reducing the problem down to a minimum
>>> example which surprisingly turned out to have nothing to do with the
>>> manipulations I was performing.
> [snip]
>>
>> \def\testmacro
>> {\bgroup
>> \catcode`\\=12
>> \dotestmacro}
>>
>> \def\dotestmacro#1
>> {\ctxlua{d='\luaescapestring{#1}'}%
>> \egroup}
>>
>> \starttext
>>
>> \testmacro{\starttabulate \NC text \NC text \NC\NR \stoptabulate}
>>
>> %\ctxlua{tex.sprint(d)}
>>
>> \stoptext
>>
>> Wolfgang
>
> Thank you Wolfgang! That's certainly a step in the right
> direction. But what I (and others?) really need is a way of passing
> any chunk of ConTeXt code into Lua.
Everything you pass to Lua is expanded and this did not work
with macros that contain \dosingleempty (or \dodoubleempty etc.).
\def\command
{\dosingleempty\docommand}
\def\docommand[#1]{#1}
\def\testmacro#1%
{\ctxlua{d='\luaescapestring{#1}'}}
\starttext
\testmacro{\docommand[text]} % works
\testmacro{\command[text]} % fails
\stoptext
> When I changed '\starttabulate' to '\starttabulate[|l|p|]' in your
> solution above, it broke.
Try to escape the |, it's a active character in ConTeXt but this
could work (untested):
\def\testmacro
{\bgroup
\catcode`\\=12
\catcode`\|=12
\dotestmacro}
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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2008-12-29 13:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-27 11:20 Tad Ashlock
2008-12-28 22:33 ` Wolfgang Schuster
2008-12-29 12:56 ` Ashlock, Tad A
2008-12-29 13:14 ` luigi scarso
2008-12-29 13:28 ` Wolfgang Schuster [this message]
2008-12-30 9:06 ` Wolfgang Schuster
2009-01-01 11:00 ` Wolfgang Schuster
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=F1163D1E-F1AD-4E63-BCBE-F54E295C4957@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).