ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Problem Passing \starttabulate into Lua
@ 2008-12-27 11:20 Tad Ashlock
  2008-12-28 22:33 ` Wolfgang Schuster
  2009-01-01 11:00 ` Wolfgang Schuster
  0 siblings, 2 replies; 7+ messages in thread
From: Tad Ashlock @ 2008-12-27 11:20 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-01-01 11:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-27 11:20 Problem Passing \starttabulate into Lua 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
2008-12-30  9:06       ` Wolfgang Schuster
2009-01-01 11:00 ` Wolfgang Schuster

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).