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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________