ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Tad Ashlock <taashlo@cyberdude.com>
To: ntg-context@ntg.nl
Subject: Problem Passing \starttabulate into Lua
Date: Sat, 27 Dec 2008 04:20:35 -0700	[thread overview]
Message-ID: <49560F83.3080706@cyberdude.com> (raw)

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.

Here is the working example (without \starttabulate):

\long\def\testmacro#1{\directlua0{d='\luaescapestring{#1}'}}
\starttext
Hello, world!
\testmacro{%
    testing}
\stoptext


Here is the broken example:

\long\def\testmacro#1{\directlua0{d='\luaescapestring{#1}'}}
\starttext
Hello, world!
\testmacro{%
    testing
    \starttabulate
      \NC 0 \NC testing tabulate. \NC \NR
    \stoptabulate}
\stoptext

Here's the output:
=====================================
MtxRun | loading configuration for C:/context/tex/texmf/web2c from 
C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/trees/53ad5f8b88994bdd02baa17501789699
MtxRun | run 1: luatex 
--fmt="C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/formats/cont-en" 
--lua="C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/formats/cont-en.lua" 
"./test.tex"
(test.tex

ConTeXt  ver: 2008.10.31 13:58 MKIV  fmt: 2008.12.24  int: english/english

language       : language en is active
system         : cont-new loaded
(C:/context/tex/texmf-context/tex/context/base/cont-new.tex
systems         : beware: some patches loaded from cont-new.tex
(C:/context/tex/texmf-context/tex/context/base/cont-new.mkiv) 
(C:/context/tex/texmf-context/tex/context/base/cont-mtx.tex))
system         : cont-fil loaded
(C:/context/tex/texmf-context/tex/context/base/cont-fil.tex
loading        : Context File Synonyms
)
system         : cont-sys.rme loaded
(C:/context/tex/texmf-context/tex/context/user/cont-sys.rme 
(C:/context/tex/texmf-context/tex/context/base/type-tmf.tex) 
(C:/context/tex/texmf-context/tex/context/base/type-siz.tex) 
(C:/context/tex/texmf-context/tex/context/base/type-otf.tex))
bodyfont       : 12pt rm is loaded
specials       : pdftex loaded
system         : test.top loaded
(test.top) (test.tuo) (test.tuo)
systems        : begin file test at line 2
! Argument of \dodoubletestempty has an extra }.
<inserted text>
                \par
<to be read again>
                   }
\doifnextcharelse ...token =#1\def \!!stringa {#2}
                                                  \def \!!stringb 
{#3}\futur...
<argument> testing \starttabulate
                                  \NC 0 \NC testing tabulate. \NC \NR 
\stopt...
\testmacro ...\directlua 0{d='\luaescapestring {#1
                                                  }'}
l.8     \stoptabulate}

?
=====================================

I've tried all sorts of variations on the above example including using 
\ctxlua, \startlua, \startluacode, etc.  I tried using '[[...]]' and 
'[===[...]===]' instead of \luaescapestring.  I tried \def with and 
without \long.  I tried other \start* ... \stop* commands (different 
errors, but still broken).  Plus many more variations.

At this point I'm convinced that there's something fundamental that I'm 
not understanding.  What is the general method for taking any chunk of 
ConTeXt code and passing it into Lua so that it can be written back out 
with tex.print()?

Info: running on Windows XP, SP3 -- ConTeXt: 2008.10.31 -- LuaTeX, 
Version snapshot-0.31.2-2008121200, build 1659

(The older versions of ConTeXt and LuaTeX are necessary because of the 
problem the latest Windows versions are having.  See the "Serious Bug?" 
thread.)

Thank you,
Tad Ashlock




___________________________________________________________________________________
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
___________________________________________________________________________________


             reply	other threads:[~2008-12-27 11:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-27 11:20 Tad Ashlock [this message]
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
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=49560F83.3080706@cyberdude.com \
    --to=taashlo@cyberdude.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).