內容簡介
這個外掛使用基於 Pygments 的伺服器端語法高亮軟體。
安裝:
在使用這個外掛前,你需要先在伺服器上安裝 Pygments:
sudo apt-get install python-setuptools
easy_install Pygments
這就是全部安裝步驟,現在你可以下載這個外掛,並在 WordPress 中進行安裝。
用法
安裝完這個外掛後,用法很直覺。只需要用相對應語言的標籤包裹你的程式碼即可:
[javascript]....[/javascript]
[php]....[/php]
可以前往“Languages and filetypes supported” 查看所有可用的語言。
參數
標籤支援一些參數(全部是可選的):
[php **style**="manni" **linenumbers**="table"]....[/php]
style="manni" 為程式碼樣式。目前有 22 種可用風格。<br>
預設的樣式為 default,非常美觀,但你可能會喜歡其他樣式。請查看“Color styles”章節。
如果將 “linenumbers” 設置為 inline 或 table,行數就會以獨立表格列的方式顯示,或是成為該行的一部分。
範例
`
[javascript]
//comment line
var foo = “foo”;
var bar = function(){
var baz;
}
[/javascript]
`
輸出以預設風格高亮的 JavaScript 程式碼,並且不加行數。
`
[javascript style=”monokai” linenumbers=”inline”]
//comment line
var foo = “foo”;
var bar = function(){
var baz;
}
[/javascript]
`
輸出以 monokai 風格高亮的 JavaScript 程式碼,並且加入行數(成為該行的一部分)。
`
[javascript style=”monokai” linenumbers=”table”]
//comment line
var foo = “foo”;
var bar = function(){
var baz;
}
[/javascript]
`
輸出以 monokai 風格高亮的 JavaScript 程式碼,並且加入行數(獨立表格列)。
顏色風格
這些是支援的顏色風格:
monokai
manni
rrt
perldoc
borland
colorful
default
murphy
vs
trac
tango
fruity
autumn
bw
emacs
vim
pastie
friendly
native
支援的語言和文件類型
Pygments 不僅可以高亮語言,也支援像是 .conf、Nginx 設定檔、Apache(以檔名 .htaccess、apache.conf、apache2.conf 來識別),等多種文件類型。
注意:要查看使用方法,請前往 “Usage” 章節。
important sdsd;
General
apacheconf:(.htaccess, apache.conf, apache2.conf)
bash、sh、ksh:
(*.sh, *.ksh, *.bash, *.ebuild, *.eclass, .bashrc, bashrc)
ini、cfg:(*.ini, *.cfg)
makefile:
(.mak, Makefile, makefile, Makefile., GNUmakefile)
nginx:(.conf)
外掛標籤
開發者團隊
原文外掛簡介
Server side syntax highlighter based on Pygments highlighter software.
Installation:
To use this plugin you need pygments in your server:
sudo apt-get install python-setuptools
easy_install Pygments
That’s all. Now you can download the plugin and install it in your WordPress.
Usage
Once you get installed the plugin the usage is straightforward. just enclose your code between tokens named with the corresponding lang:
[javascript]....[/javascript]
[php]....[/php]
See “Languages and filetypes supported” section to know available languages.
Parameters
Tokens support a few parameters (all optionals):
[php **style**="manni" **linenumbers**="table"]....[/php]
style="manni" defines code styling. Currently are 22 available styles.
Default styling is default wich is very nice, but maybe you like other styles. see “Color styles” section.
If you set “linenumbers” to inline or table, the line numbers will be added as independent table column or as part of the line.
Examples
`
[javascript]
//comment line
var foo = “foo”;
var bar = function(){
var baz;
}
[/javascript]
`
Outputs highlighted js with default style, and no line numbers.
`
[javascript style=”monokai” linenumbers=”inline”]
//comment line
var foo = “foo”;
var bar = function(){
var baz;
}
[/javascript]
`
Outputs highlighted js with monokai style with line numbers (as part of the line).
`
[javascript style=”monokai” linenumbers=”table”]
//comment line
var foo = “foo”;
var bar = function(){
var baz;
}
[/javascript]
`
Outputs highlighted js with monokai style with line numbers (as new column).
Color styles
These are supported color styles:
monokai
manni
rrt
perldoc
borland
colorful
default
murphy
vs
trac
tango
fruity
autumn
bw
emacs
vim
pastie
friendly
native
Languages and filetypes supported
Pygments not only highlights languages. also highlights filetypes like .conf Nginx configuration file, Apache (filenames .htaccess, apache.conf, apache2.conf), etc.
NOTE: to use see “Usage” section
important sdsd;
General
apacheconf: (.htaccess, apache.conf, apache2.conf)
bash, sh, ksh:
(*.sh, *.ksh, *.bash, *.ebuild, *.eclass, .bashrc, bashrc)
ini, cfg: (*.ini, *.cfg)
makefile:
(.mak, Makefile, makefile, Makefile., GNUmakefile)
nginx:
Nginx configuration file
yaml:
(*.yaml, *.yml)
perl:
Perl (*.pl, *.pm)
vb.net:
VB.net (*.vb, *.bas)
console:
Bash Session (*.sh-session)
Javascript
javascript: Pure Javascript
coffeescript: Pure CoffeeScript
json: Pure JSON
PHP
cssphp: PHP embedded in CSS
htmlphp: PHP embedded in HTML
jsphp: PHP embedded in JS
php: Pure PHP
xmlphp: PHP embedded in XML
Ruby
ruby, duby: Ruby (*.rb, *.rbw, *.rake, *.gemspec, *.rbx, *.duby)
csserb, cssruby: Ruby embedded in CSS
xmlerb, xmlruby: Ruby embedded in XML
CSS and CSS compilers
css:
CSS (*.css)
sass:
Sass (*.sass)
scss:
SCSS (*.scss)
HTML and HTML template systems
html:
HTML (*.html, *.htm, *.xhtml, *.xslt)
haml:
Haml (*.haml)
jade:
Jade (*.jade)
SQL
sql:
SQL (*.sql)
sqlite3:
sqlite3con (*.sqlite3-console)
mysql:
MySQL
Python, jinja & Django
python: Pure Python
python3: Pure Python 3
xmldjango, xmljinja: Django/Jinja embedded in XML
cssdjango, cssjinja: Django/Jinja embedded in CSS
django, jinja: Pure Django/Jinja
htmldjango, htmljinja: Django/Jinja embedded in HTML
jsdjango, jsjinja: Django/Jinja embedded in Javascript
Java && family
java:
Java (*.java)
clojure:
clojure (*.clj)
groovy:
Groovy (*.groovy)
jsp:
Java Server Page (*.jsp)
C, C++, Objetive-c, C Sharp
cobjdump: c-objdump (*.c-objdump)
c: C (*.c, *.h, *.idc)
cpp: C++ (*.cpp, *.hpp, *.c++, *.h++, *.cc, *.hh, *.cxx, *.hxx)
csharp: C# (*.cs)
objectivec: (*.m)
XML
xml: (*.xml, *.xsl, *.rss, *.xslt, *.xsd, *.wsdl)
xslt: (*.xsl, *.xslt)
