* [NTG-context] Buffer and \input content as input for \processtokens, etc.
@ 2023-12-06 19:26 Jairo A. del Rio
2023-12-06 20:08 ` [NTG-context] " Hans Hagen
0 siblings, 1 reply; 2+ messages in thread
From: Jairo A. del Rio @ 2023-12-06 19:26 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 768 bytes --]
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
[-- Attachment #1.2: Type: text/html, Size: 919 bytes --]
[-- Attachment #2: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* [NTG-context] Re: Buffer and \input content as input for \processtokens, etc.
2023-12-06 19:26 [NTG-context] Buffer and \input content as input for \processtokens, etc Jairo A. del Rio
@ 2023-12-06 20:08 ` Hans Hagen
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2023-12-06 20:08 UTC (permalink / raw)
To: ntg-context
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-06 20:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-06 19:26 [NTG-context] Buffer and \input content as input for \processtokens, etc Jairo A. del Rio
2023-12-06 20:08 ` [NTG-context] " Hans Hagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).