You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Yatin Chawathe <ya...@chawathe.com> on 2003/02/13 17:48:34 UTC

Extending HTML syntax

Hi,

I am trying to create a new HTML tag <EPIMG ...> to be interpreted by
Embperl as follows:  I want <EPIMG SRC="foobar.gif" otherattrs=blah...>
to be replaced with:
  <IMG SRC="foobar.gif" WIDTH=x HEIGHT=y otherattrs=blah...>

I have the following code in a subclass of Embperl::Syntax::HTML which
almost gets me there:

    $self->AddTag('epimg', ['width', 'height'], ['src'], undef,
		  {
		      perlcode => 
       'my ($w, $h, $src); 
        $w = %&width%; 
        $h = %&height%; 
        $src = %&src%;
        if (!defined $w && !defined $h) { 
            ($w, $h) = my_own_func_to_get_img_dimensions($src);
            _ep_sa(%$t%, %$x%, "width", $w);
            _ep_sa(%$t%, %$x%, "height", $h); 
        }',
    });

This gets me 90% of the way there.  It adds the WIDTH and HEIGHT
attributes to the tag (if they don't already exist).  But I can't figure
out a way to replace the EPIMG label with IMG.  Any suggestions that
someone may have would be appreciated.

Another way I thought of doing this was to use _ep_rp() to replace the
entire <EPIMG...> tag with a newly constructed <IMG...> tag.  But I
can't figure out a way to automatically copy all of the "otherattrs"
mentioned in the EPIMG tag into the new replacement tag without having
to specify an exhaustive list of all possible "otherattrs".  For
example: _ep_rp(%$x%, "<IMG SRC=\"$src\" WIDTH=$w HEIGHT=$h
BORDER=%&border% ALIGN=%&align% onClick=%&onclick%
onMouseOver=%&onMouseOver% .......")

This is something I would like to avoid.  Am I missing some obvious API
that would allow me to add some simple code to my earlier piece of
perlcode to replace the tag name EPIMG with IMG?

Thanks,
Yatin


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Extending HTML syntax

Posted by Gerald Richter <ri...@ecos.de>.
> Thanks, I will check it out.  Will this change be integrated into the next
> release of Embperl?
>
Yes, It's already in the cvs

> Btw, when will the next release happen?
>

Should have been happen some weeks ago, but I didn't had enought spare time.
Hopefully I can release b9 at the weekend

Gerald


> Yatin
>
> ----- Original Message -----
> From: "Gerald Richter" <ri...@ecos.de>
> To: "Yatin Chawathe" <ya...@chawathe.com>; <em...@perl.apache.org>
> Sent: Friday, February 14, 2003 2:01 PM
> Subject: Re: Extending HTML syntax
>
>
> >
> >
> >  Hi,
> > >
> > >     $self->AddTag('epimg', ['width', 'height'], ['src'], undef,
> > >   {
> > >       perlcode =>
> > >        'my ($w, $h, $src);
> > >         $w = %&width%;
> > >         $h = %&height%;
> > >         $src = %&src%;
> > >         if (!defined $w && !defined $h) {
> > >             ($w, $h) = my_own_func_to_get_img_dimensions($src);
> > >             _ep_sa(%$t%, %$x%, "width", $w);
> > >             _ep_sa(%$t%, %$x%, "height", $h);
> >
> >                XML::Embperl::DOM::iSetText(%$t%,%$x%, "img") ;
> >
> > >         }',
> > >     });
> > >
> >
> > Use the above addition with the DOM.xs I attach you then it should work
> (but
> > I have not fully tested it)
> >
> > Gerald
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Extending HTML syntax

Posted by Yatin Chawathe <ya...@chawathe.com>.
Thanks, I will check it out.  Will this change be integrated into the next
release of Embperl?

Btw, when will the next release happen?

Yatin

----- Original Message -----
From: "Gerald Richter" <ri...@ecos.de>
To: "Yatin Chawathe" <ya...@chawathe.com>; <em...@perl.apache.org>
Sent: Friday, February 14, 2003 2:01 PM
Subject: Re: Extending HTML syntax


>
>
>  Hi,
> >
> >     $self->AddTag('epimg', ['width', 'height'], ['src'], undef,
> >   {
> >       perlcode =>
> >        'my ($w, $h, $src);
> >         $w = %&width%;
> >         $h = %&height%;
> >         $src = %&src%;
> >         if (!defined $w && !defined $h) {
> >             ($w, $h) = my_own_func_to_get_img_dimensions($src);
> >             _ep_sa(%$t%, %$x%, "width", $w);
> >             _ep_sa(%$t%, %$x%, "height", $h);
>
>                XML::Embperl::DOM::iSetText(%$t%,%$x%, "img") ;
>
> >         }',
> >     });
> >
>
> Use the above addition with the DOM.xs I attach you then it should work
(but
> I have not fully tested it)
>
> Gerald
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Extending HTML syntax

Posted by Gerald Richter <ri...@ecos.de>.

 Hi,
>
>     $self->AddTag('epimg', ['width', 'height'], ['src'], undef,
>   {
>       perlcode =>
>        'my ($w, $h, $src);
>         $w = %&width%;
>         $h = %&height%;
>         $src = %&src%;
>         if (!defined $w && !defined $h) {
>             ($w, $h) = my_own_func_to_get_img_dimensions($src);
>             _ep_sa(%$t%, %$x%, "width", $w);
>             _ep_sa(%$t%, %$x%, "height", $h);

               XML::Embperl::DOM::iSetText(%$t%,%$x%, "img") ;

>         }',
>     });
>

Use the above addition with the DOM.xs I attach you then it should work (but
I have not fully tested it)

Gerald