[luatex] Cannot register callback in \everymath
Henri Menke
henrimenke at gmail.com
Thu Apr 19 23:49:01 CEST 2018
Dear list,
It seems as if callbacks are not registered if I'm doing it inside \everymath.
The idea is to have a callback in "process_input_buffer", which only acts in
math mode. To have that semi-automatically, I wanted to register it in
\everymath and deregister after math mode using \aftergroup. However, the
callback is simply ignored in that constellation. MWE is below.
Cheers, Henri
---
\begingroup
\catcode`\%=12
\let\\=\relax
\directlua{
function smartlig ( s )
s = s:gsub ( "%->", "\\rightarrow " )
s = s:gsub ( "<%-", "\\leftarrow " )
return s
end
}
\endgroup
\def\SmartligOn{\directlua{callback.register("process_input_buffer", smartlig)}}
\def\SmartligOff{\directlua{callback.register("process_input_buffer", false)}}
\everymath{\SmartligOn\aftergroup\SmartligOff}
$a->b$, $c<-d$
\SmartligOn
$a->b$, $c<-d$
\SmartligOff
$a->b$, $c<-d$
\bye
More information about the luatex
mailing list