Re: [NTG-context] Minor bug in Lua or ConTeXt

2023-01-18 Thread Pablo Rodriguez via ntg-context
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  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
___


Re: [NTG-context] Minor bug in Lua or ConTeXt

2023-01-18 Thread Hans Hagen via ntg-context

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
___


Re: [NTG-context] Minor bug in Lua or ConTeXt

2023-01-18 Thread Pablo Rodriguez via ntg-context
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
___


Re: [NTG-context] multimedia inclusion added to the wiki

2023-01-18 Thread Pablo Rodriguez via ntg-context
On 1/18/23 17:45, Alan Braslau via ntg-context wrote:
> [...] 
> Thank you - this is indeed helpful.

Hi Alan,

many thanks for the kind words (also to Otared and Willi).

> I have two questions:
> 
> \userendering[key-name][video/mp4][video.mp4]
>   [embed=yes, auto]
> 
> It was my understanding that the mix of key=value with (single) option
> in the same comma-separated list does not work. Would someone clarify
> this?

This is the first time read something like that. I don’t know whether
something like this exists.

https://wiki.contextgarden.net/Multimedia_Inclusion#Including_Video
contains a sample with both keys.

Using the improved lpdf-wid.lmt included in
https://mailman.ntg.nl/pipermail/ntg-context/2023/107599.html, both keys
work.

> Secondly, I would have thought that embed=yes would include the
> multimedia file in the PDF stream. However,
> 
>   The resulting PDF document requires a video.mp4 file on the same
>   directory as your ConTeXt source file.
> 
> This should probably say "in the same directory as the PDF file", but
> is that true, or does it get embedded?

Sorry for the poor wording, it gets embedded. The source requires it for
generation (for the file to be embedded in the resulting PDF document).

I hope the new version is clearer now.

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
___


Re: [NTG-context] multimedia inclusion added to the wiki

2023-01-18 Thread Alan Braslau via ntg-context
On Mon, 16 Jan 2023 19:00:06 +0100
Pablo Rodriguez via ntg-context  wrote:

> Dear list,
> 
> just in case it might help, I have just added a new wiki article about
> how to add multimedia in PDF documents.
> 
>   https://wiki.contextgarden.net/Multimedia_Inclusion
> 
> I hope it helps,
> 
> Pablo

Pablo,

Thank you - this is indeed helpful.

I have two questions:

\userendering[key-name][video/mp4][video.mp4]
  [embed=yes, auto]

It was my understanding that the mix of key=value with (single) option
in the same comma-separated list does not work. Would someone clarify
this?


Secondly, I would have thought that embed=yes would include the
multimedia file in the PDF stream. However,

The resulting PDF document requires a video.mp4 file on the same
directory as your ConTeXt source file.

This should probably say "in the same directory as the PDF file", but
is that true, or does it get embedded?


Alan
___
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
___


Re: [NTG-context] Minor bug in Lua or ConTeXt

2023-01-18 Thread Bruce Horrocks via ntg-context
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  
> 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
___


Re: [NTG-context] Minor bug in Lua or ConTeXt

2023-01-18 Thread Hans Hagen via ntg-context

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
___


Re: [NTG-context] Minor bug in Lua or ConTeXt

2023-01-18 Thread Pablo Rodriguez via ntg-context
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
___