SyntaxHighlighter 為免費網站外掛程式 , 提供頁面較容易瀏覽程式碼內容的樣式 ,
文章中如需特定標注程式內容只需使用<pre></pre>標籤 , 並且給予符合的class樣式名稱 ,
就可以依不同程式碼類型顯示 , 十分方便.
官方網址:SyntaxHighlighter
下載網址:連結
使用說明:連結
支援以下類型顯示:
| Brush name | Brush aliases | File name |
as3, actionscript3
|
shBrushAS3.js
|
|
bash, shell
|
shBrushBash.js
|
|
cf, coldfusion
|
shBrushColdFusion.js
|
|
c-sharp, csharp
|
shBrushCSharp.js
|
|
cpp, c
|
shBrushCpp.js
|
|
css
|
shBrushCss.js
|
|
delphi, pas, pascal
|
shBrushDelphi.js
|
|
diff, patch
|
shBrushDiff.js
|
|
erl, erlang
|
shBrushErlang.js
|
|
groovy
|
shBrushGroovy.js
|
|
js, jscript, javascript
|
shBrushJScript.js
|
|
java
|
shBrushJava.js
|
|
jfx, javafx
|
shBrushJavaFX.js
|
|
perl, pl
|
shBrushPerl.js
|
|
php
|
shBrushPhp.js
|
|
plain, text
|
shBrushPlain.js
|
|
ps, powershell
|
shBrushPowerShell.js
|
|
py, python
|
shBrushPython.js
|
|
rails, ror, ruby
|
shBrushRuby.js
|
|
scala
|
shBrushScala.js
|
|
sql
|
shBrushSql.js
|
|
vb, vbnet
|
shBrushVb.js
|
|
xml, xhtml, xslt, html, xhtml
|
shBrushXml.js
|
將需使用格式JS檔加入</head>之前
<script src='http://alexgorbatchev.com/pub/sh/3.0.83/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/3.0.83/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/3.0.83/scripts/shBrushXml.js' type='text/javascript'/>
<script type='text/javascript'>
SyntaxHighlighter.all();
</script>
<link href='http://alexgorbatchev.com/pub/sh/3.0.83/styles/shCoreRDark.css' rel='stylesheet' type='text/css'/>
為程式排版更美觀可於CSS加入以下內容:
.toolbar{ /*將原本右上角會出現 ?(問號) 的版權宣告隱藏不顯示*/
display: none !important;
-webkit-box-shadow: 7px 6px 6px rgba(50, 50, 50, 0.75); /* 陰影 */
-moz-box-shadow: 7px 6px 6px rgba(50, 50, 50, 0.75); /* 陰影 */
box-shadow: 7px 6px 6px rgba(50, 50, 50, 0.75); /* 陰影 */
-webkit-border-radius: 8px; /* 圓角 */
-moz-border-radius: 8px; /* 圓角 */
border-radius: 8px; /* 圓角 */
}
body .syntaxhighlighter{ /*在 chrome 瀏覽器下程式碼右邊會出現醜醜的直向捲軸把它給移除掉*/
overflow-y: hidden !important;
}
body .syntaxhighlighter div{ /*控制行高及字體大小*/
height: 20px !important;
line-height: 20px !important;
font-size: 16px !important;
}
參考資料:網站後端的工作筆記
沒有留言 :
張貼留言