WP SyntaxHighlighter プラグインについては既に以下の記事に書きました。
WordPress で Syntaxhighlighter を使う | blog.delphinus.dev
https://blog.delphinus.dev/2013/01/use-syntaxhighlighter-in-wordpress.html
このプラグインでは利用できる言語を増やす仕組みも用意してあり、配布物の中を見ると説明書きがあります。
Lang Pack for WP SyntaxHighlighter
/wp-content/plugins/wp-syntaxhighlighter/sample/readme.txtから引用== このプラグインにより以下の言語が追加できます ==
Biferno, Clojure, DOS batch file, F#, LISP, Lua(only for SyntaxHighlighter 3.0), MEL Script, Objective-C, PowerCLI, Processing, R, S, S-PLUS, Tcl, Verilog, Vim Script, YAML
== インストール ==
1.
lang-pack-for-wp-syntaxhighlighterフォルダーを/wp-content/plugins/ディレクトリにコピー。
2. 管理画面で有効化する
この時点で、以下のように利用できる言語が増えています。
オリジナルの定義ファイルを追加する
ずっと前に Template Toolkit 用の定義ファイルを追加したことがありました。
SyntaxHighlighterでTemplate Toolkitをハイライトする | blog.delphinus.dev
https://blog.delphinus.dev/2010/01/syntaxhighlightertemplate-toolkit.html
このとき作成した shBrushTT2.js を WordPress でも利用できるようにしてみます。
ファイルをコピーする
shBrushTT2.js を所定の場所にコピーします。
# Lang Pack for WP SyntaxHighlighter のディレクトリに移動 $ cd /path/to/wordpress $ cd wp-content/plugins/lang-pack-for-wp-syntaxhighlighter # ディレクトリを作ってファイルをコピーする $ mkdir tt2 $ cp /path/to/shBrushTT2.js tt2
次に、プラグイン本体(lang-pack-for-wp-syntaxhighlighter.php)を修正します。
diff -u wp-syntaxhighlighter/sample/lang-pack-for-wp-syntaxhighlighter/lang-pack-for-wp-syntaxhighlighter.php lang-pack-for-wp-syntaxhighlighter/lang-pack-for-wp-syntaxhighlighter.php
--- wp-syntaxhighlighter/sample/lang-pack-for-wp-syntaxhighlighter/lang-pack-for-wp-syntaxhighlighter.php 2012-12-15 15:35:38.000000000 +0900
+++ lang-pack-for-wp-syntaxhighlighter/lang-pack-for-wp-syntaxhighlighter.php 2013-01-02 16:06:16.000000000 +0900
@@ -23,7 +23,7 @@
// Customizable part1 begin.
$plugin_name = 'Lang_Pack_for_WP_SyntaxHighlighter'; // Plugin name without spaces.
-$version = '1.3'; // Plugin version. When you modify this file, you must increase the version.
+$version = '1.3.2013010101'; // Plugin version. When you modify this file, you must increase the version.
// Customizable part1 end.
function add_nl_new_brush() {
@@ -52,6 +52,7 @@
$wp_sh_brush_files['Verilog'] = array($add_nl_plugin_url.'verilog/shBrushVerilog.js', 'verilog v', 'all', 'added');
$wp_sh_brush_files['Vim'] = array($add_nl_plugin_url.'vim/shBrushVimscript.js', 'vim vimscript', 'all', 'added');
$wp_sh_brush_files['YAML'] = array($add_nl_plugin_url.'yaml/shBrushYaml.js', 'yaml yml', 'all', 'added');
+ $wp_sh_brush_files['TT2'] = array($add_nl_plugin_url.'tt2/shBrushTT2.js', 'tt tt2', 'all', 'added');
// Customizable part2 end.
@@ -82,6 +83,7 @@
$wp_sh_language3['verilog'] = array('Verilog', 'added');
$wp_sh_language3['vim'] = array('Vim Script', 'added');
$wp_sh_language3['yaml'] = array('YAML', 'added');
+ $wp_sh_language3['tt2'] = array('TT2', 'added');
// Add new languages to language list at the click of buttons. For ver. 2.1.
// Format:
@@ -103,6 +105,7 @@
$wp_sh_language2['verilog'] = array('Verilog', 'added');
$wp_sh_language2['vim'] = array('Vim Script', 'added');
$wp_sh_language2['yaml'] = array('YAML', 'added');
+ $wp_sh_language3['tt2'] = array('TT2', 'added');
// Customizable part3 end.
@@ -245,4 +248,4 @@
register_deactivation_hook(__FILE__, 'add_nl_deactive');
-?>
\ No newline at end of file
+?>
3 行追加しただけですね。そんなに悩むことも無いと思います。
この後、Wordpress の管理画面を見ると、TT2 の項目が増えています。
ちゃんと表示されてるかな?
<html>
<head>
<meta charset="UTF-8">
<title>Template Toolkit 2 のサンプル</title>
</head>
<body>
<table>
<tbody>
[%# コメント %]
[%# 複数行コメント
複数行コメント
%]
[% FOREACH row IN tbody %]
<tr>
[% FOREACH td IN row %]
<th colspan="[% td.colspan %]">[% td.text %]</th>
[% END %]
</tr>
[% END %]
</tbody>
</table>
</body>
</html>


