ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
Subject: Re: Using \applytosplitstringwordspaced and allies
Date: Sat, 8 Aug 2020 15:34:28 +0200	[thread overview]
Message-ID: <73587e56-8266-b177-040d-8ba97a175101@xs4all.nl> (raw)
In-Reply-To: <ee48f772-2e50-6ec9-41c0-c3013768169c@gmail.com>

On 8/8/2020 12:00 PM, Wolfgang Schuster wrote:
> Jairo A. del Rio schrieb am 08.08.2020 um 10:14:
>> Hi, list! :D
>> I've found \applytosplitstringwordspaced and many other commands 
>> reading on the mailing list and TeX StackExchange. An issue with those 
>> is: the following does not work:
>>
>> \applytosplitstringwordspaced\somemacro{\input knuth}
>>
>> It only works with explicit TeX "words". How to circumvent this 
>> inconvenience? Thanks in advance.
> 
> You can't feed knuth.tex to the command because it contains multiple 
> paragraphs but even when your file contains only a single paragraph it 
> isn't perfect because the linebreak after the last line contains as 
> extra word (seen in the first paragraph below).
> 
> To use \input as argument for \applytosplitstringwordspaced you need a 
> few \expandafter's to ensure the file is read before the argument is 
> passed to Lua. A easier method is to move everything to Lua where you 
> read the file and put it in a string, afterward you can use the CLD 
> mechanism to call \applytosplitstringwordspaced from Lua.
> 
> \unexpanded\def\somemacro#1{[#1]}
> 
> \starttext
> 
> \expandafter\applytosplitstringwordspaced\expandafter\somemacro\expandafter{\input 
> weisman }
> 
> \blank
> 
> \startluacode
> 
> -- local ward = io.loaddata(resolvers.findfile("ward.tex"))
> local ward = string.fullstrip(io.loaddata(resolvers.findfile("ward.tex")))
> 
> context.applytosplitstringwordspaced ( "\\somemacro", ward )
> 
> \stopluacode
> 
> \stoptext
just a remark: knuth.tex is tricky becauss it also has \TeX and \ and 
such, so one needs to escape it, as in:

context.applytosplitstringwordspaced (
   "\\somemacro",
   context.escape(ward)
)


-----------------------------------------------------------------
                                           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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2020-08-08 13:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-08  8:14 Jairo A. del Rio
2020-08-08 10:00 ` Wolfgang Schuster
2020-08-08 13:34   ` Hans Hagen [this message]
2020-08-08 14:31     ` Jairo A. del Rio
2020-08-09  6:52       ` Wolfgang Schuster
2020-08-09  7:13         ` Jairo A. del Rio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=73587e56-8266-b177-040d-8ba97a175101@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    --cc=wolfgang.schuster.lists@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).