Re: [NTG-context] setupregister with realpage?

2022-09-23 Thread Benjamin Buchmuller via ntg-context
Thank you, Hans! This works, I get all the correct page references!

I didn't know about cont-new.mkxl to temporarily store "hacks". I assume the 
file is updated with each release? Is there a way to store local hacks, e.g., 
in texmf-local? I could not find "cont-loc" (maybe it's not a file).

For future reference, this is how I am using the hack:

\def\MyRegisterPageCommand#1{\currentregisterrealpage}

\setupregister[MyRegisterA][pagecommand=\MyRegisterPageCommand]
\setupregister[MyRegisterB][pagecommand=\MyRegisterPageCommand]

> On Sep 23, 2022, at 17:47, Hans Hagen  wrote:
> 
> On 9/23/2022 11:08 PM, Benjamin Buchmuller via ntg-context wrote:
>> Dear list,
>> \setuplist has the convenient option [pagenumber=realpage]
>> \setupregister has not (yet).
>> How can I get the realpagenumber instead of the userpagenumber for the 
>> register indices?
>> I tried
>> \def\MyPageCommand#1{\realpagenumber}
>> \setupregister[MyIndex][pagecommand=\MyPageCommand]
>> but this prints only the current (although real) page number.
> you can try with this in cont-new.mkxl
> 
> \pushoverloadmode \unprotect
> 
> \let\currentregisterrealpage\!!zerocount % todo: more general accessor
> 
> \permanent\protected\def\withregisterpagecommand#1#2#3#4%
>  {\ifcase#3\relax
> {\tt [entry\space not\space flushed]}%
>   \else
> \def\currentregisterpageindex{#2}%
> \def\currentregisterrealpage{#3}%
> \iflocation
> \strc_references_goto_internal{\applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}}[internal(#2)]%
> \else
>   \applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}%
> \fi
>   \fi}
> 
> \protect \popoverloadmode
> 
> which sets \currentregisterrealpage
> 
> -
>  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] setupregister with realpage?

2022-09-23 Thread Hans Hagen via ntg-context

On 9/23/2022 11:08 PM, Benjamin Buchmuller via ntg-context wrote:

Dear list,

\setuplist has the convenient option [pagenumber=realpage]

\setupregister has not (yet).

How can I get the realpagenumber instead of the userpagenumber for the register 
indices?

I tried

\def\MyPageCommand#1{\realpagenumber}

\setupregister[MyIndex][pagecommand=\MyPageCommand]

but this prints only the current (although real) page number.

you can try with this in cont-new.mkxl

\pushoverloadmode \unprotect

\let\currentregisterrealpage\!!zerocount % todo: more general accessor

\permanent\protected\def\withregisterpagecommand#1#2#3#4%
  {\ifcase#3\relax
 {\tt [entry\space not\space flushed]}%
   \else
 \def\currentregisterpageindex{#2}%
 \def\currentregisterrealpage{#3}%
 \iflocation

\strc_references_goto_internal{\applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}}[internal(#2)]%
 \else
   \applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}%
 \fi
   \fi}

\protect \popoverloadmode

which sets \currentregisterrealpage

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


[NTG-context] setupregister with realpage?

2022-09-23 Thread Benjamin Buchmuller via ntg-context
Dear list,

\setuplist has the convenient option [pagenumber=realpage]

\setupregister has not (yet).

How can I get the realpagenumber instead of the userpagenumber for the register 
indices?

I tried

\def\MyPageCommand#1{\realpagenumber}

\setupregister[MyIndex][pagecommand=\MyPageCommand]

but this prints only the current (although real) page number.

Thank you!


Benjamin
___
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] Math alignment question

2022-09-23 Thread Mikael Sundqvist via ntg-context
On Fri, Sep 23, 2022 at 8:46 PM Aditya Mahajan via ntg-context
 wrote:
>
> On Thu, 22 Sep 2022, Jeong Dal via ntg-context wrote:
>
> > Dear Mikael and Hans,
> >
> > Recently, you introdued the new command “\alignhere, \breakhere, \skiphere” 
> > which works fine.
> >
> > Since I usually use the following code that is adopted from My 
> > Way(Mathalign.pdf), I’d like to know that there is a way to use 
> > “\alignhere, \breakhere, \skiphere”  for the case below?
> >
> > \startformula\startalign
> > \NC A \NC = 3 \NR
> > \NC B \NC = 5 \NR
> > \stopalign\stopformula
>
> The way I see it is that the current implementation is that it is way to 
> break a _single_ long equation to multiple lines. For multiple equations, you 
> still need to use the \startalign method.
>

Indeed, that is the case. These formulas are done for single chain
equations. The example given above consists of two formulas, and the
new broken formula type simply does not fit. You can play with more
than one \alignhere, but they will only set new align points. I think
\startalign ... \stopalign is the way to go there. If it is cumbersome
to type all the \NC and \NR one could in principle thing of similar
input as for the simple matrices. Your example then would become

\startalign
A, = 3;
B, = 5;
\stopalign

/Mikael
___
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] Math alignment question

2022-09-23 Thread Aditya Mahajan via ntg-context
On Thu, 22 Sep 2022, Jeong Dal via ntg-context wrote:

> Dear Mikael and Hans,
> 
> Recently, you introdued the new command “\alignhere, \breakhere, \skiphere” 
> which works fine.
> 
> Since I usually use the following code that is adopted from My 
> Way(Mathalign.pdf), I’d like to know that there is a way to use “\alignhere, 
> \breakhere, \skiphere”  for the case below?
> 
> \startformula\startalign
> \NC A \NC = 3 \NR
> \NC B \NC = 5 \NR
> \stopalign\stopformula

The way I see it is that the current implementation is that it is way to break 
a _single_ long equation to multiple lines. For multiple equations, you still 
need to use the \startalign method.

Aditya___
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] PDF viewer

2022-09-23 Thread Pablo Rodriguez via ntg-context
On 9/23/22 12:18, Max Chernoff via ntg-context wrote:
>> Unfortunately, Firefox doesn’t register itself as a PDF viewer (at
>> least on MacOS), that means I can’t use it easily to open a PDF
>> from the command line (e.g. in scripts).
>
> That's odd. You can set it as the default PDF viewer on Windows and
> Linux at least.

Hi Hraban,

I know you wrote scripts, but here you have two links on how to set
another PDF default viewer:

  https://discussions.apple.com/thread/7883441
  https://www.igeeksblog.com/how-to-change-default-pdf-viewer-on-mac/

And to open PDF documents from scripts, once the default viewer is set,
it seems that "open" is the right way to go (similar to "xdge-open" in
Linux).


>>> […]
 - JS for calculations

I would love that JS worked fine in PDF.js.

I was surprised that not even this worked fine
(https://github.com/mozilla/pdf.js/issues/13918):

  this.pageNum = this.numPages ;

I would love that the kind of presentation contained in
https://free-culture.tk could be displayed as
https://www.vector-video.tk/bga-presvoz.pdf (only Acrobat seems to be
able to deal with it).

If PDF.js could deal with multimedia and JS in PDF, other audio formats
than MP3 (such as Opus) could be used.

 for annotations […]
>>> Reading annotations works, but you can't modify anything.
>> […]
> Microsoft Edge has decent PDF annotation support. I've never tested
> it on Linux, but a Linux version does exist. Okular also lets you add
> some annotations.

Annotations may be part of a PDF viewer, but the problem is that in some
projects they understand that the feature to add them is part of a PDF
editor (so annotations won’t be added).

I think this is what happened to annotations in Evince (but I may be
wrong here). And I wonder whether PDF.js might take this approach.

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
___


Re: [NTG-context] lmt_outline not rendering properly

2022-09-23 Thread Mikael Sundqvist via ntg-context
On Thu, Sep 22, 2022 at 11:15 AM Jacob Kauffmann via ntg-context
 wrote:
>
> Dear list,
>
> attached is an example taken from the luametafun manual.
> The letter o looks odd. When I compile the manual the examples in section 4 
> look also bad (different font; page 10 attached).
> It seems like the paths miss one point.
>
> This is with the latest version 2022.09.11 20:44.
>
> Cheers,
> Jacob

Hi,

I do not see this in the (just a bit) newer version I have locally, so
I think it was fixed during the meeting last week. Hopefully it will
work in the next upload. (Sometime next week)

/Mikael
___
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] PDF viewer

2022-09-23 Thread Bruce Horrocks via ntg-context
On 23 Sep 2022, at 08:59, Henning Hraban Ramm via ntg-context 
 wrote:
> 
> Unfortunately, Firefox doesn’t register itself as a PDF viewer (at least on 
> MacOS), that means I can’t use it easily to open a PDF from the command line 
> (e.g. in scripts).

The following works for me in Monterey on an Intel Mac:

$ /Applications/Firefox.app/Contents/MacOS/firefox test.pdf  

—
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] PDF viewer

2022-09-23 Thread Pablo Rodriguez via ntg-context
On 9/22/22 20:07, Henning Hraban Ramm via ntg-context wrote:
> […]
> I suggest we’ll discuss funding in the context group board, but there
> was also a discussion about fundraising at the 2022 meeting that I
> didn’t follow – I think Paulo said he had experience in fundraising?

Hi Hraban,

sorry if I’m misreading, but I’m afraid I wasn’t able to find any Paulo
in the messages I have from this list.

Now I wonder who he might be.

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] new hash for buffer (as file)

2022-09-23 Thread Pablo Rodriguez via ntg-context
On 9/23/22 06:01, Max Chernoff via ntg-context wrote:
> […]
> The SHA calculation isn't working properly because of a weird newline
> issue. Try this:
> […]
>function sha256(str)
>return utilities.sha2.hash256(
>str:gsub(string.char(0x0D), string.char(0x0A))
>)
>end
> […]

Hi Max,

this works perfectly fine with Linux "str:gsub('\r','\n')", but I can’t
make it work in Windows.

I always thought that Unix used LF (\n, if I’m not wrong) to mark a new
line, and Windows used CRLF (\r\n).

How are new lines marked in the buffer? As \r instead of \r\n or \n?

At least, Notepad (the minimal plain text editor in Windows) doesn’t
recognize newlines if I attach the buffer to the PDF document as a .txt
file.

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] PDF viewer

2022-09-23 Thread Max Chernoff via ntg-context

Hi Hraban,

> Unfortunately, Firefox doesn’t register itself as a PDF viewer (at least 
> on MacOS), that means I can’t use it easily to open a PDF from the 
> command line (e.g. in scripts).

That's odd. You can set it as the default PDF viewer on Windows and
Linux at least.

> >> for forms:
> >>   - fill in
> > Yes.
> 
> Just checked again with current Firefox: It doesn’t work with all of my 
> test files.

I tested it with the eforms manual:

   http://mirrors.ctan.org/macros/latex/contrib/acrotex/doc/eformman.pdf
   
and it seems to work fine for me. I've also used it to fill out a few
government forms in the past and it's worked too. Unfortunately, I think
that there are like 12 incompatible ways of making a form in PDF, so
support probably heavily depends on how the document was made.

> >>   - print documents with/without form contents
> > Yes.
> 
> I couldn’t find an option to print without form contents. (But usually
> you would want filled forms, so “with” is ok.)

Well if you refresh the page, you can delete everything that you've
filled in :)

> >>   - custom checkmarks/radiobuttons should work & display correctly
> > 
> > Usually it works, sometimes it doesn't.
> > 
> >>   - JS for calculations
> > 
> > Usually it works, sometimes it doesn't.
> 
> Need to check further...

I checked with the eforms manual linked above. Check marks and radio
buttons seem to work, but calculations don't.

> >> for annotations (correction workflow; generally just nice to have):
> >>   - similar to Adobe/Foxit Reader
> > 
> > Reading annotations works, but you can't modify anything.
> 
> Ok. There’s still no PDF viewer on Linux that can handle annotations 
> well. (But even Acrobat Reader on MacOS frequently crashes on them; I’m 
> using Foxit Reader for annotations, but the one for Linux is too old.)

Microsoft Edge has decent PDF annotation support. I've never tested it
on Linux, but a Linux version does exist. Okular also lets you add some
annotations.


> > I've been using pdf.js almost exclusively for the past few years either
> > via Firefox or VS Code, and I've never really had any problems. The only
> > real issue that I've had is that it gets fairly slow with documents over
> > a few thousand pages long. Otherwise, it seems pretty fast and stable,
> > and it supports nearly every feature that I tend to need.
> 
> Well, documents with thousands of pages are probably unreliable/slow in 
> most viewers.

I've got a 1.1GB document with 16000 pages, and Okular handles it just
as fast as a 10 page document. Firefox at least manages to not crash
when opening the document, which is better than most viewers.

Okular is actually a pretty nice viewer in general. It's really fast,
and it also seems to support most of these features. The tricky thing
with it though is that I think that it would be much harder to modify
compared to pdf.js.

-- Max

___
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] PDF viewer

2022-09-23 Thread luigi scarso via ntg-context
On Thu, Sep 22, 2022 at 8:08 PM Henning Hraban Ramm via ntg-context <
ntg-context@ntg.nl> wrote:

> Hi all,
> I compiled a kind of wishlist what we need or look for in a new or
> enhanced open source PDF viewer, as discussed e.g. at the 2021 meeting.
>
> https://wiki.contextgarden.net/PDF_viewer
>
>
slightly off-topic
1)   gs has a new pdf viewer
 https://www.ghostscript.com/blog/pdfi.html
but of course I think that they push on mupdf

2) EBookDroid - PDF & DJVU Reader is a very nice pdf viewer for android,
especially on 10" tablets. It's based on mupdf.

It seems that mupdf is more suited to be embedded into / used for
embedding   other programs:
latest mupdf (1.20, iirc)  has a js console and  I think you can interact
with the viewer -- sort of the js console of the browser;
I haven't seen how yet, perhaps you can add objects on the fly to the
documents, in this case one can think of embedding a
small luatex (no harms,  after all mupdf it's already a big binary) and add
(pdf)objects by scripting.


-- 
luigi
___
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] PDF viewer

2022-09-23 Thread Henning Hraban Ramm via ntg-context

Am 23.09.22 um 02:47 schrieb Max Chernoff:


I compiled a kind of wishlist what we need or look for in a new or
enhanced open source PDF viewer, as discussed e.g. at the 2021 meeting.

https://wiki.contextgarden.net/PDF_viewer

Feel free to enhance the wiki page or discuss here.


I think that pdf.js (the Firefox PDF viewer) meets most of these
requirements. There are a few requirements that it doesn't meet, but
it's open source and written in JavaScript, so we should be able to add
anything that's missing.


You’re right, pdf.js is quite good, and it’s already used by a lot of 
projects (browsers, editor plugins etc.) – the latter also means that 
you often encounter old/buggy/limited versions.


Unfortunately, Firefox doesn’t register itself as a PDF viewer (at least 
on MacOS), that means I can’t use it easily to open a PDF from the 
command line (e.g. in scripts).


But anyway, that could shift our focus to add/enable features for pdf.js 
in TeX editors.




  - PDF 2.0 compatible


It can open PDF 2.0 files, but I doubt that it supports every single
feature.


I won’t expect every feature, there are too many. Actually I don’t know 
which features of PDF 2.0 Hans was missing in viewers.



  - proper color and transparency display (respect color profiles)


It supports all of the PDF colour models/profiles for vectors, although
it ignores embedded colour profiles in images.

https://github.com/mozilla/pdf.js/issues/2856

Regular RGB and CMYK stuff works fine though.


That’s a problem if you prepare PDFs for printing. Apple’s PDF library 
(used e.g. in Preview.app, Skim, TeXshop) also does a bad job at it, as 
well as Sumatra and Chrome (according to the comments to that ticket).



  - limited JavaScript support (no modification, no file operations)


Yes, although it is quite limited:


https://blog.mozilla.org/attack-and-defense/2021/10/14/implementing-form-filling-and-accessibility-in-the-firefox-pdf-viewer/


Thank you for the link!

What they write about the scope of JS in pdf.js sounds good; but 
presentation stuff like buttons (e.g. for OCG) is probably missing.


I need to check the limits of forms in pdf.js; but Mozilla even 
implemented XFA (e.g. Qoppa didn’t).



  - update on file change (configurable)


Not by default in Firefox. It works fine in this extension though:

https://github.com/tomoki1207/vscode-pdfviewer


There it’s probably the editor framework that enables refresh. (Same 
experience with pdf.js in Atom.)



  - SyncTeX support


Not in Firefox, although there are patches to enable it:


https://github.com/James-Yu/LaTeX-Workshop/blob/cff1a372/viewer/components/synctex.ts

https://github.com/tomoki1207/vscode-pdfviewer/blob/92fecdb8/src/pdfPreview.ts


One of the Atom plugins was supposed to have it, but it didn’t work... 
(SyncTeX with ConTeXt is special anyway, we need to look into that again.)



  - accessibility (e.g. alternative text must work)


I've never used it, but it looks like there's good support:


https://blog.mozilla.org/attack-and-defense/2021/10/14/implementing-form-filling-and-accessibility-in-the-firefox-pdf-viewer/


Sounds good.


  - JS for controlling optional content groups (OCGs, Viewer Layers)


You can toggle all the layers in the side panel. I don't think that you
can toggle via buttons or JS though.


Same as in Okular. OCG control via JS would enable stepwise 
presentations and simple animations.



  - inner- and inter-document links must work


Yes; however, inter-document links are sometimes limited depending for
security reasons. I'm sure that this can be configured though.


Of course; I just meant it would be handy to be able to jump between 
PDFs in the same directory.



  - multimedia support at least via links (suggestion: use “plain Rich
Media” approach with OS’ default player)


I don't think so, although I guess you could include a video file as an
attachment.


A question for Michal...


  - transition effects not necessary (but if the developer has fun
including them, go on)


No transition effects.


for forms:
  - fill in

Yes.


Just checked again with current Firefox: It doesn’t work with all of my 
test files.



  - print documents with/without form contents

Yes.


I couldn’t find an option to print without form contents. (But usually 
you would want filled forms, so “with” is ok.)



  - same-ID fields on different pages must be synchronized


No idea.


If the form generally works, this does also.
I listed it because it’s a problem in some viewers.


  - custom checkmarks/radiobuttons should work & display correctly


Usually it works, sometimes it doesn't.


  - JS for calculations


Usually it works, sometimes it doesn't.


Need to check further...


for annotations (correction workflow; generally just nice to have):
  - similar to Adobe/Foxit Reader


Reading annotations works, but you can't modify anything.


Ok. There’s still no PDF viewer on Linux that can handle annotations