Hi Pablo,

> On 20 Sep 2020, at 18:29, Pablo Rodriguez <oi...@gmx.es> wrote:
> 
> Dear list,
> 
> I have the following sample:
> 
>  \setuplayout[page]
>  \setupinteraction
>     [state=start, color=, contrastcolor=, focus=standard]
>  \enabledirectives[references.border=red]
>  \setupexternalfigures[interaction=all, method=pdf]
>  \setupinteractionscreen[option={portrait, paper}]
>  \starttext
>  %~ \insertpages[http://gaceta.rsme.es/abrir.php?id=1495][width=0pt]
>  \insertpages[GacRSocMatEsp.pdf][width=0pt]
>  \stoptext
> 
> I have some issues with it.

Yes, various issues indeed.

> 1. For some strange reason, the first \insertpages command with a remote
> file cannot deal with the interaction from the file (no internal or
> external links).

The problem with that one is that the url does not end in .pdf, which 
means context is too late in discovering that it really is a pdf. The

  \setupexternalfigures[interaction=all, method=pdf]

doesn’t help enough, it seems. I could get it to ‘work’ with

  \insertpages[http://gaceta.rsme.es/abrir.php?id=1495&=f.pdf][width=0pt]

but I assume that is a bug, and that ConTeXt should have listened to the
method=pdf.

> 2. The local file includes internal destinations to page parts. After
> imposition, destinations to page for internal links cannot reach the
> page parts as links in original document do.

Interaction=all actually converts the internal links in the pdf into a
normal ConTeXt layer. In that process, the target is lost, and all the
links are converted to page number references. That is a limitation
of the current (MkIV) implementation. In lmtx it should be possible
to be smarter about this, but it needs an extension to ConTeXt.

> 
> 3. Even external links are converted. On last page,
> https://www.cs.umb.edu/~offner/files/pi.pdf is rewritten as
> https://www.cs.umb.edu/õffner/files/pi.pdf.

This is a bug for sure. In the process of converting the link to the
ConTeXt layer (it actually becomes a \button) it is necessary to
convert some of the characters in the PDF link into ’TeX’ by escaping
some special characters like \ and #, or the \button would fail.

ConTeXt does the TeX escaping by prepending a backslash. While that
works fine for most of the special characters, it fails for a few others.

It fails for ~ and ^ because \~ and \^ are accent commands, not character 
escapes. 
The replacer should be using \texttilde and \textcircumflex for those.

It also fails for \, but that character is rejected in URIs anyway.

===

However, in fact, most of the special characters don't need escaping for 
inclusion 
at all any more (at least not with the standard catcodes). The only ones that 
do need escaping to please ConTeXt are:

  # % \ { }

(of those, only # and % can actually happen in a wellformed URI)

The other ‘old’ special characters: 

  ~ $ ^ & _ |

do not need to be escaped by ConTeXt at all any more, \button handles them just 
fine.

(also, bare ^ and | are disallowed in a wellformed URI)


Summarized: 

In link_uri() in lpdf-epa.lua, the line

  url = escapetex(url)

can be replaced with 

  url = string.gsub(url,"#", "\\#")
  url = string.gsub(url,"%%", "\\%%")

if only correct URIs need to be considered. 


Otherwise (if bad URIs should be processed correctly), then a special 
escapeurl()
is needed in char-tex.lua to make sure that besides the prefixed backslashes
for the list of escaped characters, there is this override:

  ^ => “\textcircumflex "
  ~ => “\texttitlde "
  \ => “\textbackslash “

In that case, the \ handling needs fixing as well, because ConTeXt currently 
rejects
URIs with backslashes in them. This latter option may be wise, because I know 
from
experience that there are many bad URIs in external PDFs.

Best wishes,
Taco




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

Reply via email to