[luatex] newlines in key-value list

Ulrike Fischer luatex at nililand.de
Sat Mar 19 18:04:25 CET 2011

Am Fri, 18 Mar 2011 20:26:49 +0100 schrieb Paul Isambert:

> Le 18/03/2011 17:22, Ulrike Fischer a écrit :
>> In the following example using the variable A to get a key val list
>> gives and error (` color` not a key). Obviously because of the
>> newline in the string definition (B works fine). How can I avoid it?
>> \documentclass{scrartcl}
>> \usepackage{chessboard}
>> \usepackage{luacode}
>> \begin{document}
>> \begin{luacode}
>> A=[[color=green,
>>      color=red]]
>> B=[[color=green, color=red]]
>> \end{luacode}
>> \chessboard[\directlua{tex.sprint(A)}]
>> \chessboard[\directlua{tex.sprint(B)}]
>> \end{document}
> I'd say use a real table in Lua, and traverse it, but you're probably 
> using strings for some good reason, 

Actually I do have a real table. And some of the entries are
key-val-combinations I wanted to test. And I use [[..]] to avoid to
long lines.

Meanwhile I have understood what's going on: lua use newline (\n,
^^J) at the end of the lines. ^^J has catcode 12 (and when printed
(using OT1-encoding) gives the Omega mentioned the line break
discussion some weeks ago).

I would get the same problem with A=[[text \n text]], while A=[[text
\r text]] would work fine. 

So I think the best is to change the catcode of ^^J when I want to
use such strings:




\catcode`\^^J=10 %

\catcode`\^^J=\active %



A="color=green,\n addpieces=Ke1"






Ulrike Fischer 

More information about the luatex mailing list