summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luakeys/luakeys-debug.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-09-20 03:02:23 +0000
committerNorbert Preining <norbert@preining.info>2021-09-20 03:02:23 +0000
commitc9fcf97bc045a9d020980c33b6c7c1ee5aedef99 (patch)
treebf74a43623e081cad4b72a752730aeff86b7c5cf /macros/luatex/generic/luakeys/luakeys-debug.tex
parent996c9b239bde82dc3ef3e5b69cd525e87fdb61a8 (diff)
CTAN sync 202109200302
Diffstat (limited to 'macros/luatex/generic/luakeys/luakeys-debug.tex')
-rw-r--r--macros/luatex/generic/luakeys/luakeys-debug.tex35
1 files changed, 32 insertions, 3 deletions
diff --git a/macros/luatex/generic/luakeys/luakeys-debug.tex b/macros/luatex/generic/luakeys/luakeys-debug.tex
index 499b1305f6..b63e67e050 100644
--- a/macros/luatex/generic/luakeys/luakeys-debug.tex
+++ b/macros/luatex/generic/luakeys/luakeys-debug.tex
@@ -20,14 +20,43 @@
luakeys = require('luakeys')
}
-\def\luakeysdebug#1{
+% https://tex.stackexchange.com/a/418401/42311
+\catcode`\@=11
+\long\def\LuaKeysIfNextChar#1#2#3{%
+ \let\@tmpa=#1%
+ \def\@tmpb{#2}%
+ \def\@tmpc{#3}%
+ \futurelet\@future\LuaKeysIfNextChar@i%
+}%
+\def\LuaKeysIfNextChar@i{%
+ \ifx\@tmpa\@future%
+ \expandafter\@tmpb
+ \else
+ \expandafter\@tmpc
+ \fi
+}%
+\def\luakeysdebug@parse@options#1{
+ \directlua{
+ luakeys.save('debug_options', luakeys.parse('#1'))
+ }
+}%
+\def\luakeysdebug@output#1{
{
\tt
\parindent=0pt
\directlua{
- local result = luakeys.parse('#1')
+ local result = luakeys.parse('\luaescapestring{\unexpanded{#1}}', luakeys.get('debug_options'))
tex.print(luakeys.stringify(result, true))
luakeys.print(result)
}
}
-}
+}%
+\def\luakeysdebug@oarg[#1]#2{%
+ \luakeysdebug@parse@options{#1}%
+ \luakeysdebug@output{#2}%
+}%
+\def\luakeysdebug@marg#1{%
+ \luakeysdebug@output{#1}%
+}%
+\def\luakeysdebug{\LuaKeysIfNextChar[{\luakeysdebug@oarg}{\luakeysdebug@marg}}%
+\catcode`\@=12