Req #23253 [Ver->Csd]: highlight_string($string) removes newlines from input string
| From: | kalle@php.net | Date: | Tue, 24 Oct 2017 02:01:01 +0000 |
| Subject: | Req #23253 [Ver->Csd]: highlight_string($string) removes newlines from input string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211877@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=23253&edit=1
ID: 23253
Updated by: kalle@php.net
Reported by: gk at proliberty dot com
Summary: highlight_string($string) removes newlines from
input string
-Status: Verified
+Status: Closed
Type: Feature/Change Request
Package: *General Issues
Operating System: *
PHP Version: master
-Assigned To:
+Assigned To: kalle
Block user comment: N
Private report: N
New Comment:
The documentation for this was fixed, I believe the main reason for why this was never fixed or
changed was that highlighted code was intended for <pre> HTML tags.
Previous Comments:
------------------------------------------------------------------------
[2014-01-11 23:09:29] bjori@php.net
http://news.php.net/php.doc.cvs/12046
------------------------------------------------------------------------
[2013-12-24 21:19:59] aaron dot hamid at gmail dot com
I submitted the attached patch to php doc system for review.
How would one go about introducing a minor enhancement as described - just a pull request? The
change is trivial and I don't think it would have any BC implications.
------------------------------------------------------------------------
[2013-12-24 20:37:18] aaron dot hamid at gmail dot com
So at the least this warrants a documentation update right?
------------------------------------------------------------------------
[2013-07-31 05:56:12] yohgaki@php.net
Current PHP doesn't add linefeed as reporter said. However, we do not have to
change behavior as highlighted source is for browsers, not human.
Left this report open, in case someone would like to change behavior.
------------------------------------------------------------------------
[2003-04-17 02:06:09] gk at proliberty dot com
If you use highlight_string() to produce HTML formatted source, the output string replaces newlines
with <br \>.
This is very ugly and unnecessary.
Whitespace is an important part of code; readability is not an insignificant feature.
Instead, "\n" should be replaced with "<br \>\n", or
"<br>\n", to be HTML compliant.
<?php
// $source_file includes line breaks
$source=join('',file($source_file));
$body=highlight_string ( $source, $return=TRUE);
// $body is a single line, without line breaks
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=23253&edit=1