[luatex] newlines in key-value list

Paul Isambert zappathustra at free.fr
Fri Mar 18 20:26:49 CET 2011


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, hence:

\begin{luacode}

local eol = [[

]]

function remove_eol (str)
     str = str:gsub(eol, "")
     return str
end

\end{luacode}

Then use remove_eol() in the tex.sprint() statement. (Defining "eol" 
with /two/ lines is necessary because the first end-of-line isn't taken 
into account if there is no character before.)

Best,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/luatex/attachments/20110318/4bce1b56/attachment.html>


More information about the luatex mailing list