
內容簡介
Prism 是一個最受歡迎的語法高亮工具,被許多博客或網站廣泛使用,其中一些知名網站包括 Mozilla、Drupal 和 SitePoint。
為什麼許多網站偏好使用這個高亮工具的原因之一是它能夠建立自訂的語言高亮和插件,你可以自行決定要使用哪些功能。
這個外掛程式可以輕鬆地將這個代碼高亮工具引入你的 WordPress 網站中,並且配備許多功能和使用者友好的 GUI,讓它簡便易用。
** 功能 **
簡單易用
支援經典編輯器和 Guttenberg 區塊編輯器
Prism 提供的所有可能的語法語言
完整的 GUI,不需要硬編碼參數
易於建立自訂版本。輕鬆選擇你自己的語言、佈景主題和一些插件
自訂容器最大高度。在顯示長代碼時很有用
易於添加自定義 CSS。對於響應式設計很有用
易於編輯在 tinyMCE 文本編輯器中編寫的代碼(截圖 4)
原地編寫和編輯代碼。代碼編輯器的文字區域支援標籤和反向標籤,因此你可以直接編輯或編寫你的代碼,而無需切換到代碼編輯器。
按需加載腳本。僅在需要時加載 Prism 高亮工具的 JavaScript 和 CSS 文件
能夠覆蓋全局選項,使用每個代碼區塊的個別選項
支援 TinyMCE 可視模式和文本模式(快速標籤),它也支援在管理員評論頁面上使用的快速標籤(截圖 5)
使用與 APH Syntax Highlighter 和 Crayon Syntax Highlighter 外掛程式相似的模式,因此你的代碼在使用這些外掛程式時仍然可以正常運作
新增語言:淺色和深色純文字
使用方式
安裝了外掛程式後,前往管理設定 > Prism Highlighter 設置全局設置,包括你想要加載的高亮語言、主題等等。
在 TinyMCE 菜單(新增或編輯文章或頁面)中,將出現一個新的按鈕可用於彈出代碼編輯器,只需複製粘貼代碼並填入一些選項即可。
這個新按鈕還可以在管理員編輯評論頁面的快速標籤中找到。當你編輯或回覆評論時,這個快速標籤會出現。
外掛標籤
開發者團隊
② 後台搜尋「APH Prism Syntax Highlighter」→ 直接安裝(推薦)
原文外掛簡介
Prism is one of the most popular syntax highlighters that widely used by a lot of blog or websites, some of them are popular websites, such as Mozilla, drupal, and SitePoint.
One reason why a lot of websites prefer to use this highlighter is because it’s ability to do custom builds of the language highlighter and plugins you want to be used
This plugin helps you to do all of those tasks and bring this code highlighter to your WordPress easily, provided with many features and user-friendly GUI, make it handy and easy to use.
** Features. **
Simple and easy to use
Support both Classic and Guttenberg block editor
All possible syntax languages provided by Prism
Full GUI, don’t need to hardcode parameters
Easy to make a custom build. Choose your own language, theme, and some plugins easily
Custom container max-height. Useful when displaying long code.
Easy to add custom CSS. Useful for responsive design.
Easy to edit code that has been written in tinyMCE text editor (screenshot 4)
Write and Edit code in place. The textarea of code editor, support tab, and back tab, so you can directly edit or write your code, rather than switch back to your code editor.
Load script on demand, load javascript and CSS file of prism highlighter only when needed
Ability to override global options and use individual options for each code block
Support TinyMCE Visual mode and Text Mode (Quick Tags), it also supports the Quick tags used in the admin comment page (screenshot 5)
Use similar pattern with APH Syntax Highlighter and Crayon Syntax Highlighter plugins, so your code will still work using those plugins
Language added: Light plain and dark plain
How To Use
After installing the plugin, go to the admin setting Settings > Prism Highlighter to configure the global setting including the highlighter languages you want to load, theme, etc.
In the TinyMCE menu (add or edit post or page), there is a new button that can be used to pop up the code editor, simply copy-paste your code and fill in some options
This new button also can be found at the quick tags of comment editor in the Admin Edit Comments page. This quick tag appears when you edit or reply a comment.
