內容簡介
Syntax Highlight Nano 為 WordPress 的核心程式碼區塊新增美觀且可自訂的語法高亮功能。它與 Gutenberg 編輯器無縫整合,確保編輯器與前端的一致性,並基於 highlight.js 提供準確且高效的語法高亮。
【主要功能】
• 自動語言偵測:智能辨識程式碼語言
• 可自訂標題:選擇顯示檔名或語言名稱
• 行號顯示:可切換行號以提升可讀性
• 一鍵複製按鈕:滑鼠懸停時出現複製按鈕
• 10 種顏色主題:包含 GitHub、Monokai 等主題
• 輕量高效:使用 highlight.js 進行優化高亮
外掛標籤
開發者團隊
原文外掛簡介
Syntax Highlight Nano adds beautiful, customizable syntax highlighting to WordPress’s core code block.
It integrates seamlessly with the Gutenberg editor, providing a consistent look and feel between the editor and the frontend.
Because it extends the existing “Code” block, there is no need for a separate custom block or switching between different block types.
This plugin is built on top of highlight.js, ensuring accurate and performant syntax highlighting for a wide variety of languages.
Features
Automatic language detection: Intelligently detects the programming language of your code.
Customizable header: Optionally display a header above the code block with a filename or language name.
Line numbers: Toggle line numbers on or off to improve code readability.
Copy to clipboard button: A convenient button appears on hover, allowing users to copy the code with a single click.
10 color themes: Choose from light and dark themes including GitHub, Monokai, Solarized, and Catppuccin.
Lightweight and performant: Uses highlight.js for efficient, optimized syntax highlighting.
WordPress best practices: Built following WordPress development standards.
How to Use
Install and activate the plugin.
In the WordPress editor, add a standard “Code” block.
Enter your code.
In the block settings sidebar, you can:
Select a programming language (or leave it for automatic detection).
Add a filename.
Toggle header visibility.
Toggle line number visibility.
The code block will be automatically highlighted on the frontend.
Privacy
This plugin does not collect any personal data. It does not set cookies or connect to external services. All processing happens locally on your server and in the user’s browser.
Credits
This plugin uses highlight.js (BSD 3‑Clause License).
Copyright (c) 2006, Ivan Sagalaev
https://github.com/highlightjs/highlight.js
The Catppuccin themes are based on @catppuccin/highlightjs (MIT License).
Copyright (c) 2021 Catppuccin
https://github.com/catppuccin/highlightjs
Support
For support, feature requests, and bug reports, please visit:
https://github.com/takashifujisaki/syntax-highlight-nano/issues
