trash-area.com ≫ blog ≫ メモ ≫ wordpressにシンタックスハイライトをするプラグインを入れてみた。
というわけでいきなり放置ぎみになっているわけですが
ビバ・初プラグインということでシンタックスハイライトをするプラグインのインストールに挑戦してみました。
プラグインはiG:Syntax Hiliter 日本語版です。
$find . -maxdepth 4 | grep plugins | grep syn | sort
./wordpress/wp-content/plugins/ig_syntax_hilite
./wordpress/wp-content/plugins/syntax-hilite-ja_EUC.mo
./wordpress/wp-content/plugins/syntax-hilite-ja_EUC.po
./wordpress/wp-content/plugins/syntax-hilite-ja.mo
./wordpress/wp-content/plugins/syntax-hilite-ja.po
./wordpress/wp-content/plugins/syntax-hilite-ja_SJIS.mo
./wordpress/wp-content/plugins/syntax-hilite-ja_SJIS.po
./wordpress/wp-content/plugins/syntax-hilite-ja_UTF.mo
./wordpress/wp-content/plugins/syntax-hilite-ja_UTF.po
./wordpress/wp-content/plugins/syntax_hilite.php
とこれだけでインストールが完了しました。
対応言語は ActionScript, ASP, C, C++, C#, CSS, DELPHI, HTML, JAVA, JavaScript, MySQL, PERL, PHP, PYTHON, RUBY, SMARTY, SQL, Visual Basic, VB.NET, XML & CODE だそうです。
CODEってなんでしょう?シェルというかターミナルというかコンソールっぽいもののハイライトもあると嬉しいのですけどないのはしかたないですね。
とりあえず使ってみます。
サンプル java で javax.servlet.http.HttpServletResponse のラッパーです。
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Locale;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
public class DebugResponce implements HttpServletResponse{
MyServletOutputStream sos ;
public DebugResponce() {
try {
sos = new MyServletOutputStream(“e:\\result.xml”);
} catch (Exception e) {
e.printStackTrace();
}
}
public ServletOutputStream getOutputStream() throws IOException {
return this.sos;
}
public void addCookie(Cookie arg0) { }
public boolean containsHeader(String arg0) { return false; }
public String encodeURL(String arg0) { return null; }
public String encodeRedirectURL(String arg0) { return null; }
public String encodeUrl(String arg0) { return null; }
public String encodeRedirectUrl(String arg0) { return null; }
public void sendError(int arg0, String arg1) throws IOException { }
public void sendError(int arg0) throws IOException { }
public void sendRedirect(String arg0) throws IOException { }
public void setDateHeader(String arg0, long arg1) { }
public void addDateHeader(String arg0, long arg1) { }
public void setHeader(String arg0, String arg1) { }
public void addHeader(String arg0, String arg1) { }
public void setIntHeader(String arg0, int arg1) { }
public void addIntHeader(String arg0, int arg1) { }
public void setStatus(int arg0) { }
public void setStatus(int arg0, String arg1) { }
public String getCharacterEncoding() { return null; }
public String getContentType() { return null; }
public PrintWriter getWriter() throws IOException { return null; }
public void setCharacterEncoding(String arg0) { }
public void setContentLength(int arg0) { }
public void setContentType(String arg0) { }
public void setBufferSize(int arg0) { }
public int getBufferSize() { return 0; }
public void flushBuffer() throws IOException { }
public void resetBuffer() { }
public boolean isCommitted() { return false; }
public void reset() { }
public void setLocale(Locale arg0) { }
public Locale getLocale() { return null; }
}
class MyServletOutputStream extends ServletOutputStream {
OutputStream os ;
public MyServletOutputStream() {
os = System.out;
}
public MyServletOutputStream(String fileName) throws Exception {
os = new FileOutputStream(new File(fileName));
}
public void write(int arg0) throws IOException {
os.write(arg0);
}
}
[/java]