[reportlab-users] format error? Boy is that confusing!

Robin Becker robin at reportlab.com
Thu May 7 05:15:47 EDT 2015

On 07/05/2015 09:05, Andy Robinson wrote:
> On 7 May 2015 at 07:21, Henning von Bargen <H.vonBargen at t-p.com> wrote:
>> Why not just "invalid hyperlink target" or something alike?
> That's MUCH better.  Thanks, Henning.
unfortunately this isn't a hyperlink error except at the source level where 
instead of <a href="http://xxx" we saw <a href="xxx". In the absence of a scheme 
we end up assuming a document jump. The only restriction on href is that we 
remove a leading # unfortunately that means we could allow "../../hc/foo.png" :(

> It could be an internal (elsewhere in the document) or external one
> and we need to see what else it might be about at that point in the
> code. I can't look at this until next week due to other project
> deadlines.
> - Andy
As Andy says at the point of error it is actually intended to be an internal 
link, but in practice it could just be a mis-formed external.

I don't believe there's anything in the current code that could distinguish 
between the two. In html the lack of <a name="#target"> causes no problem, but 
in pdf we have already created the jump and the target must be defined or we get 
an error on document open. I made a code change yesterday to make the message 
more useful, but we don't carry enough context with the href value to allow 
going back to the python source where the paragraph was created.

In a debugging case we could get a special Paragraph to locate its calling code 
in the python source using inspect and that could be passed to the parser and 
then used to decorate the actual string that's recorded for the href; 
non-trivial and probably costly and most likely cpython only.
Robin Becker

More information about the reportlab-users mailing list