[WordPress] 外掛分享: Prettify GC Syntax Highlighter

前言介紹

  • 這款 WordPress 外掛「Prettify GC Syntax Highlighter」是 2011-02-15 上架。
  • 目前有 30 個安裝啟用數。
  • 上一次更新是 2012-08-28,距離現在已有 4631 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.0.5 以上版本才可以安裝。
  • 有 3 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

lexn |

外掛標籤

prettify | google code | Prettify.js | syntax highlighter |

內容簡介

此外掛直接複製了美化程式庫 prettify.js 從 google-code source browser。如此您的程式碼將會長得和在 google-code 上一模一樣。
CSS 被稍微修改了,以加粗關鍵詞和型別。

授權

授權詳情請見 prettify.js(Apache License 2.0)。其他檔案採用 GPLv2 授權。

使用方式


// 在這裡加入你的程式碼。

或使用短碼:

[code]
// 在這裡加入你的程式碼。
[/code]

保護程式碼中的 HTML 標籤

這個外掛能自動使你的程式碼被 HTML 安全地保護:


任何出現在這裡的文字都會不經修改地顯示在頁面上。
例如:

若要避免你的程式碼被修改,請把 "dontquote" 加在第一個類別上。


請留意需要自行修改 HTML 語法。
例如:<head></head><body></body>

編號行

以下方法可以啟用編號行:


// 在這裡加入你的程式碼。

如果你想要從第 42 行開始編號,請加入以下參數:


// 在這裡加入你的程式碼。

將某些行文字標示

當編號行被啟用時,你可以使用 highlight 類別來將一或多個行標示出來:


// 第 2 行
// 第 3 行
// 第 4 行

你也可以標示出一或多個程式碼區塊:


// 第 2 行
// 第 3 行
// 第 4 行
// 第 5 行

注意:當編號行未啟用時無法使用這個功能。

指定語言

大部分時候這個採用高亮字的功能會自動猜測程式碼的語言。但是,為了取得最好的效果,請明確指定語言:


// 在這裡加入你的程式碼。

把 YOURLANG 換成以下之一:

aea
agc
apollo
bsh
c
cc
cl
cpp
cs
csh
css-str
cv
cxx
cyc
default-markup
el
fs
go
hs
htm
html
java
js
json
lisp
lua
m
ml
mxml
perl
pl
pm
proto
py
rb
scala
scm
sh
sql
vhd
vhdl
wiki
xhtml
xml
xsl
yaml
yml

短碼

以下是一個快速範例。所有參數都是可選的。

[code lang=”scala” start=”1″ highlight=”1-3,6,10-14″ background=”#C0FFB3″]
// 在這裡加入你的程式碼。
[

原文外掛簡介

This plugin has prettify.js copied directly from google-code source browser. So your code will look exactly like it does on google-code.
CSS is slightly modified to embolden keywords and types.
License
See prettify.js for license details (Apache License 2.0). Other files are available under GPLv2.
Usage

  // Put your code here.

Or with shortcode:
[code]
// Put your code here.
[/code]
Making Code HTML Safe
The plugin automatically makes highlighted code html-safe:

  Anything that goes here will be quoted to appear on the page as-is.
  For example: 

To avoid quoting your code, add dontquote as the first class.

  Remember to quote manually.
  For example: 

Line Numbering
Line numbdering can be enabled as follows:

  // Put your code here.

If you want to start with a line number 42, you can do the following:

  // Put your code here.

Highlighting Lines
When line numbering is enabled you can highlight one or several lines of code using the highlight class:

  // line 2
  // line 3
  // line 4

Alternatively you can highlight one or several code segments:

  // line 2
  // line 3
  // line 4
  // line 5

Note: This feature is not available when line numbering is disabled.
Specifying Language
Most of the time the highlighter will do a good job guessing how to highlight the code. However, to achieve the best result, you should specify the language:

  // Put your code here.

Replace YOURLANG with one of the following:

aea
agc
apollo
bsh
c
cc
cl
cpp
cs
csh
css-str
cv
cxx
cyc
default-markup
el
fs
go
hs
htm
html
java
js
json
lisp
lua
m
ml
mxml
perl
pl
pm
proto
py
rb
scala
scm
sh
sql
vhd
vhdl
wiki
xhtml
xml
xsl
yaml
yml

Shortcode
Here is a quick example. All the parameters are optional.
[code lang=”scala” start=”1″ highlight=”1-3,6,10-14″ background=”#C0FFB3″]
// Put your code here.
[/code]
Html quoting can be disabled as follows:
[code quote=”false”]
// Put your code here.
[/code]
The contents of shortcodes is auto-formatted by WP. As a result

and
tags along
with some formatting will be lost. If you need to preseve the original formatting use
html notation instead of the shortcode.
Please Support
If you like Prettify GC Syntax Highlighter plugin, please donate a minute of your time and vote for it. Thank you!

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Prettify GC Syntax Highlighter」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.2 | 1.4 | 1.3.1 | 1.5.1 | 1.6.0 | trunk |

延伸相關外掛(你可能也想知道)

暫無相關外掛推薦。

文章
Filter
Apply Filters
Mastodon