
內容簡介
• 現場示範
• 亮點:
支援259種程式語言。
適用於行動裝置:無需執行JavaScript,與基於JavaScript的解決方案相比可節省頻寬和電力。
後端負載接近零。使用快取解決方案後,將不會影響網頁載入時間。
行數編號。如果需要(程式行與行號之間不會有垂直位移)。
預設樣式經過多達20款主題的測試,包括Twenty Ten到Fifteen款,也根據眾多使用者的回饋進行調整。
如果需要調整樣式:僅需提供自己的CSS檔案,樣式可高度且容易地配置。
區塊樣式:在單一頁面上,每個程式碼區塊都可以自行設定樣式(如果您需要這樣做)。
乾淨、小型和有效的HTML輸出。
使用現代WordPress API呼叫進行全面記錄的源代碼。
我已經維護這個外掛數年了,並且我打算繼續提供支援。
基於GeSHi,一個可靠且良好建立的PHP語法突顯引擎,被流行的社區論壇應用程序(如phpBB)或Wiki應用程序(如Dokuwiki或MediaWiki)使用。
WP-GeSHi-Highlight可作為WP-Syntax的即插即用替代品,後者自2015年以來似乎已不再維護。進行替換,這應該是有效的(讓我知道結果如何)!
• 用法:
WordPress 5使用者:目前我只在傳統編輯器中測試過此外掛程式。Gutenberg目前尚未支援(不過可能可以運作,讓我知道)。
建議:使用“文本”(原始)編輯器,而不是使用“可視化”編輯器。在兩種編輯器之間切換可能會損壞程式碼塊的內容。
在文本編輯器中插入程式碼區塊,並使用lang參數定義程式碼片段的語言:
<pre lang="language">
CODE
</pre>
以下是bash語言的簡短範例:
<pre lang="bash">
$ dd if=/dev/zero of=image.ext3 bs=1M count=10000 oflag=append conv=notrunc
</pre>
發佈/預覽,並查看結果!
還可以查看所有可用選項的參考文檔。您可以在外掛程式的網站上找到它。請注意,更多的用法示例可以在示範網站上找到。
• 問題:
許多網站已經使用這個外掛程式數年了,似乎已能很好地發揮其作用。如果您發現任何問題,請告訴我:發送郵件或留下評論。
• 預設樣式表的主題相容性:
預設樣式表已經與所有官方主題(包括Twenty Ten到Twenty Fifteen款)和許多非官方主題進行過測試,例如Vantage、Customizr、ColorWay、Zerif Lite、Responsive、Storefront、Virtue、evolve、Make、Sparkling、Spacious、Enigma、Sydney、Point、Interface、SinglePage等等。
外掛標籤
開發者團隊
② 後台搜尋「WP-GeSHi-Highlight — rock-solid syntax highlighting for 259 languages」→ 直接安裝(推薦)
📦 歷史版本下載
原文外掛簡介
• Live demo
• Highlights:
Supports 259 languages.
Server-side. Saves bandwidth, latency, and battery compared to client-side rendering.
Near-zero load on the backend. With a caching solution this does not affect your page load time at all.
Line numbering. If you want to (no vertical displacements between code line and line number).
Default style was tested with more than 20 themes, including Twenty Ten to Fifteen, and tweaked based on a bunch of user feedback.
If you’d like to tweak the style: just provide your own CSS file. Styles are highly & easily configurable.
Per-block styles: each code block on a single page can be styled on its own (if that is something you would liked to do).
Clean, small and valid HTML output.
Well-documented source code using modern WordPress API calls.
I have maintained this plugin for several years and I plan to continue to provide support.
Based on GeSHi, a reliable and well-established PHP highlighting engine, used by popular community forum applications such as phpBB or wiki applications such as Dokuwiki or MediaWiki.
WP-GeSHi-Highlight works as a drop-in replacement for WP-Syntax, which does not seem to be maintained anymore (as of 2015). Make the switch, it should just work (let me know how it went)!
• Usage:
WordPress 5 users: for now I have tested this plugin only with the Classical Editor. Gutenberg is not yet supported (it may work though, let me know).
Recommendation: use the “Text” (raw) editor. Do not use the “Visual” editor. Switching between both may corrupt the contents of your code blocks.
In the text editor insert code blocks as pre blocks, and use the lang argument to define the language of the code snippet:
CODE
A short example for the bash language:
$ dd if=/dev/zero of=image.ext3 bs=1M count=10000 oflag=append conv=notrunc
Publish/preview, and have a look at the result!
Also check out the reference documentation for all available options. You can find it on the plugin’s website. Note that more usage examples can be found on the demo website.
• Issues:
A bunch of websites have used this plugin for years, and it seems to serve its purpose well. If you find an issue please let me know: drop a mail or leave a comment.
• Theme compatibility of the default style sheet:
The default style sheet was tested with recent versions of all official themes (Twenty Ten to Twenty Fifteen), and with a large range of non-official themes such as Vantage, Customizr, ColorWay, Zerif Lite, Responsive, Storefront, Virtue, evolve, Make, Sparkling, Spacious, Enigma, Sydney, Point, Interface, SinglePage.
Certain themes might define styles with a high specificity that negatively affect the visual code block appearance. It is difficult to impossible to anticipate all these cases in advance, so I expect this to happen in rare cases (the past has proven that these things happen). So, I need you to look out for these situations, and please report them!
