[luatex] Line breaks

Dirk Laurie dpl at sun.ac.za
Sat Feb 19 13:42:06 CET 2011


On Sat, Feb 19, 2011 at 01:25:47PM +0200, Paul Isambert wrote:
> 
> Which confirms something I'd been suspecting for a while but never 
> really investigated: blank lines aren't turned into \par in \directlua, 
> as they are anywhere else (including whatsits). I guess that's a 
> feature, so you can have blank lines in your Lua code, but in that case 
> it's not what's intended.
> 
And if I save those exerpts as 

% file ex1.tex 
This is a paragraph
with some lines.
 
This is another paragraph,
separated from the first
by a blank line.
% end file

-- file ex2.lua
text = [[
This is a paragraph
with some lines.

This is another paragraph,
separated from the first
by a blank line. ]]
tex.print(text)
-- end file

then the result of lualatex on

% 
\documentclass{article}
\begin{document}
\input{ex1.tex}

\directlua{ dofile "ex2.lua" }
\end{document}
%

gives results that look even more different: the newlines in the
ex2.lua version are set by lualatex beta-0.50.0-2010010503 as 
capital Omega.  I also tried beta-0.65.0-2010121316, same story.

Thus the error seems to be due to a font/locale difference, which 
I do not understand.

I'm working around the problem as follows:

function linefix(a)
    a=string.gsub(a,"\n%s*\n+","\\par ")
    return string.gsub(a,"\n",' ')
    return a
    end

then strings that may contain newlines, especially
blank paragraph separators, are filtered through linefix.

Dirk



More information about the luatex mailing list