這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

Goodbye Syntax Highlighter

外掛說明

For years I’ve used Alex Gorbatchev’s SyntaxHighlighter. It has served me well over the years. When I moved to WordPress I tried various plugins based on the library, such SyntaxHighlighter Evolved.

I’ve decided to start blogging using Markdown. Making this move I needed to find a way to highlight various bits of source code in an easy way. There are many nice libraries that make this a snap, such as google-code-prettify or highlight.js. In the end I decided to go with highlight.js, for the simple reason that it is automatic, working flawlessly with Markdown’s code syntax output.

Great, but my existing source code examples use SyntaxHighlighter’s style for code blocks (using <pre class="brush: ruby;" />, for example). I could have converted things in a few ways:

  • Change the database
  • Write a JS script to convert the <pre /> structure to <pre><code /></pre>
  • Write a JS script to call highlight.js’ highlightBlock method
  • Write a WP plugin and reformat things easily Ding Ding Ding

So there you have it. This WordPress plugin will go through and process your SyntaxHighlighter style blocks into ones that highlight.js works with out-of-the-box. It will also add the language that you have specified with the brush class and add it as a class on the <code /> element (following the HTML5 recommendation). Nothing is changed in the DB, so if you decide to go back to SyntaxHighlighter, you can without any issues.

GeSHi

This plugin now supports conversion of GeSHi style code blocks! Now you can move from plugins such as WP-Syntax and WP-GeSHi-Highlight to highlight.js.

GeSHi uses the syntax that is close to SyntaxHighlighter, except instead of putting the language in the class attribute, it uses the lang attribute. Similar to the SyntaxHighligher conversion, it will go through and process your GeSHi style blocks into ones that highlight.js works with out-of-the-box. It will also add the language that you have specified with the lang attribute and add it as a class on the <code /> element.

安裝方式

Installation is standard and straight forward.

  1. Upload the goodbye-syntax-highlighter folder (and all it’s contents) to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress

使用者評論

這個外掛目前沒有任何使用者評論。

參與者及開發者

以下人員參與了開源軟體〈Goodbye Syntax Highlighter〉的開發相關工作。

參與者

將〈Goodbye Syntax Highlighter〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

0.1.0

  • Initial release

0.1.1

  • Modified output to use the HTML5 recommended syntax highlighting class names, e.g. language-ruby. For more information, see the HTML5 spec

0.1.2

  • Added conversion of GeSHi style code blocks