highlight PHP
| From: | Florent Monnier | Date: | Sun, 16 May 2004 00:23:15 +0000 |
| Subject: | highlight PHP | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-29279@lists.php.net to get a copy of this message | ||
hello,
While highlighter is discussed actualy, I don't know if this will interest
somebody, but in case here is my sed script I use to highlight my PHP code:
================================
php -s $1 | sed \
\
-e "s|<br />|\n|g" \
-e "s|<font color=\"|<span class=\"|g" \
-e "s|</font>|</span>|g" \
-e "s| | |g" \
-e "s|<?<br />|\<?php<br />|g" \
-e "s|<code>|<html>\n<head>\n<title>
basename $1
.php</title>\n\
<style type='text/css'>\n\
body { color: black;\n\
background: #CCC; }\n\
pre { background: #EEE; }\n\
.string { color: #D00; }\n\
.comment { color: #F90; }\n\
.keyword { color: #070; }\n\
.default { color: #00B; }\n\
.html { color: #000; }\n</style>\
\n</head>\n<body>\n\n<pre>|g" \
-e "s|</code>|</pre>\n\n</body>\n</html>|g" \
\
> basename $1 .php.html
================================
I have put it in /usr/local/bin, and here is the changes I have made in my
php.ini:
highlight.string = string
highlight.comment = comment
highlight.keyword = keyword
highlight.bg = bg
highlight.default = default
highlight.html = html
which correspond to the CSS added by the sed script.
Cheers