[Dev-luatex] [PATCH] Allow literal # in argument text by escaping

Marcel Fabian Krüger tex at 2krueger.de
Sun May 26 15:20:05 CEST 2019


inspired by [a recent TeX.sx question][1] this allows delimited macros
with `#` in the parameter text by doubling the `#`.
It isn't needed that often but it is useful if you try to analyze the
parameter text of a TeX macro using TeX code. Also it is completely
backward-compatible (`##` always triggers an error without this) and
it is very easy to implement.

For example:

\test hello#{world}

would result in (hello)[world]

Best regards,
Marcel Krüger

1: https://tex.stackexchange.com/questions/491296/can-i-have-a-delimited-macro-with-a-literal-in-the-parameter-text
 source/texk/web2c/luatexdir/tex/scanning.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source/texk/web2c/luatexdir/tex/scanning.c b/source/texk/web2c/luatexdir/tex/scanning.c
index 8f7e1d591..e8b9fca66 100644
--- a/source/texk/web2c/luatexdir/tex/scanning.c
+++ b/source/texk/web2c/luatexdir/tex/scanning.c
@@ -2095,7 +2095,8 @@ halfword scan_toks(boolean macro_def, boolean xpand)
                     goto DONE;
-                if (t == nine_token) {
+                if (cur_cmd == mac_param_cmd) {
+                } else if (t == nine_token) {
                     print_err("You already have nine parameters");
                     help1("I'm going to ignore the # sign you just used.");

More information about the dev-luatex mailing list