Buffer and \input content as input for \processtokens, etc.
Hi, list! My question is just like that: how do I pass buffers or \input content to \processtokens. What I have done so far: \tolerant\protected\def\foo#={\ifparameter#1\or\oof{#1}\fi} \protected\def\oof#1{<#1>} \startbuffer[ofo] % Output: Th<i>s <is> not a <question> anymore! Th{i{s {is} not a {question} anymore! \stopbuffer \starttext \processtokens\foo\foo\relax\space{Th{i}s {is} not a {question} anymore!} % Neither \inlinebuffer nor \rawbuffer work in the example above \stoptext I've also tried a variant of the mechanism described in OPmac trick described here https://petr.olsak.net/opmac-tricks-e.html#etoks to process content token by token, but it only works with \normalinput. Any suggestions or guidance? Thank you in advance. Best regards, Jairo
On 12/6/2023 8:26 PM, Jairo A. del Rio wrote:
Hi, list! My question is just like that: how do I pass buffers or \input content to \processtokens. What I have done so far:
\tolerant\protected\def\foo#={\ifparameter#1\or\oof{#1}\fi} \protected\def\oof#1{<#1>} \startbuffer[ofo] % Output: Th<i>s <is> not a <question> anymore! Th{i{s {is} not a {question} anymore! \stopbuffer \starttext \processtokens\foo\foo\relax\space{Th{i}s {is} not a {question} anymore!} % Neither \inlinebuffer nor \rawbuffer work in the example above \stoptext
I didn't try to decipher this (you probably need expansion someplace),
I've also tried a variant of the mechanism described in OPmac trick described here https://petr.olsak.net/opmac-tricks-e.html#etoks to process content token by token, but it only works with \normalinput. Any suggestions or guidance? Thank you in advance. \starttext
% \doloopovermatch % {(.-)(\letterpercent b\letterleftbrace\letterrightbrace)(.-)} % {Th{i}s {is} not a {que{s}tion} anymore!} % {#1<#2>#3} \startluacode interfaces.implement { name = "WeirdCommand", -- arguments = "string", arguments = "detokened", public = true, actions = function(s) s = string.gsub(s,".",{ ["{"] = "<", ["}"] = ">",}) context(s) end } \stopluacode \WeirdCommand {Th{i}s {is} not a {que{s}tion} anymore!} \stoptext Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Jairo A. del Rio