php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32918 highlight_string (and highlight_file?) indent incorrectly.
Submitted: 2005-05-02 23:59 UTC Modified: 2005-05-03 09:36 UTC
From: mpb dot mail at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.0.3 OS: Gentoo Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
30 - 7 = ?
Subscribe to this entry?

 
 [2005-05-02 23:59 UTC] mpb dot mail at gmail dot com
Description:
------------
The highlight_string function fails to properly indent lines that begin with a single space.

I suspect highlight_file has the same problem, but have not tested it.

In the reproduce code (below), the line ' *' actually renders as:

<br /> *<br />

Instead of the expected:

<br />&nbsp;*<br />

So, I guess if a line begins with a single space, that space needs to be converted into '&nbsp;' even though it is a singleton.

Reproduce code:
---------------
<?php

$comment = array ('/*', '*', ' *', '  *', "\t*/");
$comment = join ("\n", $comment);
highlight_string ($comment);

?>


Expected result:
----------------
<code><span style="color: #000000">
/*<br />*<br />&nbsp;*<br />&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;*/</span>
</code>


Actual result:
--------------
<code><span style="color: #000000">
/*<br />*<br /> *<br />&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;*/</span>
</code>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-03 09:36 UTC] johannes@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

see #29338  
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 00:01:31 2024 UTC