I'm using GeSHi under php to highlight a source code. How do I turn on or off line numbers using GeSHi?
GeSHi has the ability to add line numbers to your code. You can turn on or off this features as per your requirements. To highlight a source with line numbers, you call the enable_line_numbers() method. The syntax is:
$geshi->enable_line_numbers($flag);
Where $flag is one of the following:
- GESHI_NORMAL_LINE_NUMBERS - Use normal line numbering.
- GESHI_FANCY_LINE_NUMBERS - Use fancy line numbering.
- GESHI_NO_LINE_NUMBERS - Disable line numbers (default).
The following code will disable line numbers:
$tabstop = 2;
$code = trim($matches[5], '\r\n');
$code = str_replace('< pre>', '</pre>', $code);
// Create a new GeSHi for our code
$geshi =& new GeSHi($code, $lang);
$geshi->set_tab_width($tabstop);
//Disable line numbers
$geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
return $geshi->parse_code();
To enable fancy line numbering:
//Enable fancy numbering:
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
Reference:
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 0 comments… add one now }