Bug #80793 [Nab]: highlight_string
| From: | icarosnet at gmail dot com | Date: | Wed, 24 Feb 2021 04:44:35 +0000 |
| Subject: | Bug #80793 [Nab]: highlight_string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232374@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80793&edit=1
ID: 80793
User updated by: icarosnet at gmail dot com
Reported by: icarosnet at gmail dot com
Summary: highlight_string
Status: Not a bug
Type: Bug
Package: Unknown/Other Function
Operating System: all
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
well, I don't know if you can do it, to include this request in a vote, to see if they take it
out within PHP. It seems to me that it would be the same as with html, you simply have to change the
span tag for the php escapes in opening and closing, I would do it but I don't have access ...
Previous Comments:
------------------------------------------------------------------------
[2021-02-24 04:36:11] requinix@php.net
Terminal coloring varies by terminal and operating system, though cmd in Windows 10 now seems to
support the common ANSI \e[ sequences so that helps.
With a small amount of creativity, you can alter the string returned by highlight_string() to use
the proper escape sequences.
Otherwise, if there isn't already a library out there to do this for you (and I'm 95% sure
there is), the internals behind highlight_string() are not complicated so you could do it yourself
using token_get_all().
https://github.com/php/php-src/blob/PHP-8.0.3/Zend/zend_highlight.c#L84
Because honestly, this sort of thing really is best handled by a library rather than bundled into
PHP.
------------------------------------------------------------------------
[2021-02-24 04:19:47] icarosnet at gmail dot com
I am interested in this feature to run in cli, because i want implement in other of library: https://github.com/arcanisgk/BOH-Basic-Output-Handler
currently only works on web, but if "highlight_string" works correctly in CLI I can extend
the support.
------------------------------------------------------------------------
[2021-02-24 04:13:24] icarosnet at gmail dot com
i have check the php.init setting and only have this commented:
; Colors for Syntax Highlighting mode. Anything that's acceptable in
; <span style="color: ???????"> would work.
; http://php.net/syntax-highlighting
;highlight.string = #DD0000
;highlight.comment = #FF9900
;highlight.keyword = #007700
;highlight.default = #0000BB
;highlight.html = #000000
the problem, not the limitation that php has in CLI is that "highlight_string" returns
html code even when run from a terminal. is there a way to do it or recreate it for CLI?
------------------------------------------------------------------------
[2021-02-24 03:59:39] requinix@php.net
Check your highlight.* php.ini settings.
------------------------------------------------------------------------
[2021-02-24 03:57:34] icarosnet at gmail dot com
Description:
------------
hello any way to get highlight_string working in CLI?
Test script:
---------------
highlight_cli
Expected result:
----------------
highlight
Actual result:
--------------
not exist
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80793&edit=1