2

Scratching my head to compile this example in the mkiv manual (p57).

Example run: $ context file.tex.

Am I missing something??

%engine=luatex    
\setuphead[section][style=\bfa]
\setupbodyfontenvironment[default][em=italic]

\startluacode
local template = [[
path p, q ; color c[] ;
c1 := \MPcolor{darkblue} ;
c2 := \MPcolor{darkred} ;
p := fullcircle scaled 50 ;
l := length p ;
n := %s ;
q := subpath (0,%s/n*l) of p ;
draw q withcolor c2 withpen pencircle scaled 1 ;
fill fullcircle scaled 5 shifted point length q of q withcolor c1 ;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5) scaled 60 ;
draw boundingbox currentpicture withcolor c1 ;
currentpicture := currentpicture xsized(1cm) ;
]]
local function steps(n)
for i=0,n do
context.metafun.start()
context.metafun(template,n,i)
context.metafun.stop()
if i < n then
context.quad()
end
end
end
context.hbox(function() steps(10) end)
\stopluacode

Output:

tex error       > tex error on line 2 in file /Users/user/Desktop/coo/Untitled.tex: ! Argument of \meta_start_code_standard has an extra }

<inserted text> 
\par 
<to be read again> 
}
l.2 ...th p, q ; color c[] ;
    c1 := (0,0,0)white}
                                                   ;
    c2 := (0,0,0)black}...
<to be read again> 
}
l.4 }

}ontext.hbox(function() steps(10) end)

...
l.32 \stopluacode


 1     \setuphead[section][style=\bfa]
 2 >>  \setupbodyfontenvironment[default][em=italic]
 3     
 4     \startluacode
 5     local template = [[
 6         path p, q ; color c[] ;
 7         c1 := \MPcolor{white} ;
 8         c2 := \MPcolor{black} ;
 9         p := fullcircle scaled 50 ;
10         l := length p ;
11         n := %s ;
12         q := subpath (0,%s/n*l) of p ;

? 
  • 4
    It works if I add \starttext/\stoptext and change the colors to c1 := darkblue ; c2 := darkred ;. context seems not to like the \MPcolor there. (In the sources context uses a buffer here, probably this has different escaping conventions.) – Ulrike Fischer Dec 6 '18 at 15:31
  • @UlrikeFischer You were right the MPcolor does it! Vielen Dank! – Georges Dec 6 '18 at 16:21
  • 4
    The example (excluding the luacode environment and the other setups) works when you put it in a file with the extension cld. – Wolfgang Schuster Dec 6 '18 at 16:33
1

Converting Wolfgang's comment to an answer until he posts one himself:

The example (excluding the luacode environment and the other setups) works when you put it in a file with the extension cld.

You can also run ConTeXt in CLD mode using context yourfile.xyz --forcecld

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.