Syntax Highlight Code in WordPress Posts

From time to time I post code snippets in blog posts. Today I found a wordpress plugin, Code Snippet 2.0, a plugin that eases code posting by escaping the the code right. And moreover Code Snippet 2.0 displays the code with highlighting. The plugin uses GeSHi syntax highlighter engine – a flexible and easy extendable highlighter engine.

Install

  • Download the plugin here
  • Copy archive to wp-content/plugins directory
  • Extract the zip file
  • When extracted properly you should have a directory structure like: /wp-content/plugins/codesnippet
  • Enable the Plugin in WP-admin

Usage

<code lang="php">
< ?php
echo "Hello World";
?>
</code>

Result:

< ?php
echo "Hello World";
?>

The list of supported languages in Code Snippet 2.0:

  • actionscript-french
  • actionscript
  • ada
  • apache
  • applescript
  • asm
  • asp
  • bash
  • caddcl
  • cadlisp
  • c_mac
  • c
  • cpp
  • csharp
  • css-gen
  • css
  • delphi
  • diff
  • div
  • dos
  • d
  • eiffel
  • freebasic
  • gml
  • html4strict
  • ini
  • inno
  • java
  • javascript
  • lisp
  • lua
  • matlab
  • mpasm
  • nsis
  • objc
  • oobas
  • oracle8
  • pascal
  • perl
  • php-brief
  • php
  • python
  • qbasic
  • sdlbasic
  • smarty
  • sql
  • vbnet
  • vb
  • vhdl
  • visualfoxpro
  • xml

Comments off

Howto PHP / Java bridge on Debian

Updated 20. Marts 2007

The PHP / Java Bridge makes it possible to run use java objects within your PHP code. For example; let’s say you have a jar-file containing some functionality you may want to use in a PHP application.

To use this you must have a Java installed – either the latest version of Java (JDK) or a black hawk version installed.

Get the source code php-java-bridge_3.0.4.tar.bz2 from the PHP / Java bridge website and unpack it with

wget http://switch.dl.sourceforge.net/sourceforge/php-java-bridge/php-java-bridge_3.0.8.tar.bz2


tar xvjf php-java-bridge_3.0.4.tar.bz2


cd php-java-bridge-3.0.4


phpize - in order to use this you'll need to have the php5-dev package installed


./configure --with-java=/usr/lib/j2sdk1.5-sun - be sure to set this to the path where the Java installation is located

If the ./configure command fails because the automake version is less than 1.6 try this

apt-get install automake1.6
update-alternatives --config automake

Select version 1.6 of automake in the update-alternatives dialog and then try to run ./configure again

Now we just need to compile and install, this is done by:

make
make install-modules

Add this line to php.ini in order to enabled the PHP/Java bridge extension:

extension=java.so

Comments off