Colorize code inside <code></code> [closed]
开发者_如何学运维
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questionI'm looking for a open source PHP script to colorize the code inside
<code></code>
or
[code][/code] tags.
Thanks
You could also try a clientside/javascript highlighter: Google Code Prettify
- Supports all C-like, Bash-like, and XML-like languages.
(This is the one used on stackoverflow.com/ and code.google.com/)
Assuming you want something other than the built-in syntax highlighter, GeSHi looks like it might fit your requirements:
GeSHi started as an idea to create a generic syntax highlighter for the phpBB forum system, but has been generalised to this project. GeSHi aims to be a simple but powerful highlighting class, with the following goals:
- Support for a wide range of popular languages
- Easy to add a new language for highlighting
- Highly customisable output formats
PHP has some built in functions for this purpose. Check if highlight_string or highlight_file will work for you
http://www.php.net/highlight_file
http://www.php.net/highlight_string
精彩评论