On Sat, Feb 19, 2011 at 12:25:47PM +0100, Paul Isambert wrote:
Le 19/02/2011 12:12, Dirk Laurie a écrit :
The following are not equivalent on my system (texlive, ubuntu lucid):
% excerpt from TeX file This is a paragraph with some lines.
This is another paragraph, separated from the first by a blank line. % end excerpt
% another excerpt \directlua{ text = [[ This is a paragraph with some lines.
This is another paragraph, separated from the first by a blank line. ]] tex.print(text)} % end excerpt
The second excerpt sets as a single paragraph.
Which confirms something I'd been suspecting for a while but never really investigated: blank lines aren't turned into \par in \directlua,
No, the conversion is done by TeX, \directlua sees the \par then. But tex.print removes the \par, perhaps because of | Each string argument is treated by TEX as a separate input line. Also interesting: | The very last string of the very last tex.print() command in a | \directlua will not have the \endlinechar appended, all others do. But a statement about \par filtering of tex.print() would be useful for the documentation. Minimal example (luatex --ini): \catcode`\{=1 \catcode`\}=2 \expandafter\def\expandafter\x\expandafter{% \directlua{tex.print('a \par b')}% }\show\x \csname @@end\endcsname\end Result: "a b" Yours sincerely Heiko Oberdiek
Le 19/02/2011 13:38, Heiko Oberdiek a écrit :
On Sat, Feb 19, 2011 at 12:25:47PM +0100, Paul Isambert wrote:
Le 19/02/2011 12:12, Dirk Laurie a écrit :
The following are not equivalent on my system (texlive, ubuntu lucid):
% excerpt from TeX file This is a paragraph with some lines.
This is another paragraph, separated from the first by a blank line. % end excerpt
% another excerpt \directlua{ text = [[ This is a paragraph with some lines.
This is another paragraph, separated from the first by a blank line. ]] tex.print(text)} % end excerpt
The second excerpt sets as a single paragraph. Which confirms something I'd been suspecting for a while but never really investigated: blank lines aren't turned into \par in \directlua, No, the conversion is done by TeX, \directlua sees the \par then.
Then \directlua{ foo = 1} should be read as "\parfoo=1", and it isn't. Or is there something I'm missing? Paul
On Sat, Feb 19, 2011 at 01:41:30PM +0100, Paul Isambert wrote:
No, the conversion is done by TeX, \directlua sees the \par then.
Then
\directlua{
foo = 1}
should be read as "\parfoo=1", and it isn't. Or is there something I'm missing?
Yes, you example and some testing shows, that it isn't tex.print, but \directlua seems to remove \par if it has its original meaning. \def\par{bar} \directlua{ foo = 1} Then Lua sees "barfoo = 1". Something like the following should fix the OP's problem: \begingroup \def\par{\endgraf} \directlua{ text = [[ This is a paragraph with some lines. This is another paragraph, separated from the first by a blank line. ]] tex.print(text) } \endgroup Yours sincerely Heiko Oberdiek
Le 19/02/2011 14:05, Heiko Oberdiek a écrit :
On Sat, Feb 19, 2011 at 01:41:30PM +0100, Paul Isambert wrote:
No, the conversion is done by TeX, \directlua sees the \par then. Then
\directlua{
foo = 1}
should be read as "\parfoo=1", and it isn't. Or is there something I'm missing? Yes, you example and some testing shows, that it isn't tex.print, but \directlua seems to remove \par if it has its original meaning.
So I guess it's definitely a feature (quite useful), not a bug. But that should be mentioned in the manual. Best, Paul
Heiko said: Yes, you example and some testing shows, that it isn't tex.print, but \directlua seems to remove \par if it has its original meaning. \def\par{bar} \directlua{ foo = 1} Then Lua sees "barfoo = 1". Actually, have I just noticed, \par is removed if it is unexpandable, whatever its definition: \bgroup \protected\def\par{par} \directlua{texio.write_nl("foo\par")} \egroup prints "foo". And it is a feature, Taco says. Best, Paul
participants (2)
-
Heiko Oberdiek
-
Paul Isambert