前言介紹
- 這款 WordPress 外掛「WP Colored Coding」是 2012-08-13 上架。
- 目前有 20 個安裝啟用數。
- 上一次更新是 2014-09-05,距離現在已有 3894 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.9.2 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
rainbow.js | code samples | syntax highlighting |
內容簡介
這個外掛將酷炫的 JavaScript 語法高亮器 Rainbow.js 引入您的 WordPress-Blog 中,使您能夠獨立管理程式碼片段而不受文本編輯器的影響。
重要!- 這個外掛已經不再經過 PHP 5.2 的測試!
快速開始
從此頁面下載外掛
按照WordPress Codex上的說明安裝插件。
預設情況下,插件在啟用後即可使用。某些選項可以在「設定」→「撰寫」中更改。
有關詳細的使用手冊,請參閱使用說明,或 – 比起言之無物 – 可以參考螢幕截圖。
如果您想更改插件的行為,請參閱API 文件
設定
預設情況下,插件在啟用後即可使用。某些選項可以在「設定」→「撰寫」中更改。
原始輸出
這個選項為每個文章的程式碼塊啟用了額外的核取方塊,這允許您為該程式碼片段禁用esc_attr()過濾器。這意味著,每個 HTML 和 JavaScript 在這個文本區域內都將像它們一樣被瀏覽器解析,因此請謹慎使用這個選項。
使用方式
程式碼塊
(在文章的上下文中) 單個程式碼塊是通過它的名稱來識別的。如果您不想為每個代碼塊指定名稱,可以將其留空,它將自動生成。
語言字段也是可選的。要使用語法高亮,使用 Rainbow 支持的語言編寫。(它會給您建議。) 目前支援以下語言:
* C
* Coffeescript
* C#
* CSS
* Go
* HTML
* Java
* JavaScript
* Lua
* PHP
* Python
* R
* Ruby
* Shell
* Smalltalk
每個程式碼塊都可以通過使用短碼 [cc name="{name}"] 放置在文本的任何地方。您可以使用 TinyMCE 按鈕»CC«來進行操作。
短碼 (內部程式碼)
對於僅有幾行程式碼,您可以使用類似如下的短碼:
[cc lang="javascript"]
var str = 'Hello World';
alert( str );
[/cc]
貢獻和錯誤報告
有關錯誤報告或新功能的想法,請使用Gitub 上的問題站。
API
提供以下過濾器:
wp_cc_rainbow_themes
wp_cc_rainbow_scripts
wp_cc_rainbow_languages
添加新佈景主題非常容易。僅需像這樣擴展佈景主題陣列的鍵即可:
/**
* @param array $themes
* @return array
*/
function my_new_rainbow_theme( $themes ) {
$themes[ 'my_theme' ] = array(
'src' => //樣式表的絕對URI
'name' => 'My Theme'
);
return $themes;
}
add_filter( 'wp_cc_rainbow_themes', 'my_new_rainbow_theme' );
要添加受支持的語言,請使用
/**
* @param array $scripts
* @return array
*/
function my_new_rainbow_script( $scripts ) {
原文外掛簡介
Brings the cool Javascript syntax highlighter Rainbow.js to your WordPress-Blog and allows you to manage code snippets independend from the text editor.
IMPORTANT! – This plugin is no longer testet with PHP 5.2!
Quick Start
Download the plugin from this page
Follow the instructions on the WordPress Codex to install the plugin.
By default, the plugin is ready for use after activation. Some options can be changed on Settings → Writing.
For a detailed usage manual refer to the Usage section, or – better than a thousand words – to the screenshots.
If you want to change the behaviour of the plugin see the API-Documentation
Settings
By default, the plugin is ready for use after activation. Some options can be changed on Settings → Writing.
Raw output
This option enables an additional checkbox for each codeblock of a post which allows you to disable the esc_attr() filter for that code snippet. That means, every HTML and Javascript inside this textarea will be parsed by the browser as those. So be carefull with this option.
Usage
Codeblocks
A single Codeblock is identified (in the posts context) by its name. If you don’t want to specify a name for each block, leave it empty, it will be generated automatically.
The language field is also optional. To use syntax highlighting, write in a rainbow supported language. (It will give you suggestions.) Currently these are
* C
* Coffeescript
* C#
* CSS
* Go
* HTML
* Java
* JavaScript
* Lua
* PHP
* Python
* R
* Ruby
* Shell
* Smalltalk
Each codeblock can be placed anywhere in the text by using the shortcode [cc name="{name}"]. You can use the TinyMCE button »CC« for that.
Shortcode (in-text code)
For just a few lines of code you may want to use the shortcode like this:
[cc lang="javascript"]
var str = 'Hello World';
alert( str );
[/cc]
Contribution & Bug-Report
For bug reports or ideas for new features, please use the issue tracker on gitub.
API
The following filters are provided:
wp_cc_rainbow_themes
wp_cc_rainbow_scripts
wp_cc_rainbow_languages
Adding a new Theme is quite easy. Just expend the themes-array by a key like this
/**
* @param array $themes
* @return array
*/
function my_new_rainbow_theme( $themes ) {
$themes[ 'my_theme' ] = array(
'src' => //the absolute URI to the stylesheet
'name' => 'My Theme'
);
return $themes;
}
add_filter( 'wp_cc_rainbow_themes', 'my_new_rainbow_theme' );
To add a supported language use
/**
* @param array $scripts
* @return array
*/
function my_new_rainbow_script( $scripts ) {
$scripts[ 'my_new_lang' ] = array(
'src' => //the absolute URI to the script
'depth' => array( 'rainbow' ),
'lang' => 'my_new_lang',
'in_footer' => TRUE # this must be equal with the script it depends on
);
# to override the built-in rainbow version use the key 'rainbow'
return $scripts;
}
add_filter( 'wp_cc_rainbow_scripts', 'my_new_rainbow_script' );
/**
* @param array $langs
* @return array
*/
function my_new_lang( $langs ) {
$langs[ 'my_new_lang' ] = 'My new lang';
return $langs;
}
add_filter( 'wp_cc_rainbow_languages', 'my_new_lang' );
Deactivation/Uninstallation
If you deactivate the plugin all settings and codes will be preserved. On uninstallation (delete), all settings and codes will be deleted finally. If this is triggered from the network-admin page, all blogs will be cleaned up.
Acknowledgement
Thanks to sparanoid for chinese translation
Thanks to @volleyballfisch for spanish translation
Thanks to yonjah for JS Bugfixing
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WP Colored Coding」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.2 | 1.1.0 | trunk | 2014.08.19 |
延伸相關外掛(你可能也想知道)
暫無相關外掛推薦。