I'm trying to issue TeX warnings from within \directlua with accurate line numbers (pointing to the offending line in the .tex document).
When I compile the MWE below with lualatex, \TestTex issues a warning that correctly points to line 40. However, \TestLua and \TestLuaIndirect both issue warnings pointomg to line 1.
Any help would be much appreciated. Thank you!
\documentclass{article}
\ExplSyntaxOn
\msg_new:nnn { test } { test-warning } { #1 ~ \msg_line_context: }
\NewDocumentCommand { \TestTex } { }
{
\ExplSyntaxOn
\msg_warning:nnn { test } { test-warning } { tex ~ warning }
\ExplSyntaxOff
}
\NewDocumentCommand { \TestLua } { }
{
\directlua
{
tex.sprint('\ExplSyntaxOn'
.. '\msg_warning:nnn { test } { test-warning }'
.. '{ lua ~ warning }'
.. '\ExplSyntaxOff')
}
}
\NewDocumentCommand { \TestLuaIndirect } { }
{
\directlua
{
tex.sprint('\TestTex')
}
}
\ExplSyntaxOff
\begin{document}
Test.
\TestTex
\TestLua
\TestLuaIndirect
\end{document}
luatexbase.module_warning(module_name, message)instead. – Max Chernoff Apr 02 '23 at 05:33