Re: [NTG-context] JavaScript in multimedia PDF

2021-08-10 Thread Michal Vlasák via ntg-context
On Mon Aug 9, 2021 at 8:32 AM CEST, Pablo Rodriguez via ntg-context wrote:
> On 8/8/21 11:00 PM, Michal Vlasák via ntg-context wrote:
> > Is there a newer document than "JavaScript for Acrobat API Reference"
> > (May 2015)?
>
> Well, the link you provided
> (https://mailman.ntg.nl/pipermail/ntg-context/2021/103023.html) is from
> February 2021:
>
> https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/pdfs/acrobatsdk_jsapiref.pdf
>
> Here is the guide to developers (from the same date):
>
> https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/pdfs/acrobatsdk_jsdevguide.pdf

Thank you, I didn't realize that they updated the document after I
saved it. The (public) update also must have been more recently than
in February (I think the 2015 one was still up in May).

I wasn't every of the guide. It seems nice.

> I get exactly the same results: screen object, but null rendition.
>
> I have no idea what it is needed here.

Sorry, in the last mail I forgot to mention one idea I had. But now I
had time to try it, and in the end came up with three different ways to
get it working (at least the multimedia part, didn't test the rest).

It turns out, that Acrobat Reader ignores the names assigned to the
Renditions -- that's why it can't be found by name (this is not
complaint with the spec). But there is another mapping of Rendition
names and objects -- the "Renditions" name tree, that maps Unicode
encoded names of renditions to the respective objects. After generating
the name tree, the method "getRendition" works correctly. This is the
possibility number one -- generate the name tree.

Another possibility uses the fact, that the "openPlayer" method needs to
know which Rendition (what to play) and Screen annotation (where to
play) to target. While in ordinary JavaScript actions one needs to
specify them manually (because there is no context), in _Rendition_ PDF
actions (that can also execute JavaScript) there is a context -- the
action specifies the annotation and rendition at the PDF dictionary
level. So possibility number two is to use JavaScript Rendition actions.

Lastly, possibility number three. If one can't play the multimedia with
JavaScript, there still is a plain (no JavaScript) Rendition action,
that can do this -- "/OP 0" (StartRendering in ConTeXt). Also one can
chain several PDF actions one after the other. So if we first play the
Rendition through this ordinary Rendition action, then we can chain
arbitrary JavaScript after it. The order is important here, because the
second action doesn't start until first one is finished (which you may
or not desire, so feel free to swap the order).

All three possibilities work in Acrobat Reader 2021.005.20060. Depending
on the length of your audio, you may be interested in the fact, that
Acrobat Reader starts playing the audio from the start, if it didn't
finish it before. And also supports only embedded files.

Foxit Reader 11.0.1.49938 supports only the second and third way. It
also starts playing the same audio multiple times if started multiple
times (the same track plays multiple times over itself). All three file
types are supported, though I only check embedded and external files
(not URL files).

There are probably functions in the JS API to achieve better control and
consequently the same behaviour in both viewers, but I didn't look.

The first two ways are not currently possible in ConTeXt. The last one
should work, because ConTeXt should support chaining actions with
/Next, although I would have to check what is the user interface
(implementation is in lpdf.action).

I however, have a proof of concept in OpTeX, that uses the package from
my thesis (but I had to extend it for the Unicode encoded Rendition name
tree). To compile, you would need OpTeX and the updated "pdfextra.opm"
from
https://raw.githubusercontent.com/vlasakm/pdfextra/master/pdfextra.opm.
But the compiled PDF from the below example is attached.

With the proof of concept, and real world PDF document available, we
should probably get the functionality into ConTeXt. First way should
work if the name tree is added (I will look into that), but also needs a
better way to refer to the screen annotations, than what I am using
below (which maybe means more book keeping, have to check). The second
way would need a new executer and its shortcut, maybe something used
like this:

\goto{...}[JSRendition{, }]

But I presume that more book keeping will be necessary.

The third way should hopefully already work.

Also, beware that both in my example, and in ConTeXt, multimedia
insertion produces whatsits, which especially when inserted with zero
dimensions like here for audio, may cause surprising interactions when
around normal typsetting content. Putting the whatsit insertion in a
page background is a way to keep it away. "back-swf.mkiv" suggests:

\setupbackgrounds[page][background=resources]
\setlayer[resources]{\placerenderingwindow[foo][foo]}



Michal Vlasák



% compile 

Re: [NTG-context] Different in-text and list citation renderings

2021-08-10 Thread Joey McCollum via ntg-context
It may also be relevant to mention a related feature of SBL style:
(3) The "et al." string is used for more than three authors for in-text
citations, but all authors are listed in full in the list of publications.

In publ-imp-chicago.mkvi (probably the most similar style to SBL), the
etallimit and etaldisplay parameters are set to the default values:

\definebtx
  [chicago:\s!list]
  [chicago]
 %[\c!otherstext={\btxcomma\btxnobreakspace\textellipsis\space},
 % \c!etallimit=7,
 % \c!etaldisplay=6,
 % \c!etaloption=last,
  [\c!authorconversion=inverted]

But the definition for in-text citations sets both of these parameters to 1:

\definebtx
  [chicago:\s!cite]
  [chicago]
  [\c!alternative=authoryear,
   \c!otherstext={\btxcomma\btxlabeltext{others}},
   \c!etallimit=1,
   \c!etaldisplay=1,
   \c!authorconversion=\v!name,
   \c!sorttype=normal, % \v!normal ?
   \c!style=,
   \c!compress=\v!yes] % note that cite sorts only work with compress=yes.

Now, if I cite a source in-text using the "author" alternative, this rule
is applied, but if I cite a source in-text using the "entry" alternative,
the printed citation follows the rules for [chicago:\s!list], even though
the citation style for the "entry" alternative is explicitly defined to
inherit from [chicago:\s!cite]:

\definebtx
  [chicago:\s!cite:entry]
  [chicago:\s!cite]
  [\c!left=,
   \c!right=,
   \c!inbetween={\btxspace},
   \c!separator:2={\btxsemicolon},
   \c!separator:3=\btxparameter{\c!separator:2},
   \c!separator:4=\btxparameter{\c!separator:2}]

Is the "entry" alternative just hardcoded to match the list citation, or am
I missing something?

Joey

On Tue, Aug 10, 2021 at 2:12 PM Joey McCollum 
wrote:

> Hi,
>
> I'm currently working on implementing a new citation rendering for SBL
> style. One of the challenges of this style is that it specifies slightly
> different rules for citations in the text (which are generally expected to
> look like citations made with the "entry" alternative) and entries in the
> final list of publications. The two most common differences are
> (1) Authors in the in-text citation are printed in normal form (i.e.,
> first name followed by last name), while authors in the list citation are
> printed in inverted for for the first author and normal form for all
> subsequent authors.
> (2) Most fields in the in-text citation are separated by commas, while the
> list citation uses periods in these places.
>
> Is there already a mechanism for handling this for another citation style?
> And if not, could anyone offer a suggestion on how I might go about
> implementing separate rules for in-text citations and list citations?
>
> Thanks!
>
> Joey
>
___
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
___


[NTG-context] Different in-text and list citation renderings

2021-08-10 Thread Joey McCollum via ntg-context
Hi,

I'm currently working on implementing a new citation rendering for SBL
style. One of the challenges of this style is that it specifies slightly
different rules for citations in the text (which are generally expected to
look like citations made with the "entry" alternative) and entries in the
final list of publications. The two most common differences are
(1) Authors in the in-text citation are printed in normal form (i.e., first
name followed by last name), while authors in the list citation are printed
in inverted for for the first author and normal form for all subsequent
authors.
(2) Most fields in the in-text citation are separated by commas, while the
list citation uses periods in these places.

Is there already a mechanism for handling this for another citation style?
And if not, could anyone offer a suggestion on how I might go about
implementing separate rules for in-text citations and list citations?

Thanks!

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


Re: [NTG-context] Harvard bibliography style

2021-08-10 Thread Thomas A. Schmitz via ntg-context
To get you started: the APA standards are defined in publ-imp-apa.mkvi and 
publ-imp-apa.lua. You could try and copy these files to different names 
(beginning with publ-imp-) and then make changes. You’ll have to replace the 
“apa:” prefix with the name you give your own style. From my experience, it is 
easier to start with empty files and then add definitions as you go than to 
modify the APA files; they are very complex and pull in lots of definitions 
from other files. In general: people here will be more willing to help if they 
see you make some effort to help yourself.

> On 10. Aug 2021, at 13:03, Jorge Manuel via ntg-context  
> wrote:
> 
> Alan,
> 
> Sorry for the insistence, but I need some help in setting up my bibliography. 
> I want to continue to use context, but there is no out-of-the-box solution 
> for bibliographic references that are based on the harvard agsm style (this 
> is the standard in my country).

That’s not relevant to your questions, is it?

> 
> 1. Parenthetical citations
> 
>   I need to remove the comma between de name and year. For example, the 
> APA standard produces (Alan, 2021) I want (Alan 2021).
> 

The comma is defined in l. 360-7 in publ-imp-apa.mkvi:

\definebtx
  [apa:\s!cite:authoryear]
  [apa:\s!cite:author]
  [\c!left={(},
   \c!right={)},
   \c!inbetween={\btxcomma},
   \c!separator:names:3={\btxcomma\textampersand\space},
   \c!separator:names:4={\btxspace\textampersand\space}]

So instead of inbetween=\btxcomma, you could try inbetween=\btxspace

> 2. Articles in bibliography
> 
>  I need te remove de parenthesis in year and add single quotes in the 
> article title. 
> 
> The standard are:
> Surname of the author(s) of the article, Initials Year of publication, 
> ‘Article title in single quotes’, Journal title: title complement, Volume 
> number, Issue number, Article pages.
> 
> Example: 
> Higson, R 2010, ‘Conceptual artists’ war on complacency’, Australian, 16 
> November, p. 15. 

The period after the initial is controlled by

\setupbtx [stopper:initials=]

Which you can find in publ-ini.mkxl. The default value is stopper:initials={.}, 
you can simply delete the {.} part, and there will be no period.

The double quotes are defined in publ-imp-default.mkvi, l. 144-8:

\definebtx
  [\s!default:\s!list:title:article]
  [\s!default:\s!list:title]
  [\c!style=, % journal is set in italics
   \c!command=\quotation] 

You can either replace command=\quotation with command=\quote or adapt the 
symbol for quotations for your language, e.g.

\setuplanguage[en]
[leftquotation=\upperleftsinglesixquote,
 rightquotation=\upperrightsingleninequote]

Which would of course set the single quotes for all English text in your 
document.

Once again: bibliographies are infinitely complex (if you read the source, you 
will find a couple of heartfelt outbursts from Hans), you’ll see that some 
changes have undesirable side effects, and it will take time to accomplish what 
you need. I have found it easier to start with very simple definitions and then 
add bells and whistles; the files in the distribution are complex because they 
follow complex standards and try to define all possible cases. This may be a 
bit overwhelming for a relative beginner.

3.Other documents
> 
> I have other changes, but if I understand how can adapte  the article 
> bibliographic style I can make my own changes  for other documents. 

Possible.

Good luck.

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


Re: [NTG-context] Harvard bibliography style

2021-08-10 Thread Jorge Manuel via ntg-context
Alan,

Sorry for the insistence, but I need some help in setting up my bibliography. I 
want to continue to use context, but there is no out-of-the-box solution for 
bibliographic references that are based on the harvard agsm style (this is the 
standard in my country).

1. Parenthetical citations

I need to remove the comma between de name and year. For example, the 
APA standard produces (Alan, 2021) I want (Alan 2021).

2. Articles in bibliography

     I need te remove de parenthesis in year and add single quotes in the 
article title.

The standard are:
Surname of the author(s) of the article, Initials Year of publication, ‘Article 
title in single quotes’, Journal title: title complement, Volume number, Issue 
number, Article pages.

Example:
Higson, R 2010, ‘Conceptual artists’ war on complacency’, Australian, 16 
November, p. 15.

3.Other documents

I have other changes, but if I understand how can adapte  the article 
bibliographic style I can make my own changes  for other documents.


Thanks in advance for your support.
Have a nice day.

Jorge Magalhães

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


Re: [NTG-context] Both pdfinfo & exiftool have trouble with 1.0.4 but works with 1.0.3

2021-08-10 Thread Ramkumar KB via ntg-context
Hans,

Thanks for the feedback. I will update to the latest version and run some
tests again.

mtxrun does not list the custom attributes unlike the others. From our
(limited) experience, mutool / poppler / exiftool all excel in different
areas. Dealing with different tools and keeping them upto date is
something we have internalized.

We did observe that mutool did not give errors with version 1.0.4 but
others did. In the ConTeXt development workflow, are there any tests with
such external tools (to possibly catch regression issues)?

We have experienced (reasonable) success with tools like diff-pdf
 to catch regression in our workflow.

Thank you as always!

best regards,
Ramkumar


On Tue, Aug 10, 2021 at 3:19 PM Hans Hagen  wrote:

> On 8/10/2021 6:33 AM, Ramkumar KB via ntg-context wrote:
> > Hi,
> >
> > We use PDF tools like mutool, pdfinfo (from poppler) and exiftool in our
> > workflow (once the PDFs are created by ConTeXt).
> >
> > But looks like we have hit upon some regression issue between 1.0.3 and
> > 1.0.4 versions. Both pdfinfo (from poppler) and exiftool are able to
> > read PDFs created from 1.0.3 but have trouble reading PDFs created with
> > 1.0.4. Please see below logs for details.
> hard to say without files but indeed updating might help
>
> btw, there is (kind of old but still ok):
>
> mtxrun --script pdf --info filename.pdf
>
> 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 / 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
___


Re: [NTG-context] ConTeXt exporter for Org Mode

2021-08-10 Thread luigi scarso via ntg-context
On Tue, Aug 10, 2021 at 10:01 AM Jason Ross via ntg-context <
ntg-context@ntg.nl> wrote:

> Hello,
>
> I have developed a ConTeXt exporter for Org Mode. It is available at
> https://github.com/Jason-S-Ross/ox-context
>
> The exporter provides custom environments for each Org Mode entity
> in an effort to make customization easier, in contrast to the Pandoc
> exporter which uses built-in environments for document elements.
>
> I appreciate any feedback.
>

Perhaps just add a README.md that explains how to install it,  and a short
example.


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


[NTG-context] ConTeXt exporter for Org Mode

2021-08-10 Thread Jason Ross via ntg-context
Hello,

I have developed a ConTeXt exporter for Org Mode. It is available at
https://github.com/Jason-S-Ross/ox-context

The exporter provides custom environments for each Org Mode entity
in an effort to make customization easier, in contrast to the Pandoc
exporter which uses built-in environments for document elements.

I appreciate any feedback.

Thanks,
Jason
___
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
___


Re: [NTG-context] nil from TeX to Lua

2021-08-10 Thread Hans Hagen via ntg-context

On 8/10/2021 9:23 AM, Taco Hoekwater via ntg-context wrote:




On 9 Aug 2021, at 22:05, Aditya Mahajan via ntg-context  
wrote:

On Mon, 9 Aug 2021, Hans van der Meer via ntg-context wrote:


In the TeX to Lua interface with

\def\Macro#1{\directlua{luafunction("#1")}}

the transfer from TeX to Lua is by string. However what to do at the Lua end 
when calling \Macro{}?
As I understand it, then on the Lua side an empty argument and an empty string 
are indistinguishable.




On the TeX side, these are always indistinguishable (as TeX doesn’t have 
’strings’) so depending
on the called macro, you could just assume str == "” actually means nil?


indeed, just check for ""

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


Re: [NTG-context] nil from TeX to Lua

2021-08-10 Thread Taco Hoekwater via ntg-context


> On 9 Aug 2021, at 22:05, Aditya Mahajan via ntg-context  
> wrote:
> 
> On Mon, 9 Aug 2021, Hans van der Meer via ntg-context wrote:
> 
>> In the TeX to Lua interface with
>> 
>> \def\Macro#1{\directlua{luafunction("#1")}}
>> 
>> the transfer from TeX to Lua is by string. However what to do at the Lua end 
>> when calling \Macro{}?
>> As I understand it, then on the Lua side an empty argument and an empty 
>> string are indistinguishable. 
> 

On the TeX side, these are always indistinguishable (as TeX doesn’t have 
’strings’) so depending
on the called macro, you could just assume str == "” actually means nil?

But a clearer example of where you run into trouble would be helpful.

Best wishes,
Taco


— 
Taco Hoekwater  E: t...@bittext.nl
genderfluid (all pronouns)



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


Re: [NTG-context] Both pdfinfo & exiftool have trouble with 1.0.4 but works with 1.0.3

2021-08-10 Thread Hans Hagen via ntg-context

On 8/10/2021 6:33 AM, Ramkumar KB via ntg-context wrote:

Hi,

We use PDF tools like mutool, pdfinfo (from poppler) and exiftool in our 
workflow (once the PDFs are created by ConTeXt).


But looks like we have hit upon some regression issue between 1.0.3 and 
1.0.4 versions. Both pdfinfo (from poppler) and exiftool are able to 
read PDFs created from 1.0.3 but have trouble reading PDFs created with 
1.0.4. Please see below logs for details.

hard to say without files but indeed updating might help

btw, there is (kind of old but still ok):

mtxrun --script pdf --info filename.pdf

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