[Dev-luatex] # => ## in \directlua

David Kastrup dak at gnu.org
Tue Oct 7 13:31:38 CEST 2008


"Jonathan Sauer" <Jonathan.Sauer at silverstroke.com> writes:

> take the following PlainTeX file:
>
> %&luatex
> \def\recatcode#1{%
> 	\directlua0{%
> 		tex.sprint('\luaescapestring{\unexpanded{#1}}')%
> 		texio.write_nl('\luaescapestring{\unexpanded{#1}}')%
> 	}%
> }
>
> \recatcode{%
> 	\def\test#1{`#1'}%
> }
>
> \bye
>
>
> This results in
>
> This is LuaTeX, Version snapshot-0.30.0-2008093018 (Web2C 7.5.7)
> (MacroParameterCharacter.tex
> \def \test ##1{`##1'}
> ! Parameters must be numbered consecutively.
> <to be read again> 
>                    ##
> l.1 \def \test ##
>                  1{`##1'}
> \recatcode ...uaescapestring {\unexpanded {#1}}')}
>                                                   
> l.12 }
>       
> ? x
> TeX interrupted.  No pages of output.
> Transcript written on MacroParameterCharacter.log.
>
>
> So `#' is transformed into `##' when passed from TeX to Lua.

No, when TeX prints.

> Is this a bug or a feature?

Feature.  Quite an annoying one in my opinion, but there you are.

-- 
David Kastrup


More information about the dev-luatex mailing list