* Minor bug in Lua or ConTeXt
@ 2023-01-17 23:36 Bruce Horrocks via ntg-context
2023-01-18 9:21 ` Pablo Rodriguez via ntg-context
2023-01-18 9:48 ` Hans Hagen via ntg-context
0 siblings, 2 replies; 7+ messages in thread
From: Bruce Horrocks via ntg-context @ 2023-01-17 23:36 UTC (permalink / raw)
To: ntg-context mailing list; +Cc: Bruce Horrocks
ConTeXt ver: 2023.01.04
The following MWE won't compile because of the \dummycommand line even though it is a comment. Not sure whether it's a minor bug or an unavoidable aspect of allowing embedded Lua.
\startluacode
-- \dummycommand
\stopluacode
\starttext
Hello
\stoptext
—
Bruce Horrocks
Hampshire, UK
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Minor bug in Lua or ConTeXt
2023-01-17 23:36 Minor bug in Lua or ConTeXt Bruce Horrocks via ntg-context
@ 2023-01-18 9:21 ` Pablo Rodriguez via ntg-context
2023-01-18 9:48 ` Hans Hagen via ntg-context
1 sibling, 0 replies; 7+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-01-18 9:21 UTC (permalink / raw)
To: Bruce Horrocks via ntg-context; +Cc: Pablo Rodriguez
On 1/18/23 00:36, Bruce Horrocks via ntg-context wrote:
> ConTeXt ver: 2023.01.04
>
> The following MWE won't compile because of the \dummycommand line
> even though it is a comment. Not sure whether it's a minor bug or an
> unavoidable aspect of allowing embedded Lua.
Hi Bruce,
I think your code should read:
\startluacode
-- \\dummycommand
\stopluacode
\starttext
Hello
\stoptext
BTW, in pure Lua:
a = "\a"
b = "\\b"
print(a..b)
outputs "\b".
Sorry, I lack the knowledge to explain this, but backslash seems to be
an special char in pure Lua too.
Just in case it might help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Minor bug in Lua or ConTeXt
2023-01-17 23:36 Minor bug in Lua or ConTeXt Bruce Horrocks via ntg-context
2023-01-18 9:21 ` Pablo Rodriguez via ntg-context
@ 2023-01-18 9:48 ` Hans Hagen via ntg-context
2023-01-18 13:41 ` Bruce Horrocks via ntg-context
1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen via ntg-context @ 2023-01-18 9:48 UTC (permalink / raw)
To: Bruce Horrocks via ntg-context; +Cc: Hans Hagen
On 1/18/2023 12:36 AM, Bruce Horrocks via ntg-context wrote:
> ConTeXt ver: 2023.01.04
>
> The following MWE won't compile because of the \dummycommand line even though it is a comment. Not sure whether it's a minor bug or an unavoidable aspect of allowing embedded Lua.
>
> \startluacode
> -- \dummycommand
> \stopluacode
> \starttext
> Hello
> \stoptext
a bang-head-against-the-wall case:
\let\dummycommand\relax
\startluacode
-- \dummycommand
\stopluacode
\starttext
Hello
\stoptext
or:
\ifdefined\dummycommand \else \let\dummycommand\relax \fi
a document-on-the-wiki challenge for Pablo
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://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Minor bug in Lua or ConTeXt
2023-01-18 9:48 ` Hans Hagen via ntg-context
@ 2023-01-18 13:41 ` Bruce Horrocks via ntg-context
2023-01-18 17:47 ` Pablo Rodriguez via ntg-context
0 siblings, 1 reply; 7+ messages in thread
From: Bruce Horrocks via ntg-context @ 2023-01-18 13:41 UTC (permalink / raw)
To: ntg-context mailing list; +Cc: Bruce Horrocks
Thanks Hans.
Before Pablo spends too much effort on the wiki it's worth pointing out that this only happened because I was in-line documenting the Lua function that I had written and wanted to name the ConTeXT macro that would invoke it - so it's trivial for me to avoid this error.
Perhaps the Wiki only needs to point out that if you get a Lua related error and the error log lists the entire contents of \startluacode ... \stopluacode then a possible source of the error is a \command somewhere in there?
Regards,
> On 18 Jan 2023, at 09:48, Hans Hagen via ntg-context <ntg-context@ntg.nl> wrote:
>
> On 1/18/2023 12:36 AM, Bruce Horrocks via ntg-context wrote:
>> ConTeXt ver: 2023.01.04
>> The following MWE won't compile because of the \dummycommand line even though it is a comment. Not sure whether it's a minor bug or an unavoidable aspect of allowing embedded Lua.
>> \startluacode
>> -- \dummycommand
>> \stopluacode
>> \starttext
>> Hello
>> \stoptext
>
> a bang-head-against-the-wall case:
>
> \let\dummycommand\relax
>
> \startluacode
> -- \dummycommand
> \stopluacode
> \starttext
> Hello
> \stoptext
>
> or:
>
> \ifdefined\dummycommand \else \let\dummycommand\relax \fi
>
> a document-on-the-wiki challenge for Pablo
>
> 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://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : https://www.pragma-ade.nl / http://context.aanhet.net
> archive : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> ___________________________________________________________________________________
—
Bruce Horrocks
Hampshire, UK
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Minor bug in Lua or ConTeXt
2023-01-18 13:41 ` Bruce Horrocks via ntg-context
@ 2023-01-18 17:47 ` Pablo Rodriguez via ntg-context
2023-01-18 18:07 ` Hans Hagen via ntg-context
0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-01-18 17:47 UTC (permalink / raw)
To: Bruce Horrocks via ntg-context; +Cc: Pablo Rodriguez
On 1/18/23 14:41, Bruce Horrocks via ntg-context wrote:
> […]
> Perhaps the Wiki only needs to point out that if you get a Lua
> related error and the error log lists the entire contents of \startluacode ...
> \stopluacode then a possible source of the error is a \command somewhere
> in there?
Hi Bruce,
from what I understand is that undefined TeX commands cannot be added to
Lua comments.
If I’m not wrong (in my previous statement), I think this is
counterintuitive, since undefined commands are fine in TeX comments and
undefined variables are fine inside \startluacode … \stopluacode.
So I added
https://wiki.contextgarden.net/Programming_in_LuaTeX#Undefined_Commands_in_Lua_Comments.
Let me know whether I missed something.
Many thanks for your help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Minor bug in Lua or ConTeXt
2023-01-18 17:47 ` Pablo Rodriguez via ntg-context
@ 2023-01-18 18:07 ` Hans Hagen via ntg-context
2023-01-18 18:25 ` Pablo Rodriguez via ntg-context
0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen via ntg-context @ 2023-01-18 18:07 UTC (permalink / raw)
To: Pablo Rodriguez via ntg-context; +Cc: Hans Hagen
On 1/18/2023 6:47 PM, Pablo Rodriguez via ntg-context wrote:
> from what I understand is that undefined TeX commands cannot be added to
> Lua comments.
Indeed. Of course we could have some 'ignore undefined command' feature
but that cripples the engine as well as then also never gives warning in
the case you *do* want to expand.
> If I’m not wrong (in my previous statement), I think this is
> counterintuitive, since undefined commands are fine in TeX comments and
> undefined variables are fine inside \startluacode … \stopluacode.
I bet you'd complain if \the\scratchdimen would not expand. You cannot
expect context to completely parse what goes into lua beforehand, unless
you are willing to get a performance hit (apart from a waste of time).
And even if we'd make e.g. - active (with some lookahead magick) and
then gobble till the end of the line we would get questions why it
doesn't work in macros.
It's a small price to pay. (I also bet that Bruce is willing to \relax
the command.)
Thanks for adding to the wiki,
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://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Minor bug in Lua or ConTeXt
2023-01-18 18:07 ` Hans Hagen via ntg-context
@ 2023-01-18 18:25 ` Pablo Rodriguez via ntg-context
0 siblings, 0 replies; 7+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-01-18 18:25 UTC (permalink / raw)
To: Hans Hagen via ntg-context; +Cc: Pablo Rodriguez
On 1/18/23 19:07, Hans Hagen via ntg-context wrote:
> On 1/18/2023 6:47 PM, Pablo Rodriguez via ntg-context wrote:
> [...]
>> If I’m not wrong (in my previous statement), I think this is
>> counterintuitive, since undefined commands are fine in TeX comments and
>> undefined variables are fine inside \startluacode … \stopluacode.
>
> I bet you'd complain if \the\scratchdimen would not expand. You cannot
> expect context to completely parse what goes into lua beforehand, unless
> you are willing to get a performance hit (apart from a waste of time).
I’m starting to understand that one cannot have it all.
I haven’t used so much Lua code to add an undefined TeX command in a
comment.
Different reply isn’t wrong, only it needs to be known in advance.
> Thanks for adding to the wiki,
I have discovered after the addition that this was explained before
(last paragraph from
https://wiki.contextgarden.net/Programming_in_LuaTeX#Calling_Lua_from_TeX).
To emphasize it visually, I abused the <blockquote> element.
If any wiki wizard knows better, please tell.
Many thanks for your help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-01-18 18:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 23:36 Minor bug in Lua or ConTeXt Bruce Horrocks via ntg-context
2023-01-18 9:21 ` Pablo Rodriguez via ntg-context
2023-01-18 9:48 ` Hans Hagen via ntg-context
2023-01-18 13:41 ` Bruce Horrocks via ntg-context
2023-01-18 17:47 ` Pablo Rodriguez via ntg-context
2023-01-18 18:07 ` Hans Hagen via ntg-context
2023-01-18 18:25 ` Pablo Rodriguez 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).