You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Gerald Richter <ri...@ecos.de> on 2006/01/23 18:22:04 UTC

RE: Redefining common tags? (partial solution)

Hi,

Sorry for my later answer...

> > I've never tried it before but I understand that Embperl 2 
> can define 
> > new tags - can it redefine common HTML tags too? I have stuff like 
> > <h2><img src='/img/h2.png?text=[+ "Title Title" +]'></h2>
> >   all over the place, it would be cool to just write <h2>Title 
> > Title</h2>
> Well, I ended up with
> 
> $self -> AddTagBlock ('h2', ['color'], undef, undef, { perlcode => q{
>         { local $escmode = 0;
>             _ep_rp(%$x%, "<img src=\"/img/h2.gif?color=%&color%&text="
>             . XML::Embperl::DOM::Node::iChildsText(%$n%)
>             . "\">");
>         }}
>     }) ;
> 
> which works, but it's ugly:
> 1) how can I make both %&color% and
> XML::Embperl::DOM::Node::iChildsText(%$n%) url-escaped? I 
> tried to play with $escmode but it doesn't seem to work and 
> anyway it looks like a hack so

Try

$self -> AddTagBlock ('h2', undef, ['color'], undef, { perlcode => q{
         { local $escmode = 0;
             _ep_rp(%$x%, "<img src=\"/img/h2.gif?color=" 
             . $epreq -> Escape (%&'color%, 2) . "&text="
             . $epreq -> Escape (XML::Embperl::DOM::Node::iChildsText(%$n%),
2)
             . "\">");
         }}
     }) ;


> 2) how to do it with (I dont know, perhaps) _ep_rc?
> 3) it doesn't output outmost <h2> which is usefull for CSS 
> styling, how can I add it so it down't go into endless loop?
> 

I don't understand the last question, could you give an example?

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


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


RE: Redefining common tags? (partial solution)

Posted by Gerald Richter <ri...@ecos.de>.
> Ah! I thought I saw somewhere in the docs about $row/$col 
> variables and <tr>/<td> two-dimensional processing - I was 
> too tired on that day I guess... ;-)
> 

It is a two dimensional processing, but it only use <table> and <tr> and
repeat what found between theses tags

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


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


Re: Redefining common tags? (partial solution)

Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:

>>PS2 When I'm at it: <td> doesn't have to be closed and 
>>Embperl respects it and according to the HTML specs TR 
>>doesn't have to be closed too - can default Embperl be made 
>>more forgiving and ignore unclosed TR's? My hack just remove 
>><tr> processing completely, that is hardly optimal
>>
>>    
>>
>
>I know that this is an issue, but I don't have any easy way to fix it.
>It's still in my mind and I hope I will come up with an good idea some day.
>  
>
Yes, of course - it's not a pressing issue - and people might go full 
XHTML after all, we'll see...

>BTW. <td> works because Embperl doesn't look at td at all
>  
>
Ah! I thought I saw somewhere in the docs about $row/$col variables and 
<tr>/<td> two-dimensional processing - I was too tired on that day I 
guess... ;-)

- Robert

RE: Redefining common tags? (partial solution)

Posted by Gerald Richter <ri...@ecos.de>.
> 
> PS2 When I'm at it: <td> doesn't have to be closed and 
> Embperl respects it and according to the HTML specs TR 
> doesn't have to be closed too - can default Embperl be made 
> more forgiving and ignore unclosed TR's? My hack just remove 
> <tr> processing completely, that is hardly optimal
> 

I know that this is an issue, but I don't have any easy way to fix it.

It's still in my mind and I hope I will come up with an good idea some day.

BTW. <td> works because Embperl doesn't look at td at all

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


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


Re: Redefining common tags? (partial solution)

Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:

>>Well, now I see it works when I write
>>
>>[$ syntax + ParkhotelPruhonice $]
>><h2>Parkhotel Průhonice</h2>
>>
>>in the file itself, but when I try
>>
>>[- Execute({inputfile => '*', syntax => 'Embperl 
>>ParkhotelPruhonice'}) -]
>>
>>in base file as recommended in the docs...
>>
>>    
>>
>
>I guess you mean that it does not work in the second case?
>Do you set the syntax elsewehre? For example in a get_recipe method?
>  
>

It's working now, I must have done something stupid... I'm sorry.

- Robert

PS1 Actually I tried

[- Execute({inputfile => '*', syntax => 'Embperl ParkhotelPruhonice'}) -]

but now I have the correct one

[- Execute({inputfile => '*', syntax => 'EmbperlNoTR ParkhotelPruhonice'}) -]

I don't put </tr> elements into HTML and Embperl used to complain so I 
have my own sytax without automatic table processing. I can guess 
Embperl didn't find </tr> in the source and instead of returning an 
error returned some wierd output - it behaves this way at times...

PS2 When I'm at it: <td> doesn't have to be closed and Embperl respects 
it and according to the HTML specs TR doesn't have to be closed too - 
can default Embperl be made more forgiving and ignore unclosed TR's? My 
hack just remove <tr> processing completely, that is hardly optimal

RE: Redefining common tags? (partial solution)

Posted by Gerald Richter <ri...@ecos.de>.
> 
> Well, now I see it works when I write
> 
> [$ syntax + ParkhotelPruhonice $]
> <h2>Parkhotel Průhonice</h2>
> 
> in the file itself, but when I try
> 
> [- Execute({inputfile => '*', syntax => 'Embperl 
> ParkhotelPruhonice'}) -]
> 
> in base file as recommended in the docs...
> 

I guess you mean that it does not work in the second case?

Do you set the syntax elsewehre? For example in a get_recipe method?

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


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


Re: Redefining common tags? (partial solution)

Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:

>>WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>    
>>

Well, now I see it works when I write

[$ syntax + ParkhotelPruhonice $]
<h2>Parkhotel Průhonice</h2>

in the file itself, but when I try

[- Execute({inputfile => '*', syntax => 'Embperl ParkhotelPruhonice'}) -]

in base file as recommended in the docs...

- Robert


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


RE: Redefining common tags? (partial solution)

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

:-)

> 
> PS Will this be part of the standard release or should I keep 
> it as a patch?
> 
> 

I will put it in the standard release, since it seems usefull

Gerald



 
** Virus checked by BB-5000 Mailfilter ** 


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


Re: Redefining common tags? (partial solution)

Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:

>>            { $epreq -> component -> curr_esc_mode = 0; 
>>    
>>
>
>Oops, sorry mix of C and Perl won't work...should be
>
>$epreq -> component -> curr_esc_mode(0) ;
>  
>
WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thanks a lot.

- Robert

PS Will this be part of the standard release or should I keep it as a patch?

RE: Redefining common tags? (partial solution)

Posted by Gerald Richter <ri...@ecos.de>.
>             { $epreq -> component -> curr_esc_mode = 0; 

Oops, sorry mix of C and Perl won't work...should be

$epreq -> component -> curr_esc_mode(0) ;


Gerald
 



 
** Virus checked by BB-5000 Mailfilter ** 


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


Re: Redefining common tags? (partial solution)

Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:

>>Missing directory 
>>/usr/src/cpan/Embperl-2.1.0/xsbuilder/tables/Embperl at 
>>/usr/lib/perl5/vendor_perl/5.8.6/ExtUtils/XSBuilder/ParseSourc
>>e.pm line 494.
>>    
>>
>
>A sorry, I forgot that this directory is not part of the tar.gz, please run
> perl xsbuilder/source_scan.pl
>before
>  
>

Hmm, this is starting to be - ehm - fun... Make test is OK, but it 
refuses to work:

[Tue Jan 24 20:40:10 2006] [error] Embperl::Thread object version 2.0.1 
does not match bootstrap parameter 2.1.0 at 
/usr/lib/perl5/site_perl/5.8.6/i386-linux/Embperl.pm line 
107.\nCompilation failed in require at 
/etc/apache2/modules.d/apache2-mod_perl-startup.pl line 24.\nBEGIN 
failed--compilation aborted at 
/etc/apache2/modules.d/apache2-mod_perl-startup.pl line 24.\nCompilation 
failed in require at (eval 2) line 1.\n

I can see the old ebuild 2.0.1 version (in .../vendor_perl/ ) is being 
used together with the 2.1.0 new version (in .../site_perl/). Given 
site_perl is in @INC before vendor_perl I'm confused why this is 
happening. Anyway, after uninstalling everything I have hopefully 
working patched Embperl, now I have:

--------------------------
Syntax:
...
    $self -> AddTagBlock ('h2', ['color'], undef, undef, { perlcode => q{
            { $epreq -> component -> curr_esc_mode = 0;
                _ep_rp(%$x%, "<img src=\"/img/h2.png?color="
                . $epreq -> Escape( %&'color%, 2 )
                . "&text="
                . $epreq -> Escape( 
XML::Embperl::DOM::Node::iChildsText(%$n%), 2 )
                . "\">");
            }}
        }) ;
....
-----------------------
hotel_en.html
[$ syntax + ParkhotelPruhonice $]

<h2 color="#F00">111</h2><br>
<h2>222</h2><br>
<h2>333</h2><br>
<ul></ul>
<h2>444</h2><br>
<h2>555</h2><br>
<hr>
<img src="/img/h2.png?color=&text=999"><br>
...
------------------------

[Tue Jan 24 21:26:08 2006] [error] [23740]ERR:  24:  Error in Perl code: 
Can't modify non-lvalue subroutine call at 
/home/www/parkhotel-pruhonice/new/hotel_en.html line 4.




RE: Redefining common tags? (partial solution)

Posted by Gerald Richter <ri...@ecos.de>.
> Missing directory 
> /usr/src/cpan/Embperl-2.1.0/xsbuilder/tables/Embperl at 
> /usr/lib/perl5/vendor_perl/5.8.6/ExtUtils/XSBuilder/ParseSourc
> e.pm line 494.
> 

A sorry, I forgot that this directory is not part of the tar.gz, please run

 perl xsbuilder/source_scan.pl

before

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


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


Re: Redefining common tags? (partial solution)

Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:

>>One more problem: the escaping ( initial local $escmode = 0 ) 
>>stops workins after first use and only is restore when some 
>>Embperl processed HTML is found eg
>>
>>    
>>
>
>Mmmh, I guess we need to recompile Embperl.
>
>Go to xsbuilder/maps/ep_structure.map and remove the ! Before nCurrEscMode,
>than run perl xsbuilder/xs_generate.pl (you need to have ExtUtils::XSBuilder
>installed). After that recompile Embperl. Then use
>  
>
I'm having troubles with this - on Gentoo I can't easily recompile 
without making an ebuild etc which is a bit of work. And when I try to 
make a hand-compiled version I get (maybe because of clash 
ebuild/compiled, I don't know) this error:

Missing directory /usr/src/cpan/Embperl-2.1.0/xsbuilder/tables/Embperl 
at /usr/lib/perl5/vendor_perl/5.8.6/ExtUtils/XSBuilder/ParseSource.pm 
line 494.

- Robert

full log:

pacho Embperl-2.1.0 # perl xsbuilder/xs_generate.pl
Parse /usr/src/cpan/Embperl-2.1.0/xsbuilder/maps/_types.map...
Parse /usr/src/cpan/Embperl-2.1.0/xsbuilder/maps/ep_type.map...
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/ep_xs_sv_convert.h
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/ep_xs_typedefs.h
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Makefile.PL
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/App/App.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/App/Config/Makefile.PL
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/App/Config/Config.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/App/Config/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/App/Config
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/App/Makefile.PL
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/App/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/App
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Config/Makefile.PL
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Config/Config.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Config/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Config
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Param/Param.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Param/Makefile.PL
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Param/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Param
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Req.xs
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Makefile.PL
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Req
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Thread/Makefile.PL
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Thread/Thread.xs
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Thread/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Thread
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Syntax/Syntax.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Syntax/Makefile.PL
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Syntax/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Syntax
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Makefile.PL
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Config/Makefile.PL
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Config/Config.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Config/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Config
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Param/Param.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Param/Makefile.PL
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Param/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Param
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Output/Output.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Output/Makefile.PL
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Output/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Output
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Makefile.PL
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Component.xs
unlink 
/usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Component
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Embperl
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/typemap
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/mmargs.pl
unlink /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs/Makefile
rmdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs
mkdir /usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs
writing.../usr/src/cpan/Embperl-2.1.0/xsbuilder/../xs//typemap
Missing directory /usr/src/cpan/Embperl-2.1.0/xsbuilder/tables/Embperl 
at /usr/lib/perl5/vendor_perl/5.8.6/ExtUtils/XSBuilder/ParseSource.pm 
line 494.





RE: Redefining common tags? (partial solution)

Posted by Gerald Richter <ri...@ecos.de>.
> 
> One more problem: the escaping ( initial local $escmode = 0 ) 
> stops workins after first use and only is restore when some 
> Embperl processed HTML is found eg
> 

Mmmh, I guess we need to recompile Embperl.

Go to xsbuilder/maps/ep_structure.map and remove the ! Before nCurrEscMode,
than run perl xsbuilder/xs_generate.pl (you need to have ExtUtils::XSBuilder
installed). After that recompile Embperl. Then use

$epreq -> component -> curr_esc_mode = 0 ;

Instead of $esmode = 0

The curr_esc_mode is automaticly reseted by the ep_rp function.

Gerald



 
** Virus checked by BB-5000 Mailfilter ** 


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


Re: Redefining common tags? (partial solution)

Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:

>Try
>
>$self -> AddTagBlock ('h2', undef, ['color'], undef, { perlcode => q{
>         { local $escmode = 0;
>             _ep_rp(%$x%, "<img src=\"/img/h2.gif?color=" 
>             . $epreq -> Escape (%&'color%, 2) . "&text="
>             . $epreq -> Escape (XML::Embperl::DOM::Node::iChildsText(%$n%),
>2)
>             . "\">");
>         }}
>     }) ;
>  
>

Excellent!!! It works!

One more problem: the escaping ( initial local $escmode = 0 ) stops 
workins after first use and only is restore when some Embperl processed 
HTML is found eg

<h2 color="#F00">111</h2><br>
<h2>222</h2><br>
<h2>333</h2><br>
<ul></ul>
<h2>444</h2><br>
<h2>555</h2><br>

results in

<img src="/img/h2.png?color=%23F00&text=111"><br>
&lt;img src=&quot;/img/h2.png?color=&amp;text=222&quot;&gt;<br>
&lt;img src=&quot;/img/h2.png?color=&amp;text=333&quot;&gt;<br>
<ul></ul>
<img src="/img/h2.png?color=&text=444"><br>
&lt;img src=&quot;/img/h2.png?color=&amp;text=555&quot;&gt;<br>


One more help, please... Thank you very much.

- Robert


>>3) it doesn't output outmost <h2> which is usefull for CSS 
>>styling, how can I add it so it down't go into endless loop?
>>    
>>
>
>I don't understand the last question, could you give an example?
>  
>

I had problem when <h2> tag was replaced by <h2><stuff> and I supposed 
it dumps core because of some endless loop, but it was an unrelated 
problem. My mistake.