A.參考來源:
1.SyntaxHighlighter
http://alexgorbatchev.com/SyntaxHighlighter/
2.brushes
http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
3.themes
http://alexgorbatchev.com/SyntaxHighlighter/manual/themes/
B.所需檔案:
建議將 Blog 會用到的檔案,下載到自己的網路空間存放,
並將可存取路徑,設到 Blog 的關聯路徑中;
以免來源網址掛掉,而造成無法正常顯示。
(當然直接使用原來的關聯路徑也行,非必要)
所需的檔案如下:
1.brushes: code樣板
EX: shBrushDelphi.js
2.themes: 風格樣板
EX: shThemeMidnight.css
(下列舉例中的 shThemeDelphiStyle.css 是我參考後自行修改的)
3.基本css (shCore.css)
4.主程式js (shCore.js)
5.圖示檔 (help.png, magnifier.png, page_white_code.png, printer.png)
(圖示檔是用在 themes(風格樣板) shThemeDelphiStyle.css 之中)
C.設定方式:
在網頁的 </head> 之前,加入設定範例中的 code
設定範例:
設定範例
D.使用方式:
在要顯示的程式碼前後,加上如下的標籤即可
使用方式使用範例:// 程式碼 程式碼 程式碼
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = VK_Shift) then ...
// ----- or ----
case key of
VK_ESCAPE:
begin
...
end;
VK_SHIFT:
begin
...
end;
end;
case sStr[1] of
'P': begin //A:@小時
if CARRY_CHG.CanFocus then CARRY_CHG.SetFocus;
end;
'C': begin //A:@小時
if CARRY_BEGIN.CanFocus then CARRY_BEGIN.SetFocus;
end;
{$IFDEF ODBC_MODE}
_Content:= _Content +#13#10+'[ ODBC_MODE ]';
{$ELSE}
_Content:= _Content +#13#10+'[ Normal_MODE ]';
{$ENDIF}
// 各種型態的顏色顯示
i:= 123;
s:= 'AAA';
Qoo:= "CCC";
Copy(s, 1, 3);
end;
有 highlight 的範例:
/***********************************
** Multiline block comments
**********************************/
$stringWithUrl = "http://alexgorbatchev.com";
$stringWithUrl = 'hello world';
ob_start("parseOutputBuffer"); // Start Code Buffering
session_start();
function parseOutputBuffer($buf) {
global $portal_small_code, $portal_gzcompress;
global $PHP_SELF, $HTTP_ACCEPT_ENCODING;
// cleaning out the code.
if($portal_small_code && !$portal_gzcompress) {
$buf = str_replace(" ", "", $buf);
$buf = str_replace("\n", "", $buf);
$buf = str_replace(chr(13), "", $buf);
}
}
沒有留言:
張貼留言