Needs review
Project:
Bbcode
Version:
6.x-1.2
Component:
Code
Priority:
Minor
Category:
Feature request
Assigned:
Reporter:
Created:
1 May 2009 at 11:58 UTC
Updated:
1 May 2009 at 12:10 UTC
Jump to comment: Most recent file
I have put a little addition into the filter module to add line numbers to PHP code blocks.
It uses OL and LI tags to add the line numbers, replace the entire _bbcode_php_tag function with the one below:
function _bbcode_php_tag($text = NULL) {
$text_source = explode("\n", $text);
foreach ($text_source as $this_line)
{
$output_code .= '<li>';
if (ereg('<\?(php)?[^[:graph:]]', $this_line))
$output_code .= str_replace(array('<code>', '', "\n", '
'), '', highlight_string($this_line, true)) . '
';
else
$output_code .= ereg_replace('(<\?php )+', '', str_replace(array('', '', "\n", '
'), '', highlight_string('<?php '.$this_line, true))) . '
';
}
$return = '
'.$output_code.'
';
return $return;
}
This can probable be scaled down a bit, but it works for my needs.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | php_code_update.php.txt | 722 bytes | will.gresham |
Comments
Comment #1
will.gresham commentedI seem to have broken the drupal filter...
I have attached the script for you: