Re: Petal and  

Bruno Postle <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
On Tue 15-Mar-2005 at 12:58 -0600, wsmith wrote:

> I was just wondering if anyone has any input in the fact that 
> petal changes &nbsp; to &amp;nbsp;, but does *not* modify &#160; 
> (the unicode equivilant). Is this a bug or how petal is supposed 
> to work?

Yes, this is because Petal is treating your template as XML.  If you 
create a template like this:

  <a>&nbsp;&#160;</a>

..and process it like this:

  $Petal::INPUT = 'XHTML';
  my $a = new Petal ('nbsp.xml');
  print $a->process;

As expected, you get two identical non-breaking-space characters:

  <p>  </p>

If you process it like this (XML is the Petal default):

  $Petal::INPUT = 'XML';
  my $a = new Petal ('nbsp.xml');
  print $a->process;

..suprisingly, you see this output:

  <p>&amp;nbsp; </p>

This is because "&nbsp;" isn't a XML entity.  You can check with 
xmllint:

  $ xmllint nbsp.xml
  nbsp.xml:1: parser error : Entity 'nbsp' not defined

So, use "&#160;" instead of "&nbsp;", or tell Petal the template is 
XHTML rather than XML.

-- 
Bruno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.