Skip to main content

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를 사용하게 되었다.

Comments

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

    ReplyDelete
  2. Hi,

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

    ...code...

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

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

    ReplyDelete
  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

    ReplyDelete
  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.

    Thoughts?

    ReplyDelete
  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~

    ReplyDelete
  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) {

    ReplyDelete
  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. [...]

    ReplyDelete

Post a Comment

Popular posts from this blog

CodeHighlighter plugin test page.

This post is for testing CodeHighlighter plugin which uses GeSHi as a fontifier engine. ((Those code blocks are acquired from Google Code Search .)) ((For more supported languages, go CodeHighlighter plugin or GeSHi homepage.)) C++ (<pre lang="cpp" lineno="1">) class nsScannerBufferList { public: /** * Buffer objects are directly followed by a data segment. The start * of the data segment is determined by increment the |this| pointer * by 1 unit. */ class Buffer : public PRCList { public: Buffer() { ++index_; } PHP (<pre lang="php" lineno="4">) for ($i = 0; $i $value = ord( $utf8_string[ $i ] ); if ( $value < 128 ) { // ASCII $unicode .= chr($value); } else { if ( count( $values ) == 0 ) { $num_octets = ( $value } $values[] = $value; Lisp (<pre lang="lisp">) ;;; Assignment (define-caller-pattern setq ((:star var fo...

Textiler plugin test page

This post is for testing Textiler plugin . This plugin uses Textile engine (version 2.0.0). The sample text is come from Textile test page. (Note that the result will be vary according to your CSS options.) Supported wiki syntax Rendering result h2{color:green}. This is a title h3. This is a subhead p{color:red}. This is some text of dubious character. Isn't the use of "quotes" just lazy writing -- and theft of 'intellectual property' besides? I think the time has come to see a block quote. bq[fr]. This is a block quote. I'll admit it's not the most exciting block quote ever devised. Simple list: #{color:blue} one # two # three Multi-level list: # one ## aye ## bee ## see # two ## x ## y # three Mixed list: * Point one * Point two ## Step 1 ## Step 2 ## Step 3 * Point three ** Sub point 1 ** Sub point 2 Well, that went well. How about we insert an <a href="/" title="watch out">old-fashioned hypertext link</a>? Will the quo...

BookCover plugin test page

This post is for testing BookCover plugin . (( The previous test page has some comments from users.)) The 'Books Reading' section in the sidebar is also using this plugin. [ bookcover:1932394613] [bookcover:1932394613] [ bookcover:1590598385(Smart and Gets Things Done)] [bookcover:1590598385(Smart and Gets Things Done)] [ bookcover:1591841380(Wikinomics : How Mass Collaboration Changes Everything)] [bookcover:1591841380(Wikinomics : How Mass Collaboration Changes Everything)] [ bookcover:8995856408] [bookcover:8995856408] [ bookcover:8831793721] [bookcover:8831793721] [ bookcover:9788831793728] [bookcover:9788831793728]