ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Taco Hoekwater <taco@elvenkind.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: issue with interaction=all and \insertpages
Date: Wed, 23 Sep 2020 11:59:56 +0200	[thread overview]
Message-ID: <2DAFCD5B-94CA-4CA5-8524-E28136916215@elvenkind.com> (raw)
In-Reply-To: <82c6da42-8708-b8a1-fcf5-c0bd64135f8e@gmx.es>

Hi Pablo,

> On 20 Sep 2020, at 18:29, Pablo Rodriguez <oinos@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	other threads:[~2020-09-23  9:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-20 16:29 Pablo Rodriguez
2020-09-23  9:59 ` Taco Hoekwater [this message]
2020-09-23 15:06   ` Pablo Rodriguez
     [not found] <mailman.1.1600682401.26760.ntg-context@ntg.nl>
2020-09-23  4:34 ` Andres Conrado Montoya Acosta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2DAFCD5B-94CA-4CA5-8524-E28136916215@elvenkind.com \
    --to=taco@elvenkind.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).