php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30456 Livedocs malforms example code
Submitted: 2004-10-16 07:05 UTC Modified: 2005-02-09 20:04 UTC
From: aidan@php.net Assigned: ilia (profile)
Status: Closed Package: Livedocs problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2004-10-16 07:05 UTC] aidan@php.net
Description:
------------
Livedocs, when displaying programlistings, doesn't preserve whitespace properly.

The <code> element doesn't preserve whitespace, and the `preserve-whitespace: pre` line is commented out in the theme's css files.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-16 21:03 UTC] nlopess@php.net
Can you please give an example page that doesn't work?

If I remember well, Ilia has applied one of my patches a while ago that fixed this.
 [2004-10-17 04:48 UTC] aidan@php.net
http://livedocs.zirzow.dyndns.org/index.php?l=en&q=language.oop5.exceptions

Look at the docblock, the first space is truncated. All the programlistings have 3 spaces for the first indent, though 4 are in the code.
 [2004-10-17 06:25 UTC] curt@php.net
here is a patch to fix the white space issue:

http://www.powertrip.co.za/livedocs/viewpatch.php?patch=17
 [2004-10-17 12:48 UTC] nlopess@php.net
Sorry for my stupidity, but I couldn't find where the problem is... and nor how the patch would fix the problem.

The patch will also create a bigger page (by replacing ' &nbsp;' with two &nbsp;)
 [2004-10-19 05:08 UTC] aidan@php.net
Whitespce in any element which hasn't set preserve to true will be ignored in most circumstances. Using &nbsp; won't be ignored, or setting preserve-whitespace in the CSS. Then you can not use &nbsp; at all.
 [2004-10-19 06:03 UTC] curt@php.net
Nuno,

You might be seing my changes I made for the patch. The problem is that hightlight_string() doesn't put &nbsp; in all places where a space occurs, causing in some places a ' ' to get compressed thus loosing indententation.

Here is an example of the white space compression (example Extending the Exception class):
http://livedocs.homelinux.com/en/language.oop5.exceptions.html

Note: 
  1) indentation in actual code is four spaces. this only produces 3.
  2) the  comments withing /* */ get malformed.

CSS might be able to fix this problem, I'll look into instead of translating all spaces to &nbsp;  I'm not sure exactly why the original translations of '\n ' to '<br>&nbsp;' was there but I'm assuming its due to the behaviour of highlight_string().




 [2005-02-09 20:04 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 18:01:28 2024 UTC