note 27793 added to function.highlight-file

From: Date: Wed, 18 Dec 2002 23:29:13 +0000
Subject: note 27793 added to function.highlight-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-41084@lists.php.net to get a copy of this message
The following code will reformat the output from the highlight_file function into valid XHTML (removes <font> elements, replaces with <span>). It also makes use of the <pre> tag instead of all those &nbsp; and <br /> tags being in there. Hope this helps. <style type="text/css"> .source span.html { color: <?=ini_get('highlight.html')>; } .source span.default { color: <?=ini_get('highlight.default')?>; } .source span.keyword { color: <?=ini_get('highlight.keyword')?>; } .source span.string { color: <?=ini_get('highlight.string')?>; } .source span.comment { color: <?=ini_get('highlight.comment')?> } </style> <?php echo '<pre class="source">'; $source = highlight_file('xxx.php', true); $search[0] = '<font color="'.ini_get('highlight.html').'">'; $search[1] = '<font color="'.ini_get('highlight.default').'">'; $search[2] = '<font color="'.ini_get('highlight.keyword').'">'; $search[3] = '<font color="'.ini_get('highlight.string').'">'; $search[4] = '<font color="'.ini_get('highlight.comment').'">'; $search[5] = '</font>'; $search[6] = '<br />'; $search[7] = '\r'; $search[8] = '&nbsp;'; $replace[0] = '<span class="html">'; $replace[1] = '<span class="default">'; $replace[2] = '<span class="keyword">'; $replace[3] = '<span class="string">'; $replace[4] = '<span class="comment">'; $replace[5] = '</span>'; $replace[6] = "\n"; $replace[7] = ''; $replace[8] = ' '; echo str_replace($search,$replace,$source); echo '</pre>'; ?> -- http://www.php.net/manual/en/function.highlight-file.php http://master.php.net/manage/user-notes.php?action=edit+27793 http://master.php.net/manage/user-notes.php?action=delete+27793 http://master.php.net/manage/user-notes.php?action=reject+27793

« previous php.notes (#41084) next »