Yet Another CodeHighlighter Plugin

WordPress를 사용하여 코딩에 관한 글을 쓰려다가 DokuWiki에서 사용하던 것과 유사한 syntax highlighter가 있었으면 하는 생각에 몇개 찾아보다가 결국 원하는 플러그인을 찾지 못해 하나 만들어보았다. ((CodeHighlighter WordPress Plugin Site)) ((Screenshot: <pre lang="cpp">
struct D : public B
int i, j;
std::string s;
D d;
d.i = 1;
d.s = "code";

GeSHi Site 라이브러리를 사용하였는데 알고보니 DokuWiki의 code 태그가 이 라이브러리를 사용한 것이었다.

사용법은 pre 태그안에 lang이라는 속성을 다음과 같이 추가로 지정하면 된다.
<pre lang="cpp">

추가로 원하는 라인을 강조하고 싶다면 다음과 같이 em 속성을 추가한다.
<pre lang="cpp" em="2,3">


찾아보니 WP-Dokuwiki라는 플러그인이 있다. 이 플러그인은 DokuWiki의 모든 문법을 WordPress상에서 제공한다. 물론 GeSHi를 사용하는 code 태그도 지원한다.

테마에 맞게 몇군데 수정을 가하고 WP-Dokuwiki를 사용하게 되었다.


  1. Are you still working on this plugin?
    I get this error when I activate it :(
    I am running Wordpress
    What am I doing wrong?
    Help me please!

  2. Hi,

    how can I post source code which includes php and html statements?
    When I try it like this:


    then the html tags kill my layout
    does not work, too.

  3. I should also note that i am using the latest 2.x version that is stable

  4. I am noticing that when i have the CODE

    when i use a for loop it does not work properly, for instance if i have

    for($i = 0; $i

  5. This plugin works nicely, but I can't get it to highlight PHP code of all things. It behaves as though it isn't finding the php.php file in geshi ... very strange. It highlights bash and SQL code.


  6. Sorry. This plugin is not supported any more. Actually, I'm using the dokuwiki plugin for code highlighting in this WP. It supports almost all dokuwiki syntaxes that are very usuful to write technical articles. For example, it supports code highlighting, footnote, indentaion for reference , etc.

    Highlighting PHP code is not easy because it can have html codes with <. So I think your problem is not from geshi but from your php code itself. Sorry again~

  7. Hi, Even though you no longer support this plugin, here is a patch for your users. If found that if you have a variable increment like '++pos' in C++ or any other language for that matter that the ++ was stripped of...

    Patch is as follows:

    --- codehighlighter.php 2006-11-06 20:17:32.000000000 +0100
    +++ /Users/arjenw/Desktop/codehighlighter/codehighlighter.php 2006-05-24 01:43:46.000000000 +0200
    @@ -35,7 +35,7 @@
    if ($matches[4] != null) {
    $em = explode(",", $matches[4]);
    - $code = rawurldecode($matches[5]);
    + $code = urldecode($matches[5]);
    $tabstop = 2;

    if ($lang != null) {

  8. [...] For my wordpress installation I looked around for a decent code highlighter without too much fuss. I found codehighlighter to be sufficient for my needs. The original author is no longer maintaining the package, so besides posting a patch there I am also putting it up here for anyone running into the same problem. [...]


Post a Comment

Popular Posts