[WordPress] 外掛分享: Prism Syntax Highlighter (detached)

WordPress 外掛 Prism Syntax Highlighter (detached) 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Prism Syntax Highlighter (detached)」是 2012-09-03 上架。
  • 目前有 10 個安裝啟用數。
  • 上一次更新是 2013-07-30,距離現在已有 4296 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.4.0 以上版本才可以安裝。
  • 有 4 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

apfelbox |

外掛標籤

prism | syntax highlighting |

內容簡介

將Prism Syntax Highlighting Library整合至 WordPress。

這個外掛是被稱為「分離式」,因為程式碼範例不會和所有的其他文字和內容混在一起裝在所見即所得編輯器中,而是被分獨地加入為自訂欄位,然後只是透過短代碼(就像腳註)來引用。

使用方式請參考其他注意事項。

官方開發存儲庫位於Github上。

使用方法

基本步驟如下:

建立自訂欄位,並將程式碼貼上其中。
在您要顯示程式碼塊的位置插入[prism ...]短代碼。

短代碼
[prism key=".." language=".." line=".." line_offset=".." post=".."]

key:包含代碼的自訂欄位的名稱(必填)
language:要加亮的語言
line:高亮行數(請參考官方說明文件)
line_offset:行號起始的偏移值
post:如果您想要包含另一篇文章的代碼,可以在此明確指定文章的 ID

快取資源載入程式

該外掛包含有快取資源載入程式(自 v1.3 開始),以便所有所需的資源可以連接成一個 JS 檔案和一個 CSS 檔案,以最小化 HTTP 請求。
要使用快取資源載入程式,只需在您的外掛目錄內建立一個 /cache/ 目錄並為 PHP 設置可寫權限即可。

支援的語言

僅支援 PrismJS 官方支援的語言:

bash(Unix Shell)
c
clike
coffeescript
cpp(C++)
css
groovy
java
javascript
markup(如:xHTML、MathML、SVG、LaTeX、RSS、XML、OWL 等)
php
python
scss(Sassy CSS)
sql

建立自訂擴充功能

請閱讀 Wiki 頁面:Creating A Custom Extension。

原文外掛簡介

Integrates the Prism Syntax Highlighting Library in WordPress.
It is called detached, since the code examples are not stuffed into the rich text editor, together with all the
other texts and content, but they are added separately as custom fields and just referenced via short tags (like footnotes).
Check Other Notes for usage documentation.
The official development repository is hosted on Github.
Usage
The basic procedure is:

Create a custom field and paste the code into it.
Insert the [prism ...] shorttag in your code, where you want the code block to appear.

Shorttag
[prism key=".." language=".." line=".." line_offset=".." post=".."]

key: the name of the custom field, which contains the code (required)
language: the language to highlight
line: highlighted lines (for syntax, check the offical docs)
line_offset: the offset, with which the line numbering should start
post: if you want to include a code piece of another post, you can explicitly specify the post id here

Cached Assets loader
The plugin includes (from v1.3 on) a cached assets loader, so that all needed assets are concatenated into
one js and one css file to minimize the HTTP requests.
To make use of the cached assets loader, just create a directory /cache/ inside your plugin directory and make it writable for PHP.
Supported languages
Only the ones from the official PrismJS repository

bash (Bash Unix Shell)
c
clike
coffeescript
cpp (C++)
css
groovy
java
javascript
markup (like: xHTML, MathML, SVG, LaTeX, RSS, XML, OWL, etc.)
php
python
scss (Sassy CSS)
sql

Creating Custom Extensions
Please read the wiki page: Creating A Custom Extension.

各版本下載點

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

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


1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | trunk |

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

  • Elementor Syntax Highlighter 》由於 Elementor 現已擁有自己的語法突出顯示小工具,因此此外掛已不再維護。, 這個 Elementor 小工具可讓你在內容中加入語法突出顯示的程式碼片段。, 語法突...。
  • APH Prism Syntax Highlighter 》Prism 是一個最受歡迎的語法高亮工具,被許多博客或網站廣泛使用,其中一些知名網站包括 Mozilla、Drupal 和 SitePoint。, 為什麼許多網站偏好使用這個高亮工...。
  • AH Code Highlighter 》使用起來非常簡單,並且非常輕量的代碼高亮化,具有 8 種不同的代碼高亮化主題。您可以將代碼與或不帶行號進行突出顯示。它是基於 Lea Verou 的 Prism.js。Pr...。
  • Prism Syntax Highlighter for WordPress 》儘管 WordPress 上已經有兩款外掛可用,但我決定從頭自己寫一個。結果是一個極簡但功能強大的外掛,只有大約 250 行 PHP 代碼。, , 支援 Prism 的所有可能配...。
  • Easy Prism Syntax Highlighter 》厭倦了尋找正常且易於安裝的程式碼高亮外掛嗎?, 這個外掛將幫助您結束這段冒險。, 它會增加特殊的簡碼 [code][/code]、快捷鍵「alt+c」和按鈕到視覺化編輯器...。
  • WP Prism Syntax Highlighter 》WP Prism Syntax Highlighter 讓你可以在 WordPress 博客中使用 Prism,這是由 Lea Verou 開發的一款輕量、可擴展的語法高亮插件。, , , 它在 WordPress 編輯...。
  • WP PrismJS – Syntax Highlighter 》使用 WP PrismJS,輕鬆為 WordPress 上的程式碼添加語法高亮。, 只需下載和啟用外掛,然後 TinyMCE 編輯器上就會出現一個新圖示。點擊它,就可以輸入您的縮排...。
  • WooCommerce Prism 》Prism是一個無縫的聊天商務解決方案,可增加您在Line、Facebook和其他聊天渠道上的轉換率。在一個平台上管理所有交易。, Prism的核心價值, 聊天, 與您網站上...。
  • Prism Syntax Highlighter 》Prism 是一款新型的輕量、可擴充、符合現代網路標準的語法標識軟體,由 Lea Verou 開發。透過這個 WordPress 外掛,使用 Prism 讓你的 WordPress 網站更加簡...。
  • Melonpan Block – Code 》Demo – Documentation – GitHub, 此外掛可顯示程式碼,並帶有突顯語法及可複製到剪貼簿的功能。, 特色, 此外掛帶有以下設定:, , 程式碼語言: Jav...。
  • Alkane Code 》Alkane Code 是一款使用方便且輕量級的 TinyMCE 程式碼編輯器,可以為 HTML 程式碼元素加入「語言-」類別。它可以用於添加內聯程式碼以及區塊程式碼,並且在...。
  • Syntax Highlighter with PrismJS 》使用 PrismJs 的語法突出顯示器。, 使用方法, 按照下面所示的方式包裝您的 pre 標籤:, , [sh_prismjs_pre class="language-py line-numbers match-braces ra...。
  • Prism Warning 》這個外掛可以在訪客的瀏覽器是由與 PRISM 有關的公司製造時發出警告。, 目前已有英文和德文的翻譯,如果你想貢獻更多語言,可以在 GitHub 上提交拉取請求。, ...。

文章
Filter
Apply Filters
Mastodon