From 4619c6e66ef47e8e4953142a5c65467a6b0a2c01 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 30 Jul 2020 17:51:33 +0200 Subject: 2020-07-30 16:52:00 --- scripts/context/lua/mtx-interface.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'scripts') diff --git a/scripts/context/lua/mtx-interface.lua b/scripts/context/lua/mtx-interface.lua index 85ccb3ca0..0d3f05f7d 100644 --- a/scripts/context/lua/mtx-interface.lua +++ b/scripts/context/lua/mtx-interface.lua @@ -36,6 +36,7 @@ local helpinfo = [[ report commands to the console generate check file report the mening of commands + show the internal representation of commands replace named characters by utf @@ -690,6 +691,26 @@ function scripts.interface.meaning() end end +function scripts.interface.tokens() + local runner = "mtxrun --silent --script context --extra=meaning --tokens --once --noconsole --nostatistics" + local pattern = environment.arguments.pattern + local files = environment.files + if type(pattern) == "string" then + runner = runner .. ' --pattern="' .. pattern .. '"' + elseif files and #files > 0 then + for i=1,#files do + runner = runner .. ' "' .. files[i] .. '"' + end + else + return + end + local r = os.resultof(runner) + if type(r) == "string" then + r = gsub(r,"^.-(tokens%s+>)","\n%1") + print(r) + end +end + local ea = environment.argument if ea("mkii") then @@ -698,6 +719,8 @@ elseif ea("preprocess") then scripts.interface.preprocess() elseif ea("meaning") then scripts.interface.meaning() +elseif ea("tokens") then + scripts.interface.tokens() elseif ea("toutf") then scripts.interface.toutf() elseif ea("bidi") then -- cgit v1.2.3