 |
|
|
| Author |
|
|
|
Post subject: Code highlighting?
Posted: Jan 17, 2006 - 07:12 AM PST
|
|
|
|
| Maybe it worth to highlight code in your articles? |
|
|
| |
|
|
|
 |
David
|
|
Post subject:
Posted: Jan 17, 2006 - 06:17 PM PST
|
|
Site Admin
Joined: Apr 18, 2005
Posts: 23
   
Status: Offline
|
|
Thanks for the suggestion- I've added the feature. I had to write a little function so that the whole article is not highlighted- rather it looks for "<php and ?>?;" and just highlights the PHP code. Here's the code if anyone's interested:
function find_and_highlight_php_code($html)
{
if (!strstr($html, '<?php')){
return $html;
}
$t = explode('<?php', $html);
$out = '';
foreach ($t as $tt){
if (!strstr($tt, '?>')){
$out .= $tt;
}else{
$tt = explode('?>', $tt);
$out .= highlight_string('<?php' . $tt[0] . '?>', TRUE) . $tt[1];
}
}
return $out;
} |
|
|
| |
|
|
|
 |
Medwoodu
|
|
Post subject:
Posted: Jan 19, 2006 - 06:18 AM PST
|
|
Joined: Jan 17, 2006
Posts: 1
Location: Moscow
 
Status: Offline
|
|
| highlight_file("script.php"); |
|
|
| |
|
|
|
 |
David
|
|
Post subject:
Posted: Jan 19, 2006 - 11:54 AM PST
|
|
Site Admin
Joined: Apr 18, 2005
Posts: 23
   
Status: Offline
|
|
| It's not as simple as that- all the html tags would be converted- I just wanted the stuff between "<?php" and "?>" to be highlighted. |
|
|
| |
|
|
|
 |
|
|
Go To the Top of the Thread
• Go Home
|
|