* [NTG-context] In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
@ 2025-09-19 21:46 witiko
2025-09-20 10:15 ` [NTG-context] " Hans Hagen via ntg-context
2025-09-23 9:14 ` witiko
0 siblings, 2 replies; 10+ messages in thread
From: witiko @ 2025-09-19 21:46 UTC (permalink / raw)
To: ntg-context
Dear list,
I noticed that in LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text.
Consider the following two example files:
#### example.tex
```
\starttext
\newread\example
\openin\example=example.txt
\read\example to\hello
\read\example to\world
\closein\example
\hello\ \world
\stoptext
```
#### example.txt
```
{%
hello}
world
```
Running ConTeXt MkIV with the command `context --luatex example.tex` produces a PDF file with the text "hello world", as expected.
In contrast, running ConTeXt LMTX with the command `context example.tex` produces a PDF file with just the text "world", and a warning that "\end occurred inside a group at level 1". Adding the lines `\show\hello` and `\show\world` before `\stoptext` and rerunning the command `context example.tex` reveals that `\read` only assigned the opening brace `{` rather than the whole balanced text `{hello}` to `\hello`:
```
> \hello=global macro:
{
> \world=global macro:
world
```
Best,
Vit
___________________________________________________________________________________
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-19 21:46 [NTG-context] In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text witiko
@ 2025-09-20 10:15 ` Hans Hagen via ntg-context
2025-09-20 10:51 ` Joseph Wright
2025-09-23 9:14 ` witiko
1 sibling, 1 reply; 10+ messages in thread
From: Hans Hagen via ntg-context @ 2025-09-20 10:15 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
On 9/19/2025 11:46 PM, witiko@gmail.com wrote:
> Dear list,
>
> I noticed that in LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text.
i'll check it but as we just updated and because we don't use those
reads in context it will not be an immediate fix
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-20 10:15 ` [NTG-context] " Hans Hagen via ntg-context
@ 2025-09-20 10:51 ` Joseph Wright
2025-09-21 18:37 ` Hans Hagen via ntg-context
0 siblings, 1 reply; 10+ messages in thread
From: Joseph Wright @ 2025-09-20 10:51 UTC (permalink / raw)
To: ntg-context
On 20/09/2025 11:15, Hans Hagen via ntg-context wrote:
> On 9/19/2025 11:46 PM, witiko@gmail.com wrote:
>> Dear list,
>>
>> I noticed that in LuaMetaTeX, `\read` sometimes doesn't grab the
>> entire balanced text.
>
> i'll check it but as we just updated and because we don't use those
> reads in context it will not be an immediate fix
>
> Hans
I'd hope most people wanting to read unbalanced lines are using
\readline anyway!
Joseph
___________________________________________________________________________________
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-20 10:51 ` Joseph Wright
@ 2025-09-21 18:37 ` Hans Hagen via ntg-context
0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen via ntg-context @ 2025-09-21 18:37 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
On 9/20/2025 12:51 PM, Joseph Wright wrote:
> On 20/09/2025 11:15, Hans Hagen via ntg-context wrote:
>> On 9/19/2025 11:46 PM, witiko@gmail.com wrote:
>>> Dear list,
>>>
>>> I noticed that in LuaMetaTeX, `\read` sometimes doesn't grab the
>>> entire balanced text.
>>
>> i'll check it but as we just updated and because we don't use those
>> reads in context it will not be an immediate fix
>>
>> Hans
>
> I'd hope most people wanting to read unbalanced lines are using
> \readline anyway!
i wonder how many people that are, unlikely context users; i remember
that i added it because some tikz picture needed it
btw, the issue had nothign to do with balancing, it was just a comment
ending up in the macro body
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-19 21:46 [NTG-context] In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text witiko
2025-09-20 10:15 ` [NTG-context] " Hans Hagen via ntg-context
@ 2025-09-23 9:14 ` witiko
2025-09-23 9:49 ` Hans Hagen via ntg-context
1 sibling, 1 reply; 10+ messages in thread
From: witiko @ 2025-09-23 9:14 UTC (permalink / raw)
To: ntg-context
I am seeing some other issues with `\read` as well. For example, `\def\first{hello world}` (notice the two spaces) will store 11 tokens "hello␣world" in `\first` but storing `hello world` in a text file named `example.txt` and reading that file with `\newread\example \openin\example=example.txt \read\example to\second` in LuaMetaTeX stores 13 tokens "hello␣␣world\n" in `\second`. LuaTeX and other TeX engines would store just 12 tokens "hello␣world\n". This is less of an issue than the one described in the original post and can likely be fixed by using `\scantokens` on `\second`.
___________________________________________________________________________________
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-23 9:14 ` witiko
@ 2025-09-23 9:49 ` Hans Hagen via ntg-context
2025-09-23 10:09 ` witiko
0 siblings, 1 reply; 10+ messages in thread
From: Hans Hagen via ntg-context @ 2025-09-23 9:49 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
On 9/23/2025 11:14 AM, witiko@gmail.com wrote:
> I am seeing some other issues with `\read` as well. For example, `\def\first{hello world}` (notice the two spaces) will store 11 tokens "hello␣world" in `\first` but storing `hello world` in a text file named `example.txt` and reading that file with `\newread\example \openin\example=example.txt \read\example to\second` in LuaMetaTeX stores 13 tokens "hello␣␣world\n" in `\second`. LuaTeX and other TeX engines would store just 12 tokens "hello␣world\n". This is less of an issue than the one described in the original post and can likely be fixed by using `\scantokens` on `\second`.
On my machine from this:
\starttext
\newread\example
\openin\example=example.txt
\read\example to\hello
\read\example to\world
\closein\example
(\meaningfull\hello)
(\meaningfull\world)
[\hello\ \world]
\stoptext
I now get:
(global macro:{hello})
(global macro:world)
[hello world]
For
{%
hello}
world
But I used a patched version of \read that is not yet uploaded.
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-23 9:49 ` Hans Hagen via ntg-context
@ 2025-09-23 10:09 ` witiko
2025-09-23 11:27 ` Hans Hagen via ntg-context
0 siblings, 1 reply; 10+ messages in thread
From: witiko @ 2025-09-23 10:09 UTC (permalink / raw)
To: ntg-context
What do you get with the following:
{%
h ello}
world
Is it (global macro:{h␣␣ello}) or (global macro:{h␣ello})?
___________________________________________________________________________________
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-23 10:09 ` witiko
@ 2025-09-23 11:27 ` Hans Hagen via ntg-context
2025-09-23 11:40 ` witiko
0 siblings, 1 reply; 10+ messages in thread
From: Hans Hagen via ntg-context @ 2025-09-23 11:27 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
On 9/23/2025 12:09 PM, witiko@gmail.com wrote:
> What do you get with the following:
>
> {%
> h ello}
> world
>
> Is it (global macro:{h␣␣ello}) or (global macro:{h␣ello})?
single space as spaces collapse (and \endlinechar outside 0..127 range
suppresses spaces at the end)
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-23 11:27 ` Hans Hagen via ntg-context
@ 2025-09-23 11:40 ` witiko
2025-09-23 12:58 ` Hans Hagen via ntg-context
0 siblings, 1 reply; 10+ messages in thread
From: witiko @ 2025-09-23 11:40 UTC (permalink / raw)
To: ntg-context
I am asking because the spaces don't collapse for me with LuaMetaTeX 2.11.08 (level 20250917):
(global macro:{h␣␣ello} )
(global macro:world␣)
[h␣␣ello␣␣world␣]
For
{h ello}
world
I am assuming that's part of the unreleased fix, i.e. your "patched version of \read" then?
Best,
Vit
___________________________________________________________________________________
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] 10+ messages in thread
* [NTG-context] Re: In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text
2025-09-23 11:40 ` witiko
@ 2025-09-23 12:58 ` Hans Hagen via ntg-context
0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen via ntg-context @ 2025-09-23 12:58 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
On 9/23/2025 1:40 PM, witiko@gmail.com wrote:
> I am asking because the spaces don't collapse for me with LuaMetaTeX 2.11.08 (level 20250917):
>
> (global macro:{h␣␣ello} )
> (global macro:world␣)
> [h␣␣ello␣␣world␣]
>
> For
>
> {h ello}
> world
>
> I am assuming that's part of the unreleased fix, i.e. your "patched version of \read" then?
indeed
-----------------------------------------------------------------
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] 10+ messages in thread
end of thread, other threads:[~2025-09-23 13:03 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-19 21:46 [NTG-context] In LuaMetaTeX, `\read` sometimes doesn't grab the entire balanced text witiko
2025-09-20 10:15 ` [NTG-context] " Hans Hagen via ntg-context
2025-09-20 10:51 ` Joseph Wright
2025-09-21 18:37 ` Hans Hagen via ntg-context
2025-09-23 9:14 ` witiko
2025-09-23 9:49 ` Hans Hagen via ntg-context
2025-09-23 10:09 ` witiko
2025-09-23 11:27 ` Hans Hagen via ntg-context
2025-09-23 11:40 ` witiko
2025-09-23 12:58 ` Hans Hagen via ntg-context
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).