如何高亮显示程序代码?

字体 -

首先,在管理区的插件菜单下激活 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!";

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

分享博文至:

    42 条评论

  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.

  21. 21. Augusto de Arruda Botelho - 2017年4月19日 10:35

    If some one wants to be updated with most up-to-date technologies therefore he must be visit this website and be up to date all the time.

  22. 22. Arleen - 2017年4月24日 19:21

    Hi! I understand this is kind of off-topic but I had to ask. Does running a well-established website like yours require 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 share my personal experience and feelings online.

    Please let me know if you have any ideas or tips for brand new aspiring blog owners. Thankyou!

  23. 23. Egli Diana Pinto - 2017年4月27日 15:06

    Thanks to my father who shared with me concerning this webpage, this web site is really amazing.

  24. 24. wiki.hvnh.edu.vn - 2017年5月2日 14:24

    Simply desire to say your article is as amazing. The clarity in your post is just cool and i can assume you’re an expert on this subject.

    Fine with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please continue the rewarding work.

  25. 25. Adriana - 2017年5月3日 20:40

    Hello, I think your site might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, amazing blog!

  26. 26. Taylor - 2017年5月5日 01:20

    Unquestionably believe that which you said. Your favorite reason appeared to be on the internet the easiest thing to be aware of. I say to you, I definitely get annoyed while people think about worries that they plainly do not know about. You managed to hit the nail upon the top and also defined out the whole thing without having side-effects , people can take a signal. Will probably be back to get more. Thanks

  27. 27. Scarlett - 2017年5月5日 16:58

    First off I would like to say wonderful blog! I had a quick question which I’d like to ask if you don’t mind. I was interested to find out how you center yourself and clear your thoughts prior to writing.

    I have had a difficult time clearing my thoughts in getting my thoughts out. I do enjoy writing however it just seems like the first 10 to 15 minutes are lost just trying to figure out how to begin. Any suggestions or tips? Cheers!

  28. 28. Lavon - 2017年5月6日 11:52

    Good site you have here.. It’s hard to find high-quality writing like yours these days. I honestly appreciate individuals like you! Take care!!

  29. 29. Trudi - 2017年5月8日 07:08

    Definitely consider that that you said. Your favourite reason seemed to be at the net the simplest factor to remember of.

    I say to you, I certainly get annoyed whilst folks consider concerns that they plainly do not recognise about. You managed to hit the nail upon the highest and outlined out the entire thing with no need side-effects , other folks could take a signal.

    Will likely be back to get more. Thanks

  30. 30. makanan sehat bayi 6 bulan - 2017年5月11日 23:35

    Link exchange is nothing else however it is just placing the other person’s weblog link on your page at suitable place and other person will also do same in support of you.

  31. 31. Silvia Odete Morani Massad - 2017年5月17日 12:12

    When someone writes an article he/she keeps the idea of a user in his/her brain that how a user can understand it. Thus that’s why this piece of writing is amazing. Thanks!

  32. 32. Silvia Odete Morani Massad - 2017年5月17日 15:11

    I do not even know how I ended up here, but I thought this post was great. I don’t know who you are but definitely you’re going to a famous blogger if you are not already ;) Cheers!

  33. 33. Sven - 2017年5月17日 18:27

    Good site you’ve got here.. It’s hard to find excellent writing like yours nowadays.

    I truly appreciate individuals like you! Take care!!

  34. 34. Silvia Odete Morani Massad - 2017年5月18日 04:52

    Hi! Someone in my Myspace group shared this site with us so I came to check it out. I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers! Great blog and excellent design.

  35. 35. http://www.antiksalan.is/ - 2017年5月19日 09:04

    Howdy! I know this is kinda off topic nevertheless I’d figured I’d ask. Would you be interested in exchanging links or maybe guest writing a blog article or vice-versa? My site addresses a lot of the same topics as yours and I feel we could greatly benefit from each other.

    If you happen to be interested feel free to shoot me an e-mail.

    I look forward to hearing from you! Terrific blog by the way!

  36. 36. Why does it hurt right above my heel? - 2017年7月21日 18:42

    My brother suggested I might like this website. He used to be entirely right. This post actually made my day. You cann’t imagine simply how much time I had spent for this information! Thanks!

  37. 37. What causes burning pain in Achilles tendon? - 2017年9月3日 15:56

    Hey! I know this is somewhat off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having trouble finding one?

    Thanks a lot!

    Here is my page: What causes burning pain in Achilles tendon?

  38. 38. happy wheels - 2017年9月12日 22:18

    Very nice post. I just stumbled upon your weblog and wished to say that I have truly enjoyed surfing around your site and its posts.

  39. 39. happy wheels demo - 2017年9月12日 22:19

    Wonderful post!!! Genuinely loved this kind of post. Although I want much more information on like precious subject matter.

  40. 40. Lelio Vieira Carneiro Junior - 2017年11月9日 19:55

    bookmarked!!, I love your website!

  41. 41. coconut oil when - 2019年11月15日 13:31

    Hi my loved one! I wish to say that this post is amazing, nice written and come with approximately all significant infos. I would like to look more posts like this .

  42. 42. tinyurl.com - 2019年11月21日 15:35

    Good day! This post couldn’t be written any better! Reading this post reminds me of my good old room mate! He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thanks for sharing!

发表评论