present php code with css

From: Date: Wed, 24 Sep 2003 07:01:50 +0000
Subject: present php code with css
Groups: php.general 
Request: Send a blank email to php-general+get-163697@lists.php.net to get a copy of this message
For people interested in presenting php code on their web site and integrate it with their css, here is a small sed script I have made. Just change the colors in it, or move it to your css. =================== # Put php sources in SRC dir, or change FROM definition. FROM=SRC DEST=listing if [ ! -d $DEST ]; then mkdir $DEST fi for p in ls $FROM/*.php ; do php -s $p | sed \ -e "s|<br />|\n|g" \ -e "s|<font color=\"|<span class=\"|g" \ -e "s|</font>|</span>|g" \ -e "s|&nbsp;| |g" \ -e "s|&lt;?<br />|\&lt;?php<br />|g" \ -e "s|<code>|<html>\n<head>\n<title>basename $p .php</title>\n\ <style type='text/css'>\n\ @import \"./styles/01.css\";\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" \ > $DEST/basename $p .php.html ; done =================== And change this at "Colors for Syntax Highlighting" section in the php.ini : highlight.string = string highlight.comment = comment highlight.keyword = keyword highlight.bg = bg highlight.default = default highlight.html = html

« previous php.general (#163697) next »