前言介紹
- 這款 WordPress 外掛「WP-SynHighlight」是 2008-12-29 上架。
- 目前有 200 個安裝啟用數。
- 上一次更新是 2016-01-11,距離現在已有 3698 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 2.8 以上版本才可以安裝。
- 有 5 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
code | syntax | Highlight | formatting | syntax highlight |
內容簡介
此外掛提供在貼文和評論中的語法突顯功能。
完整的 GUI 模式。不需要像其他外掛一樣在編輯器中切換到程式碼模式再切回來。
具備即時語法突顯支援的 GUI 編輯器整合(可以在設定中取消啟用)。
GUI 按鈕協助進行突顯選項。不用記憶它們!
用於碼的預設設定可以套用至整個部落格。現在,您可以同時更改所有貼文的外觀!
許多自訂碼突顯選項(幾乎完整的 Geshi 設定)。
如果您喜歡此外掛,可以使用 WebMoney(R704473788938、R704473788938)、Yandex.Money(41001122895969)、MoneyBookers([email protected])進行捐贈。
使用方式
只需在編輯器中選擇所有原始碼,然後使用編輯器按鈕(建議的方法),或直接在 WYSIWYG 編輯器中使用 [codesyntax] [/codesyntax] 標籤包裹您的程式碼如下:
[codesyntax lang=”php”]
<?php
//Replacing tags
$find [] = '/<br\s*\\?>/i';
$replace [] = "\r\n";
$content = preg_replace($find, $replace, $content);
?>
[/codesyntax]
[filesyntax filename=”test.phps” lang=”php”]
在最後一個示例中,標籤應該在設定中啟用。請參閱它的說明。
使用上述方法,您將得到美妙的 Geshi 格式。使用預格式樣式來格式化所有你的原始碼,以保留空格。
如果您需要更改已經格式化的區塊的設置,請全選它並再次點擊 GUI 編輯器按鈕。插件將識別您使用的所有設置。
此外掛可以識別幾個流行的 Geshi 選項以渲染突顯:
filename - 繼承在 [filesyntax] 標籤中允許進行突顯的某個資料夾內相對檔案名稱。只能在 [filesyntax] 標籤中使用。
lang - 您想使用的程式語言進行突顯。語言的名稱應與高亮器檔案的名稱相符。請在安裝此插件後查看 WordPress 安裝的 /wp-content/plugins/wp-synhighlighter/geshi/geshi 目錄中的所有支援的高亮器列表。目前支援的語言列表如下:
abap,actionscript,actionscript3,ada,apache,applescript,apt_sources,asm,asp,autoit,avisynth,bash,basic4gl,blitzbasic,bnf,boo,c,caddcl,cadlisp,cfdg,cfm,cil,cobol,cpp-qt,cpp,csharp,css,c_mac,d,delphi,diff,div,dos,dot,eiffel,email,fortran,freebasic,genero,gettext,glsl,gml,gnuplot,groovy,haskell,html4strict,idl,ini,inno,io,java,java5,javascript,kixtart,klonec,klonecpp,latex,lisp,list.txt,lotusformulas,lotusscript,lua,m68k,make,matlab,mirc,mpasm,mxml,mysql,nsis,objc,ocaml-brief,ocaml,oobas,oracle11,oracle8,pascal,per,perl,php-brief,php,pic16,plsql,povray,powershell,progress,prolog,python,qbasic,rails,reg,robots,ruby,sas,scala,scheme,scilab,sdlbasic,smalltalk,smarty,sql,tcl,teraterm,text,thinbasic,tsql,typoscript,vb,vbnet,verilog,vhdl,visualfoxpro,winbatch,xml,xorg_conf,xpp,z80。
lines - 是否要顯示行號?此參數可能的值包括:
- no – 無行號。 [codesyntax lang=”java” lines=”no”]My java code[/codesyntax]
- normal - 正常行號
- fancy - 裝飾行號(默認)
lines_start - 如果您希望行號從自定值開始,可以提供此參數。
原文外掛簡介
Plugin provides syntax highlighting in posts and comments.
Full GUI mode. No need to switch to code mode and back like in some other plugins
GUI editor with realtime syntax highligting support integrated (can be disable in settings)
GUI button to help with highlighting options. No need to memorize them!
Blog-wide default settings for code highlighting. Now you can change the look of all your posts at once!
Many options to customize code highlighting (almost full Geshi set)
If you like this plugin, you can make a donation with WebMoney (R704473788938, R704473788938), Yandex.Money (41001122895969), MoneyBookers ([email protected])
Usage
Just select all your source code in the editor and use editor button (preferred method) or surround your code directly in WYSIWYG editor with a [codesyntax] [/codesyntax] tag like this
[codesyntax lang=”php”]
/i';
$replace [] = "\r\n";
$content = preg_replace($find, $replace, $content);
?>
[/codesyntax]
[filesyntax filename=”test.phps” lang=”php”]
The tag in the last example should be enabled in settings. See it’s description below also.
and you will get wonderful geshi formatting. Format all your source code with Preformatted style to preserve spaces.
If you need to change settings of already formatted block – select it all and press GUI editor button again. Plugin will recognize all settings you used.
Plugin recognizes several popular geshi options to render highlighting:
filename
The relative filename of the file inside a folder, allowed for [filesyntax] tag to take the source for highlighting from. Works only in [filesyntax] tag
lang
The programming language you want to be your source highlighted in. [codesyntax lang=”java”]My java code goes here…[/codesyntax]
The name of the language should match the name of the highlighter file. For the list of all supported highlighters please look at /wp-content/plugins/wp-synhighlighter/geshi/geshi directory of your WordPress installation after installing this plugin. A list of currently support languages:
abap, actionscript, actionscript3, ada, apache, applescript, apt_sources, asm, asp, autoit, avisynth, bash, basic4gl, blitzbasic, bnf, boo, c, caddcl, cadlisp, cfdg, cfm, cil, cobol, cpp-qt, cpp, csharp, css, c_mac, d, delphi, diff, div, dos, dot, eiffel, email, fortran, freebasic, genero, gettext, glsl, gml, gnuplot, groovy, haskell, html4strict, idl, ini, inno, io, java, java5, javascript, kixtart, klonec, klonecpp, latex, lisp, list.txt, lotusformulas, lotusscript, lua, m68k, make, matlab, mirc, mpasm, mxml, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle11, oracle8, pascal, per, perl, php-brief, php, pic16, plsql, povray, powershell, progress, prolog, python, qbasic, rails, reg, robots, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, tcl, teraterm, text, thinbasic, tsql, typoscript, vb, vbnet, verilog, vhdl, visualfoxpro, winbatch, xml, xorg_conf, xpp, z80
lines
Do you want line numbers to be visible? Possible parameter values are:
no – no line numbers. [codesyntax lang=”java” lines=”no”]My java code[/codesyntax]
normal = normal line numbering
fancy – fancy line numbering
This parameter defaults to fancy
lines_start
You can provide this parameter if you want your line numbering to start with a custom value. [codesyntax lang=”java” lines=”fancy” lines_start=”1000″]My java code[/codesyntax]. Please don’t forget to enclose a value into quotes exactly like in example
By default numbering starts with 1.
container
You can select container, that your code will be wrapped in
pre
div
pre_valid
pre_table
none
By default pre is used. [codesyntax lang=”java” container=”pre”]My java code[/codesyntax]
More information can be found in Geshi documentation
capitalize
Do you wish your keywords to be automatically capitalized or decapitalized?
no – don’t change anything
upper – convert all keywords into uppercase
lower – convert all keywords into lowercase
By default no change is assumed
[codesyntax lang=”java” capitalize=”upper” lines_start=”1000″]
tab_width
If you want to change tab width, use this parameter: [codesyntax lang=”java” tab_width=”10″]
strict
This setting enables or disables strict mode for formatting complex pieces of data. Please see Geshi documentation to find out more on the subject
title (new in 0.91)
This attribute sets the header of the collapsable code block (“Code” by default)
bookmarkname (new in 0.91)
The name of bookmark (Named anchor tag ) you want to refer to this codeblock. By default it is
codesyntaxX, where X is 1 for first code block on the page, 2 for second etc. You can refer to your codeblocks using hyperlinks
< a href=”#codesyntax5″>Link to fifth code block on the page or, if you used
[codesyntax bookmarkname=”fifthcode”] lang=”php” bbcode, you can then refer to this codeblock as
< a href=”#fifthcode”>Link to fifth code block on the page
blockstate (new in 0.97)
Sets initial code block state when the page is shown to user. It can be default, expanded or collapsed. Default corresponds to expanded currently.
highlight_lines (new in 1.1)
Provides a comma-separated list of lines, that should be specially highlighted in the code
doclinks (new in 2.3)
Enables or disables generation of documentation links for keywords
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WP-SynHighlight」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Code Syntax Block 》代碼語法區塊(Code Syntax Block)擴充了 WordPress 區塊編輯器,使用 Prism 語法高亮工具為核心代碼區塊添加了語法高亮支持。, Prism 語法高亮工具在前端執...。Syntax-highlighting Code Block (with Server-side Rendering) 》這個外掛擴展了 WordPress 核心的程式碼塊,以添加在伺服器上呈現的語法突顯。現有的網站上的程式碼塊會自動擴展,以包含語法突顯。使用伺服器端的語法突顯消...。
Code Block Syntax Highlighter for Elementor 》「Code Block Syntax Highlighter for Elementor」是一個 Elementor 的小工具,可讓您在您的網站上增加具有 prism.js 語法高亮的程式碼區塊。, 目前支援 Pris...。
Elementor Syntax Highlighter 》由於 Elementor 現已擁有自己的語法突出顯示小工具,因此此外掛已不再維護。, 這個 Elementor 小工具可讓你在內容中加入語法突出顯示的程式碼片段。, 語法突...。Syntax Highlight 》WordPress外掛和主題編輯器中的語法突出顯示。, 特色, , 在外掛和主題編輯器中進行語法突出顯示, 通過CTRL+S進行AJAX保存, 在有未保存的更改時詢問是否要離開...。
CC-Syntax-Highlight 》CC-Syntax-Highlight 外掛支援文章、頁面和任何公開自訂文章類型的語法高亮顯示。, 它使用 highlight.js 或 google-code-prettify 函式庫。, 此外,它還可以...。Syntax Highlighter++ 》這個 WordPress 外掛不僅提供語法高亮效果,還在文章編輯頁面加入了一個文字區塊和一個按鈕。, 只要選擇程式語言,將程式碼貼入文字區塊,再點擊“OK”按鈕,你...。
REST API support for Crayon Syntax Highlighter 》REST API 創建的文章中的程式碼語法未突顯嗎?, Crayon Syntax Highlighter 是 WordPress 中最好的程式碼語法突顯外掛之一,但目前它尚未支援 REST API。這意...。
Post Editor Zen Coding 》, 這個外掛可在 WordPress 文章編輯頁面上新增一個語法突出顯示的編輯器,內建 Emmet(Zen Coding)引擎,可以將類似 ul.nav>li.nav-item$*4>a 的內容...。
Compilebin 》這是一個語法高亮外掛,同時也是一個介面,可以連接到 https://www.compilebin.com 提供的在雲端上的編譯器 API 服務。它透過 REST API 與雲端服務進行互動,...。WPygments 》這個外掛使用基於 Pygments 的伺服器端語法高亮軟體。, 安裝:, 在使用這個外掛前,你需要先在伺服器上安裝 Pygments:, sudo apt-get install python-setupt...。
Simple Gist Embed 》這個外掛讓你可以在你的文章或頁面中嵌入 Github 的 Gists,但與其他類似外掛不同之處在於,它允許你在不離開 WordPress 的情況下創建 Gists。, 就是這樣,你...。
Code Highlighter Block – Syntax Highlighter Gutenberg Block 》Code Highlighter Block 是一個簡單、輕量級的程式碼語法高亮外掛,可以讓不同語言的程式碼被高亮顯示。, 它擁有一個很棒的主題並支援多種語言。, 主要功能:...。CodeHighlighter 》這個外掛是一個語法高亮插件,使用 GeSHi 作為字體引擎。, 使用方法, , 將程式碼片段放在 “` 標籤內。, 在程式碼標籤中加入語言屬性,像這樣:<code...。
WP-SimpleSyntaxHighlighter 》Simple SyntaxHighlighter for WordPress 將 Alex Gorbatchev 的 JavaScript SyntaxHighlighter 加入到您的網誌中。, Alex Gorbatchev 的 SyntaxHighlighter ...。
