Near miss that might be a bug

[email protected] (Robert Inder) 30 Jan 2002 00:07:27 +0000
Newsgroups perl.perlpoint
Message-ID <[email protected]>
I was trying to find a way to plant "full featured" links
into a slide.  That is, links with javascript functions to
do mouse rollovers and the like.

It would be easy with a \EMBED, except that
I wanted to link to another slide "by name" --- using an \XREF
or similar.  And I can't do that inside an EMBED.

Now, Jochen had shown me how to use...
     \XREF{name=chapter}<\IMAGE{...}>
with an \IMAGE in place of the body.  So I though "what happens if I just
try an \EMBED instead of an \IMAGE, and use Perl to generate the link". 

I tried first to replicate Jochen's example (with a view to then generating
a fancier link...) 

I defined LLINK to be macro that expanded to EMBEDed Perl to generate
the HTML for the link, and then generated an XREF with that HTML
as an "EMBED" in the body.  Thus...

   +LLINK:
   \EMBED{lang=perl}
   $name = "__name__";
   $gif = "__gifname__";
   $img = "Images/" . $gif . ".gif";
   return("\\XREF{name=\"$name\"}<\\EMBED{lang=html}<IMG SRC='$img' border=3>\\END_" . "EMBED >");
   \END_EMBED

    \LLINK{name=Contact gifname=contact}


I had to split the inner "END_EMBED": otherwise the embedded 
perl got truncated...

The final HTML that I got was about the closest near miss I can imagine...

   <IMG SRC='Images/contact.gif' border=3><A HREF="page0003.html#Contact"> </A>

Note that I have my IMG tag, as generated in the Perl, with the
correct SRC.  And I have the link to the correct page for the specified
label, as generated by the XREF.  So all the substitutions have
happened within Perl properly, and I seem to have constructed
a valid \XREF.

Only thing is, the image comes BEFORE the link, not as its body!

Is this a bug?  Or have I missed or misunderstood something?

Can anyone see something I've done wrong, or suggest a work-around?

Robert.

------------------------------------------------------------------------
Robert Inder   Interactive Information Limited,           07770 30 40 52
               3, Lauriston Gardens,    Edinburgh    EH3 9HH    SCOTLAND
------------------------------------------------------------------------