如何高亮显示程序代码?

字体 -

首先,在管理区的插件菜单下激活 coolcode 插件。

由于coolcode插件不支持,因此您需要在“我的帐户”中关闭超文本编辑器,并在管理中心的 “选项”—>“写作”中禁用“自动修正错误的内嵌式 XHTML 语法”,然后使用以下语法即可。

[ coolcode ] 代码 [ /coolcode ]

如果要加亮具体的语言,可以用 lang 属性来指定:

[ coolcode lang=”程序设计语言” ] 代码 [ /coolcode ]

如果不需要行号,可以使用 linenum 属性来指定:

[ coolcode lang=”程序设计语言” linenum=”off” ] 代码 [ /coolcode ]

如果希望可以直接以文件下载代码,可以使用 download 属性来指定:

下载: example.txt

[ coolcode lang=”程序设计语言” download=”文件名.扩展名” ] 代码 [ /coolcode ]

这三个属性可以组合使用,互不影响。

目前支持的程序设计语言有:

  • actionscript
  • cpp
  • css
  • diff
  • dtd
  • html
  • java
  • javascript
  • mysql
  • perl
  • php
  • python
  • ruby
  • sql
  • xml

以下是高亮代码样例:

在编辑器中输入:

[ coolcode lang="php" linenum="on" download="sample.php" ] echo "Hello World!"; [ /coolcode ]

显示为:

下载: sample.php
  1. echo "Hello World!";

注:在评论中也可使用该语法。

分享博文至:

    36 条评论

  1. 1. oakley sunglasses discount code - 2013年8月10日 01:15

    无忧博客帮助站 » 如何高亮显示程序代码?

  2. 2. oakley sunglasses uk - 2013年8月12日 05:56

    无忧博客帮助站 » 如何高亮显示程序代码?

  3. 3. chaussures louboutin pas cher - 2013年8月12日 08:07

    无忧博客帮助站 » 如何高亮显示程序代码?

  4. 4. Itamar Serpa Fernandes - 2017年3月21日 10:05

    Hey there! This post could not be written any better! Reading this post reminds me of my good old room mate! He always kept talking about this. I will forward this write-up to him. Pretty sure he will have a good read. Thanks for sharing!

  5. 5. Georges Sadala - 2017年3月23日 02:36

    My brother recommended I may like this web site. He was once entirely right. This publish truly made my day. You can not consider just how much time I had spent for this information! Thanks!

  6. 6. refuse sales opportunities - 2017年3月23日 10:59

    great submit, very informative. I’m wondering why the opposite specialists of this sector don’t realize this. You should proceed your writing. I am sure, you have a great readers’ base already!

  7. 7. Ahmed - 2017年3月24日 01:56

    My brother suggested I would possibly like this blog. He used to be entirely right. This publish truly made my day. You can not consider simply how so much time I had spent for this information! Thank you!

  8. 8. sales skills identifying - 2017年3月25日 14:26

    Hey there! I know this is sort of off-topic but I needed to ask.

    Does running a well-established blog such as yours take a massive amount work? I am brand new to writing a blog however I do write in my diary daily. I’d like to start a blog so I can easily share my own experience and views online. Please let me know if you have any kind of ideas or tips for new aspiring bloggers. Thankyou!

  9. 9. model baju hem lengan panjang - 2017年4月1日 17:45

    Sweet blog! I found it while surfing around on Yahoo News.

    Do you have any tips on how to get listed in Yahoo News?

    I’ve been trying for a while but I never seem to get there! Thank you

  10. 10. Augusto de Arruda Botelho - 2017年4月5日 00:42

    I could not resist commenting. Very well written!

  11. 11. Itamar Serpa Fernandes - 2017年4月5日 08:40

    Right now it looks like Drupal is the best blogging platform available right now. (from what I’ve read) Is that what you’re using on your blog?

  12. 12. organized garbage collection - 2017年4月6日 15:16

    When someone writes an post he/she keeps the thought of a user in his/her brain that how a user can know it. Therefore that’s why this paragraph is great. Thanks!

  13. 13. Dewayne - 2017年4月7日 09:48

    Ridiculous quest there. What happened after? Good luck!

  14. 14. Romeo - 2017年4月8日 19:02

    Hi there, I read your new stuff regularly. Your story-telling style is witty, keep doing what you’re doing!

  15. 15. Felipe - 2017年4月10日 19:50

    Why visitors still use to read news papers when in this technological globe all is accessible on web?

  16. 16. Agnes - 2017年4月11日 09:50

    Very quickly this website will be famous amid all blogging and site-building people, due to it’s good posts

  17. 17. Augusto de Arruda Botelho - 2017年4月13日 13:01

    Greate post. Keep posting such kind of information on your page. Im really impressed by it. Hi there, You’ve done a great job. I’ll definitely digg it and for my part suggest to my friends. I’m confident they will be benefited from this web site.

  18. 18. Jaimie - 2017年4月13日 17:16

    That is very attention-grabbing, You are an overly skilled blogger.

    I’ve joined your rss feed and look forward to looking for extra of your wonderful post. Also, I have shared your web site in my social networks

  19. 19. Augusto de Arruda Botelho - 2017年4月13日 19:55

    No matter if some one searches for his essential thing, thus he/she desires to be available that in detail, thus that thing is maintained over here.

  20. 20. rental earnings - 2017年4月18日 02:27

    Useful info. Fortunate me I found your web site by accident, and I am shocked why this coincidence did not happened earlier! I bookmarked it.

发表评论