Calendar

三月 2008
« 二   四 »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Translator

WP-CODEBOX Plugin (代码高亮插件)

Author:Eric.Wang
Plugin URL:http://wordpress.org/extend/plugins/wp-codebox/
Tags: syntax highlighting, syntax, highlight, code, formatting
Requires at least: 2.0
Tested up to: 2.5.1
Stable tag: 1.3.1
Download

Donate for this plugin development, Thanks!

== Description ==

WP-CODEBOX代码高亮插件,支持多种语言、代码下载、复制到剪贴板、代码框收放及后台默认属性设置。本插件还在持续开发中,欢迎使用及报告bugs.
Wp-CodeBox provides clean syntax highlighting and advanced feature for embedding source code within pages or posts. It support a wide range of popular languages highlighting with line numbers, code download, Copy to clipboard, collapse codebox, automatic keywords link to API manual and maintains formatting while copying snippets of code from the browser.

It’s provide simple background configuration for highlighter style/formatting customization.
Since the plugin is developing, in the future it will support more options.(CSS option,Keyword display style,Auto Caps/Nocaps,Case Sensitivity etc. )

== Basic Usage ==

Wrap code blocks with `<pre lang=”LANGUAGE” line=”1″ file=”download.txt” colla=”+”>` and `</pre>`

Possible Parameters:

`LANGUAGE` is a [GeSHi] supported language syntax;
`file` will create a code downloading attribute.;
`line=”n”` will hide the single codebox;
`colla=”+/-”` will expand/collapse the codebox.
`line,file,colla` is optional.

== Installation ==

1. Upload WP-CodeBox.zip to your Wordpress plugins directory, usually `wp-content/plugins/` and unzip the file.  It will create a `wp-content/plugins/WP-CodeBox/` directory.
2. Activate the plugin through the ‘Plugins’ menu in WordPress.
3. Go to Option->Wp-CodeBox set default setting.
4. Create a post/page that contains a code snippet following the [proper usage syntax]

== Frequently Asked Questions ==

When activate the plugin, popup the error: “Fatal error: Cannot redeclare class GeSHi in ##/wp-content/plugins/wp-codebox/geshi/geshi.php on line 158″?
Answer:disactivate other Gashi based syntax highlighter plugin first.

== Screenshots ==

1. PHP, no line numbers.

<div id="foo">
<?php
  function foo() {
    echo "Hello World!\\n";
  }
  for (\$i = 0; \$i < 10 $i++) {
    foo();
  }
?>
</div>

2. Java, with line numbers, collapse codebox.

1
2
3
4
5
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}

3. Ruby, with line numbers starting at 18,downloading feature.

?Download ruby.txt
18
19
20
21
22
class Example
     def example(arg1)
    return "Hello: " + arg1.to_s
  end
end

4. Administration interface in WordPress 2.
screenshot-1.gif

== Usage ==

**Example 1: PHP, no line numbers**
    <pre lang=”php” line=”n”>
    <div id=”foo”>
    <?php
      function foo() {
        echo “Hello World!\\n”;
      }
      for (\$i = 0; \$i < 10 $i++) {
        foo();
      }
    ?>
    </div>
    </pre>
**Example 2: Java, with line numbers, collapse codebox**
    <pre lang=”java” colla=”-”>
    public class Hello {
      public static void main(String[] args) {
        System.out.println(”Hello World!”);
      }
    }
    </pre>
**Example 3: Ruby, with line numbers starting at 18, code downloading(ruby.txt)**
    <pre lang=”ruby” line=”18″ file=”ruby.txt”>
    class Example
      def example(arg1)
        return “Hello: ” + arg1.to_s
      end
    end
    </pre>

== Supported Languages ==

The following languages are supported in the `lang` attribute:

Actionscript,ADA,Apache Log,AppleScript,ASM,ASP,AutoIT,Backus-Naur form,Bash,BlitzBasic,C,C for Macs,C#,C++,CAD DCL,CadLisp,CFDG,CFDG,ColdFusion,CSS,Delphi,DIV,DOS,Eiffel,Fortran,Fortran,FreeBasic,GML,Groovy,HTML,Inno,IO,Java,Java 5,Javascript,LaTeX,Lisp,Lua,Microprocessor ASM,mIRC,MySQL,NSIS,Objective C,OCaml,OpenOffice BASIC,Oracle 8 SQL,Pascal,Perl,PHP,PL/SQL,Python,Q(uick)BASIC,robots.txt,Ruby,SAS,Scheme,SDLBasic,Smalltalk,Smarty,SQL,T-SQL,TCL,thinBasic,Uno IDL,VB.NET,Visual BASIC,Visual Fox Pro,Winbatch,X++,XML,Z80 ASM

==Release Notes==

**1.0** : First internal release; Uses GeSHi v1.0.7.20;
**1.0.1** : Add View Code AJAX feature;
**1.1** : Add simple background configuration for highlighter style/formatting customization;
**1.2** : css tuning and option i18n compatible;
**1.2.1** : Uses GeSHi v1.0.7.21;
**1.2.2** : WP 2.5 compatible;
**1.2.2.1** : Correct small bugs;Improve the css layout to stick the code header; Contributor:YiXia.
**1.2.3** : Uses GeSHi v1.0.7.22, add the keywords link to API manual option.

== Donate ==

== Future Feature==

It will provide backgroud option for highlighter style customization(CSS option,keyword display style,Auto Caps/Nocaps,Case Sensitivity etc.) in the future version.

  1. Galder Zamarreno posted the following on 2009-06-25 at 2:39 上午.

    Figured out what my problem was! It’s the freaking double quotes used in this blog. I copy/pasted the code but didn’t work correctly. Type your own double quotes otherwise it won’t work!

    http://wordpress.org/support/topic/282918?replies=2#post-1115173

    Reply
  2. wreutz posted the following on 2009-06-15 at 5:14 下午.

    i have a problem with html entities like &_lt; and &_gt; (_ just added to show the entities).
    i have to use html entities in pre tags to keep my site (x)html valid and wordpress converts all < to &_lt; as it’s supposed to do. The problem i have is related to wp-codebox because when i have the plugin enabled the entities are shown instead of decoded!
    when i disable the plugin the normal pre is used and the entities get decoded and shown as < or >

    can anyone track the problem down in wp-codebox?
    i had a look at the code but couldn’t find a solution :-(

    Reply
  3. Photayoke posted the following on 2009-06-11 at 6:20 下午.

    I have already installed WP-Codebox. And How to use that? Please explain me details and I want to show the HTML code in the post with this code box.

    Reply
  4. ip adres posted the following on 2009-06-07 at 8:39 上午.

    Hi, i translate this plug-in to turkish but i dont know how i can use with my translation. Is there any option for this? or where can i edit for set it?

    Reply
  5. rize gündem posted the following on 2009-06-06 at 9:53 下午.

    On FF works fine.Anyway, I like too much your plugin, it’ the best I have seen on syntax highlighting.
    rn本文来自:www.EricBess.com 详细出处参考:http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/

    Reply
  6. jon posted the following on 2009-05-19 at 3:49 上午.

    You need to add “text-align:left;” to “.wp_codebox pre” otherwise in some circumstances all of the code will be centered.

    Reply
  7. Werbeagentur-Wissen posted the following on 2009-05-14 at 8:28 上午.

    I would like to know how to display something like:

    <?php
    //…
    echo ”;
    echo ‘';
    ?>

    Can't find anything over here -.-
    I know this is creepy stuff, but at the moment i'm using " //sorry" and that would be ok.

    Cheers!

    Reply
    1. Werbeagentur-Wissen posted the following on 2009-05-14 at 8:32 上午.

      wow … i’m such an idiot XD
      it’s :

      and atm. i’m using <\/pre>
      hell …..

      Reply
      1. Werbeagentur-Wissen posted the following on 2009-05-14 at 9:03 上午.

        i give up, just del this ….

        Reply
  8. baron posted the following on 2009-05-14 at 1:14 上午.

    Works great, thank you

    Reply
  9. 狂舞网络 posted the following on 2009-05-02 at 6:44 下午.

    非常支持!做的很棒。

    Reply
  10. Samuel Santos posted the following on 2009-04-30 at 9:15 上午.

    The last version of the HTML spec now defines a way to specify the programming language in the markup.

    Example:
    <pre><code class=”language-pascal”>var i: Integer;
    begin
    i := 1;
    end.</code></pre>

    Source:
    http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-code-element

    Can a new version of the plugin be updated to use this syntax?

    Reply
  11. bolo posted the following on 2009-04-08 at 4:12 下午.

    请问如何高亮html语句啊?

    Reply
  12. Çağrı posted the following on 2009-04-01 at 9:11 下午.

    not working with wp 2.7

    Reply
    1. Eric posted the following on 2009-04-01 at 10:16 下午.

      This blog is working in WP 2.7

      Reply
  13. DJ posted the following on 2009-03-21 at 3:47 上午.

    I can not get the C# code to work. I have to use pre lang = “C” to get a close representation of C#. Can you help with this. Check out my site to see the post I am having trouble with.

    Reply
    1. Eric posted the following on 2009-03-21 at 11:57 下午.

      lang = “csharp”

      Reply
  14. karistuck posted the following on 2009-03-12 at 1:29 下午.

    :D it’s great!!

    thank you, I really need it.

    8O

    Reply
  15. Sam M. posted the following on 2009-03-12 at 3:01 上午.

    Is there a way to enable/disable the function bar in a code block via the pre switches to override the default behavior of hiding the function bar? Something like bar=”+/-” similar to the colla=”+/-”? Thanks again for a wonderful plugin!

    Reply
  16. 嗰個人 posted the following on 2009-01-26 at 9:36 下午.

    暈~~ 下面那個帖,看不圖,我把地址發上來了。下圖的英文選項,都是什麽意思? h ttp://test.35sun.com/temp/wp-codebox-1.gif
    ↓↓這個選項,我試了,無論是否勾選,都沒看到什麽變化。h ttp://test.35sun.com/temp/wp-codebox-2.gif

    Reply
  17. 嗰個人 posted the following on 2009-01-26 at 9:32 下午.

    你好,請問兩個後台設置的問題,1。下圖的英文選項,都是什麽意思?  2。↓↓這個選項,我試了,無論是否勾選,都沒看到什麽變化。

    Reply
  18. Me posted the following on 2009-01-24 at 11:56 下午.

    Hai,
     
    On the wordpress plugins page, it says you get a button in your TinyMCE editor.
    Looks like I don’t get this button :( Any ideas how?
    Wordpress version: 2.7
     
    Thanks,
    Me

    Reply
  19. Frank Liu posted the following on 2009-01-19 at 6:14 上午.

    File download problem after install 1.3.31, fixed by alter line 38 in wp-codebox.php to,
    if (preg_match(”/\s*<pre(.*file=[\"']“.$download.”[\"'])[^>]+>(.*)<\/pre>\s*/siU”, $content, $match)) {
    If anyone has the same problem, try this fix.

    Reply
  20. bastian_m posted the following on 2009-01-18 at 8:14 下午.

    It seems, that there’s a Bug! ^^
    I can’t highlight AutoIT-Code with this Plugin – try it – u will got something like:
    span style=”color: #0080FF; font-style: italic; font-weight: bold;”> =”color: #0080FF; font-style: italic; font-weight: bold;”>=”color: #0080FF; font-style: italic; font-weight: bold;”>/=”color: #0080FF; font-style: italic; font-weight: bold;”>/www.autoitscript.com/autoit3/docs/functions/MsgBox.htm”>/3/=”color: #0080FF; font-style: italic; font-weight: bold;”>>msgbox<=”color: #0080FF; font-style: italic; font-weight: bold;”>/a>(=”color: #0080FF; font-style: italic; font-weight: bold;”>=”color: #AC00A9; font-style: italic; font-weight: bold;”=”color: #0080FF; font-style: italic; font-weight: bold;”>>0,=”color: #0080FF; font-style: italic; font-weight: bold;”> =”color: #0080FF; font-style: italic; font-weight: bold;”>”Warum?”span style=”color: #0080FF; font-style: italic; font-weight: bold;”> =”color: #0080FF; font-style: italic; font-weight: bold;”>,=”color: #0080FF; font-style: italic; font-weight: bold;”> =”color: #0080FF; font-style: italic; font-weight: bold;”>”Weil ichs kann !”span style=”color: #0080FF; font-style: italic; font-weight: bold;”> =”color: #0080FF; font-style: italic; font-weight: bold;”>)=”color: #0080FF; font-style: italic; font-weight: bold;”>

    Reply
  21. neekey posted the following on 2009-01-17 at 6:22 下午.

    不错,顶一个

    Reply
  22. Web Design posted the following on 2009-01-15 at 4:01 上午.

    Thanks..

    Reply
  23. Nisse posted the following on 2009-01-15 at 1:09 上午.

    Hi,
    Me, again :)
    I use some knowledge on this blog post: ‘Styling code samples par deux‘ and it seems to get me to a point there I can go further, I hope :)
    Regards

    Reply
  24. Nisse posted the following on 2009-01-15 at 12:32 上午.

    Hi,
    I have install your PlugIn wp-codebox. I have WordPress 2.3.3 and a own styled template. (With two big css-style-files)
    The only result I get is the same has I use the ‘<pre>-tag, stand alone.
    I suspect that there is some css-issue.
    You can look at a sample post on this link:http://blogg.ngn.nu/index.php/2009/01/14/testar-syntax-highligt-wp-codebox/The blog is in Swedish but I think you can understand the post anyway :)
    Can you (any) give me some idea?
    Is there additional information you (any) need to help me out?
    Regards

    Reply
  25. Diego Pierotto posted the following on 2009-01-06 at 12:34 上午.

    Hi Eric,
    nice plugin!
    I translated it in italian and put the file here:
    http://gringo.netsons.org/blog/download/200/
    I hope this can be usefull for you and that will be soon integrated in the next release.
     
    Bye.
     

    Reply
  26. javierav posted the following on 2009-01-05 at 8:35 上午.

    Hello.
    I have wordpress 2.7 and I have a problem with your plugin. When I click for download source code in txt, load this page: …/wp-content/plugins/wp-codebox/wp-codebox.php?p=1&download=download.txt but the page is in white. I have been studying the source code and it have an error in wp-codebox.php line 39: the regular expression do not match and never send the content.
    How can I resolve this? Many thanks.
    Regards.

    Reply
  27. mike posted the following on 2009-01-02 at 6:10 上午.

    My codes are not spacing out
    Why is this?
     

    Reply
  28. hugo5688 posted the following on 2008-12-08 at 5:39 下午.

    您好,安裝plugin後,無意間要export出blog資料時發生了一些錯誤,如下
    Warning: include_once(../../../wp-config.php) [function.include-once]: failed to open stream: No such file or directory in /plugins/wp-codebox/wp-codebox.php on line 32 Warning: include_once() [function.include]: Failed opening ‘../../../wp-config.php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /plugins/wp-codebox/wp-codebox.php on line 32 Warning: include_once(../../../wp-settings.php) [function.include-once]: failed to open stream: No such file or directory in /plugins/wp-codebox/wp-codebox.php on line 33 Warning: include_once() [function.include]: Failed opening ‘../../../wp-settings.php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /plugins/wp-codebox/wp-codebox.php on line 33
    可否煩請您查看一下,感謝

    Reply
  29. pete posted the following on 2008-12-07 at 9:14 下午.

    When I try to write bare HTML my attributes are delete after I save. I’m using wordpress mu. I guess thats the reason it does not trigger the box.BTW, your site encoding is broken badly. It looks like asians encoding errors although your wordpress anounces UTF8. I even can’t read the button texts. Just guessing…

    Reply
  30. 9shell posted the following on 2008-11-28 at 5:16 下午.

    你好,感谢你的插件,我今天比较了好几个code的插件,你这个是最好的。但是。提一个小问题:
    file=”Hello.java”却显示的文件名是hello.java。这样存下来的java文件是不能编译的,请想办法解决一下,java大小写敏感。

    Reply
    1. eric posted the following on 2008-11-28 at 8:30 下午.

      改了下,没有改版本号,你重新下载安装一下,

      Reply
  31. funbsd posted the following on 2008-11-13 at 11:19 上午.

    在ff和opera里不能显示“Copy to Clipboard”

    Reply
    1. eric posted the following on 2008-11-13 at 2:59 下午.

      恭喜你答对了,你可以参与改进。

      Reply
  32. funbsd posted the following on 2008-11-11 at 2:42 下午.

    好了,原来是option.php的问题

    Reply
  33. funbsd posted the following on 2008-11-11 at 2:15 下午.

    升级之后到1.3.3之后,不能改main.php里的View Code和Copy to Clipboard为中文了,改成中文后,页面就乱七八糟的了,原来的版本没有这个问题

    Reply
  34. lavermil posted the following on 2008-11-08 at 6:03 上午.

    I am have a bit of trouble getting this line to work correctly once I have changed it. I want to support both <code> and <pre> statements. I can make it support one or the other but I want it to support both. Any suggestion on the regex of how to make this work without breaking it?
    function wp_codebox_before_filter($content)
    {
      return preg_replace_callback(
          ”/\s*<(code|pre)}(?:lang=[\"']([\w-]*)[\"']|file=[\"']([\w-]*\.?[\w-]*)[\"']|colla=[\"']([\+\-])[\"']|line=[\"'](\d*|n)[\"']|\s)+>(.*)<\/(code|pre)>\s*/siU”,
          ”wp_codebox_substitute”,
          $content
      );

    Reply
  35. tom posted the following on 2008-11-05 at 9:10 下午.

    Just had the following error while clicking on ruby.txt :
     
    http://www.ericbess.com/ericblog/wp-content/plugins/wp-codebox/wp-codebox.php?p=134&download=ruby.txt

    Reply
    1. eric posted the following on 2008-11-06 at 10:25 上午.

      fixed

      Reply
  36. Chrislabricole posted the following on 2008-10-29 at 7:06 下午.

    Hi,
    Thanks for your plugin but it have 2 bugs :
    1) the numbers of lines are shifted over the code :s
     
    And 2) at the admin dashboard, for edit settings of you plugin, I get this :
    You are not a LEVEL 8 or above USER & hence you cannot configure WP-CodeBox. If you are a LEVEL 8 or above USER, then please Logout & Login again.
     
    Thanks by advance for your reply and if need, correct theses bugs… :)

    Reply
    1. eric posted the following on 2008-11-06 at 10:26 上午.

      fixed in new version.

      Reply
  37. funbsd posted the following on 2008-10-19 at 1:34 上午.

    刚才说的有误,第二步中应该像Werbeagentur-Wissen说的那样,只注释’&’ => ‘&amp;’就行了,如果都注释了,别的地方就有问题了。第三步对于javascript来说是必须的,其它语言视情况而定。暂时没有发现其它问题。

    Reply
  38. funbsd posted the following on 2008-10-19 at 12:53 上午.

    终于找到解决办法了。一是发布的时候必须写到源代码里,代码中如果有<,其后必须是空格,不能是其它任何字符,否则返回可视化编辑器修改时会被认为非法html标签,其后内容会被删除。二是修改wp-codebox/geshi/geshi.php,将function hsc里的’&’ => ‘&amp;’,'”‘ => ‘&quot;’,'<’ => ‘&lt;’, ‘>’ => ‘&gt;’,注释掉,前面留言的Werbeagentur-Wissen已经提到了。三是修改wp-codebox/geshi/geshi/javascript.php,将’SYMBOLS’ => array中的&去掉或者改成&&,这根据你要发布的语言种类不同而不同

    Reply
  39. funbsd posted the following on 2008-10-18 at 2:32 下午.

    又研究了一下,发现如果直接粘贴到源代码里,紧挨着<后边有字符的话,返回可视化编辑器时,可视化编辑器就认为这是html标签,而这个标签不是有效的话,后边的内容就会被删除。如果直接粘贴到可视化编辑器里,可视化编辑器会对粘贴的代码重新进行编排,加些<br>之类的标签,再从wp-codebox输出时,就肯定不正确了。所以只能粘贴到源代码里,且不能有被可视化编辑器认为是html标签的字符串。这样粘贴之后,从源代码返回可视化编辑器时,可视化编辑器不会对代码重新进行编排,只是将特殊字符<>”&等变成&lt;&gt;&quot;&amp;。按说这样就应该可以了,可是我的wp-codebox不能把这些特殊字符变回原样,还是显示&lt;&gt;&quot;&amp;,不知道什么原因。请帮帮忙,给点提示。

    Reply
  40. funbsd posted the following on 2008-10-18 at 12:49 下午.

    郁闷啊,折腾半天了,<和>问题还是搞不定。一碰到<或者>,返回可视化编辑器里就被截断了,<>后边啥都没有了。除非发布出来不修改了,否则回来修改又啥都没了。要是直接在可视化编辑器里粘贴代码,发布出来就全是html代码。我用的是javascript,里边有个<号就不行了,到底该咋办啊?看了半天也没看明白后边评论里有啥有效的好办法

    Reply
  41. hightflty posted the following on 2008-09-29 at 5:54 下午.

    Fatal error: Cannot redeclare class geshi in /home/content/h/i/g/hightfly/html/blog/wp-content/plugins/wp-codebox/geshi/geshi.php on line 243

    Reply
  42. DaB. posted the following on 2008-09-18 at 10:20 下午.

    @kyle:
    I had the same problem: I just comment the line out – it seems to work here.
    Sincerly,
    DaB.

    Reply
  43. Werbeagentur-Wissen posted the following on 2008-09-16 at 5:30 上午.

    for everyone with problems like EcApS – just open /wp-codebox/geshi/geshi.php, look where the function hsc is defined and outcomment the first escape- array element(”&”). different wp users, different usages ;)

    Reply
  44. midou posted the following on 2008-09-13 at 12:25 下午.

    I have just insttaled it.. the html code doesn’t get colored unfortunately, but it’s quite great thank you!

    Reply
  45. ez posted the following on 2008-09-11 at 2:32 上午.

    Hi,Is there a way to set the “height” of the codebox? For example, I would like to set the height to 15 lines, and if my code is longer, it just adds a vertical scrollbar.Thanks! 

    Reply
  46. 沙渺 posted the following on 2008-06-05 at 2:56 下午.

    &gt ; 的意思是说pre标签中出现><号必须使用&gt ;和&lt ;。本来在pre标签中使用&gt ;和&lt ;是能正确显示的,但加上GESHI之后就不能正确解析。这个问题是GESHI的问题,不是插件的问题。但的确希望作者能尽量修正。在pre标签中直接使用><可以解决这个问题,并且在ie67和ff中都正确。但造成的后果是不能通过xhtml1.0验证。我想这虽然可行,但不是件好事。

    Reply
    1. bochgoch posted the following on 2008-06-11 at 12:12 上午.

      Excellent plugin – I need to override some CSS to tidy things up, but excellent – thanks!

      Reply
  47. Ender Xie posted the following on 2008-05-16 at 10:04 下午.

    I finnaly get it worked in my WP blog.We are supposed to edit the code in “Code” view, not in “Visual”, then everything works fine.Nice work, pal.

    Reply
  48. yixia posted the following on 2008-05-16 at 11:19 上午.

    $hHead .= “<!–[if IE]>\n<style type\”text/css\”>\n”; $hHead .= “.wp_codebox { overflow-x: auto; overflow-y: hidden; padding-bottom: expression(this.scrollWidth > this.offsetWidth ? \”15px\” : 0); width: 100%; }\n”; $hHead .= “</style>\n<![endif]–>”;
    把这个加到
    function codebox_header()
    并删掉css中的/*ie hack*/部分来通过css校验

    Reply
  49. yixia posted the following on 2008-05-16 at 9:56 上午.

    再来,如果在后台settings-writing中开启了WordPress should correct invalidly nested XHTML automatically
    那么像<?php 就会变成< ?php多了一个空格,<!-会变成< !-能不能自动把这个filter跳过去 :?:

    Reply
  50. yixia posted the following on 2008-05-13 at 10:40 下午.

    重新修改了一点点代码,为了精简输出的html,去掉不需要的id地址还是在http://www.e-xia.com/2008/05/wp-codebox-122-bug-fix/不过不理解的就是为什么要放cookie呢?是不是以后想保持开关的状态?做的时候碰到一点点小问题,真是哭笑不得,平时都是onclick=”javascript:function()”,然后在function里就可以直接用this来获得调用这个function的object,我首页的achive list前面的[+]也是这么做的,基本上是一样的javascript,一样的html,但是在wpcd_toggle_collapse里调用this就是不对,最后只能把this当一个参数传进来了,相当郁闷,你知道是为什么吗?上次压缩包里面的js好像放错folder了,这次的也改正了,有兴趣的话就再下一次吧。还有你说的”n”不能copy没试出来,反正用你给的3个例子,都能成功copy,可能是我理解有误,也有可能是js放错的关系。

    Reply
  51. yixia posted the following on 2008-05-09 at 11:54 下午.

    不知道为什么这个插件在我的blog上就是不起作用,在active插件时不报错,更改设置也不报错,在html源文件里能看到引用了codebox的js和css
    我在html编辑状态下添加的<pre…,在可见即可得模式下也试过,都失败了,我还禁用了所有插件,同样不起作用。我直接copy了这里的示例代码,也没用
    怎样才能确切知道这个插件是不是起作用了呢,在html源文件会有什么变化?

    Reply
    1. yixia posted the following on 2008-05-10 at 12:23 上午.

      原因找到,是因为下载的版本不正确引起的
      http://downloads.wordpress.org/plugin/wp-codebox.zip
      这里下载的,没敢用迅雷,右键直接下载的
      另外,报告bug一个:在main.php里的get_settings(’home’)请改成get_settings(’siteurl’),因为我的index.php不在安装目录,如果用home的话引用js和css会报错。
      另一个bug是<和>都显示&lt;和&gt;这个不知道是不是和别的插件冲突,明天继续测试。
      谢谢提供那么好的插件

       

      Reply
      1. yixia posted the following on 2008-05-11 at 7:30 下午.

        把我前面写得留言都删掉吧,谢谢,自己都觉得太罗嗦了 :oops:
        不过今天又继续抓虫,因为真的很喜欢这个插件。
        主要是copy to clipboard这个方法,因为只能在ie而且是在expand的时候才能用,所以在php代码里面加了如果不是ie隐藏这个链接,在javascript里面加了如果显示[-]的时候隐藏这个链接
        还有,现在的view和download都把代码第一行最前面的空格去掉了,不是很舒服,所以把trim都去掉了,download的正则表达式加了<pre….>.*\n(来去掉最前面的一个空行。
        发在http://www.e-xia.com/?p=58,如果有兴趣的话可以看一下。
        另外我找到了http://www.jeffothy.com/weblog/clipboard-copy/这个写了如何在firefox下实现copy to clipboard,不过因为当中要引用了一个swf,不知道怎么把这个的地址放到js里,能想到的只能是参数传递,不太舒服,所以也就没有用了。

        Reply
        1. eric posted the following on 2008-05-12 at 9:23 下午.

          感想您对WPCD的支持, 你所做的修改正是WPCD所欠缺的。我正在逐个把你做的修改做测试并加到发布版,在changlog日志中加上了贡献人信息。
          同时也向你报告你的修改文件的一个bug. line=”n” 时 copy to clipboard无作用。
          &lt,&gt问题是wordpress editor hooks 在捣鬼,应该是可以解决的。

          Reply
        2. yixia posted the following on 2008-05-13 at 5:09 下午.

          没想到你真的会看哦,很感动的说,其实我从来都不用copy to clipboard也就没有好好测试,我用firefox的,对ie的测试做得不好 :redface:

          Reply
  52. Michael posted the following on 2008-05-08 at 12:47 上午.

    Very nice plugin, thank you.
    This is another vote to keep the [Copy to Clipboard][+] visible at all times (with either word wrap or cleverer use of CSS)
    Thanks, I’m finding it very useful.

    Reply
  53. KimHoon posted the following on 2008-04-19 at 5:37 下午.

    Wonderful plugin ! but 1 more thing.
    How can I make word-wrap(no auto scrollbar) ?

    Reply
  54. Frank Wang posted the following on 2008-04-17 at 6:39 下午.

    can’t work with wordpress 2.5
    不能在2.5版下使用哦..
    希望早日更新

    Reply
    1. eric posted the following on 2008-05-07 at 9:37 下午.

      Try it again!

      Reply
  55. Becca posted the following on 2008-03-28 at 2:07 上午.

    When I wrap (without the spaces) around basic html, it breaks and doesn’t work.

    Reply
    1. Jeff posted the following on 2008-04-04 at 8:12 下午.

      You need to move the ‘copy to clipboard’ to the left sign. I use this for SQL scripts. When they are too long (and most are), you can’t see the ‘copy to clipboard’ unless you go to the bottom of the script and then use the scrollbar to scroll to the right. Most users don’t even realize it’s there as a result.

      Great plugin otherwise.

      Reply
      1. Jeff posted the following on 2008-04-04 at 8:13 下午.

        Oopss.. I meant left “side” obviously. Thx!

        Reply
  56. Chris posted the following on 2008-03-25 at 11:20 下午.

    Nice plugin but it breaks the Lightbox-2 plugin (http://wordpress.org/extend/plugins/lightbox-2/). If your WP-CODEBOX plugin is enabled at the same time as Lightbox-2, Lightbox-2 doesn’t work (it just shows the images in the browser window, i.e. the Ajax calls fail).

    FYI …

    Reply
  57. codefrenzy posted the following on 2008-03-23 at 2:43 下午.

    Hi there,

    Thanks for an awesome plugin.

    I’ve got it working by writing my posts in ‘code’ view in wordpress. However, when I edit the article, it goes back to the ‘visual’ view on wordpress. When I switch back to the ‘code’ view, the following happens:

    For php:
    1. becomes ?>
    3. ‘ becomes \’ and each time I edit the article, another \ (slash) is added

    Do you have any idea why this might be happening or am I doing something wrong?

    Cheers and thanks for the plugin!

    Reply
    1. codefrenzy posted the following on 2008-03-23 at 2:46 下午.

      Oops! Looks like my comment didn’t come through properly. I’ll try again.

      1. <?php disappears
      2. ?> becomes ?& gt; (without the space between & and gt; – I just can’t post that in this comment)
      3. ‘ becomes \’ and each time I edit the article, another \ (slash) is added

      Thanks again :)

      Reply
  58. EcApS posted the following on 2008-03-12 at 2:54 上午.

    Does no work with “>”
    exemple:

    echo aes >> /etc/modules
    echo dm_mod >> /etc/modules
    echo dm_crypt >> /etc/modules

    shown:

    echo aes &gt;&gt; /etc/modules
    echo dm_mod &gt;&gt; /etc/modules
    echo dm_crypt &gt;&gt; /etc/modules

    Reply
    1. eric posted the following on 2008-03-12 at 9:47 上午.
      1
      2
      3
      
      echo aes >> /etc/modules
      echo dm_mod >> /etc/modules
      //no problem!
      Reply
      1. Vladimir posted the following on 2008-06-02 at 2:56 上午.

        If Prototype or LightBox or ProtoBox or whatever does not work with WP CodeBox, you will have to do the following:
        Open /wp-content/plugins/wp-codebox/js/codebox.js and find these lines:
        function $(id) {
        return document.getElementById(id);
        }

        Then replace it with
        if (’undefined’ == typeof $) {
        function $(id)
        {
        return document.getElementById(id);
        }
        }

        Since Prototype’s $ function is extented with respect to CodeBox’s one, the code should work fine.
        Hope this helps.

        Reply
        1. MoebiuZ posted the following on 2008-07-07 at 3:40 上午.

          That is not working on IE7

          Reply
        2. eric posted the following on 2008-07-07 at 8:53 上午.

          I’am Ie 7, no problem!

          Reply
        3. MoebiuZ posted the following on 2008-07-08 at 3:29 上午.

          I mean, the workaround vladimir posted (and you integrated on wp-codebox). I’m using wp-codebox with lightbox-2 and codebox breaks the lightbox-2 script. On FF works fine.Anyway, I like too much your plugin, it’ the best I have seen on syntax highlighting.

          Reply
        4. Vladimir posted the following on 2008-06-02 at 3:10 上午.

          Eric, there is one more bug in the code: when creating a download link, you are using htmlspecialchars() function to screen special characters. However, by default, htmspecialchars() assumes iso-8859-1 charset, which is wrong for the most of blogs. So it would be more correct to use wp_specialchars() instead.

          Reply
        5. Ralph posted the following on 2008-06-04 at 9:32 下午.

          I get:
          Warning: Invalid argument supplied for foreach() in /home/xxx/public_html/wp-content/plugins/wp-codebox/geshi/geshi.php on line 2281 Warning: Invalid argument supplied for foreach() in /home/xxx/public_html/wp-content/plugins/wp-codebox/geshi/geshi.php on line 2281 Warning: Invalid argument supplied for foreach() in /home/xxx/public_html/wp-content/plugins/wp-codebox/geshi/geshi.php on line 2281 Warning: Invalid argument supplied for foreach() in /home/xxx/public_html/wp-content/plugins/wp-codebox/geshi/geshi.php on line 2281
          Any ideas?

          Reply
      2. cc posted the following on 2008-05-28 at 12:40 上午.

        还是楼上说的 <  > 问题
        我发现当在源代码模式写时,比如 <pre lang=”C”> p->q ……    如果立刻发布就没有问题
        可一旦我切回可视模式后,就会被转成  <pre lang=”C”> p-&gt;q …… 而这时发布就只能看到错误的形式了
        而且我试了其他几个代码高亮插件,同一个编辑器下,虽然编辑时显示的是 p-&gt;q  但发布后没有问题,可以看到 p->q
        所以应该不是编辑器的问题,希望老大解决
        还有一个就是行号这一栏有时莫名其妙的非常宽,包括您这里的几个例子也是,应该不是我浏览器的问题吧(我用的是firefox)
         

        Reply
        1. cc posted the following on 2008-05-28 at 12:41 上午.

          贴个图给您看看 http://i264.photobucket.com/albums/ii169/coffeecat10/code.jpg

          Reply

Leave a reply

  1. You will post the following soon.
    Go ahead and start typing.