<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Le 18/03/2011 17:22, Ulrike Fischer a écrit :
<blockquote cite="mid:85z3mgd2v08m$.dlg@nililand.de" type="cite">
<pre wrap="">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}
</pre>
</blockquote>
<br>
<br>
I'd say use a real table in Lua, and traverse it, but you're
probably using strings for some good reason, hence:<br>
<br>
\begin{luacode}<br>
<br>
local eol = [[<br>
<br>
]]<br>
<br>
function remove_eol (str)<br>
str = str:gsub(eol, "")<br>
return str<br>
end<br>
<br>
\end{luacode}<br>
<br>
Then use remove_eol() in the tex.sprint() statement. (Defining "eol"
with <i>two</i> lines is necessary because the first end-of-line
isn't taken into account if there is no character before.)<br>
<br>
Best,<br>
Paul<br>
</body>
</html>