ソースコードのシンタックスカラーリング
Trac は wiki プロセッサ ブロック内の Wiki 形式のテキストと リポジトリブラウザ での、ソースコードの言語特有のシンタックスハイライトに対応しています。
色付けを行うために、 Trac はとても多くのプログラミング言語に対応している外部のライブラリを使用しています。
現在、 Trac は以下にあげる 1 つ以上のパッケージを使用して、シンタックスハイライトを実現しています:
- Pygments 最も推奨するシステムです。というのもカバーしているプログラミング言語、構造化テキストが多いこととサポート体制が活発であるからです。
 - GNU Enscript 通常 UNIX で利用できますが、 Windows ではサポートされていません。
 - SilverCity レガシーなシステムです。いくつかのバージョンには 問題があります
 
シンタックスカラーリングを有効にするには、これらのパッケージのどれか 1 つまたは 1 つ以上をインストールするだけです ( 下記の その他のソフトウェア を参照 ) もし、これらのパッケージの中で適用できるものがなければ、 Trac はプレーンテキストとしてデータを表示します。
Pygments について
Trac 0.11 以降で、 pygments はデフォルトのハイライトパッケージとなりました。ハイライト用のライブラリがピュアな Python コードで書かれていて、とても速く、拡張しやすく ドキュメントが豊富です 。
Pygments のデフォルトのスタイルは、 trac.ini の mime-viewer セクションで指定できます。デフォルトのスタイルは、 個人設定のシンタックスハイライトタブ 上のスタイルを設定することで、オーバーライドされます。
Pygments の構文解析エンジンが対応するリストは毎週のように更新されています。以下のリストが古い可能性は非常に高いです。 正確には supported lexers のページを参照してください。
対応しているシンタックスハイライト
対応している MIME タイプ
| MIME Types | WikiProcessors | 
|---|---|
| application/javascript | js | 
| application/pdf | pdf | 
| application/postscript | ps | 
| application/rss+xml | rss | 
| application/rtf | rtf | 
| application/x-csh | csh | 
| application/x-sh | sh | 
| application/x-troff | nroff roff troff | 
| application/x-yaml | yaml yml | 
| application/xsl+xml | xsl | 
| application/xslt+xml | xslt | 
| image/svg+xml | svg | 
| image/x-icon | ico | 
| model/vrml | vrml wrl | 
| text/css | css | 
| text/html | htm html | 
| text/plain | AUTHORS COPYING ChangeLog INSTALL README RELEASE TXT text txt | 
| text/x-ada | ada adb ads | 
| text/x-asm | asm | 
| text/x-asp | asp | 
| text/x-awk | awk | 
| text/x-c++hdr | H HH c++hdr hh hpp | 
| text/x-c++src | C C++ CC c++ c++src cc cpp | 
| text/x-chdr | chdr h | 
| text/x-csharp | C# c# cs csharp | 
| text/x-csrc | c csrc xs | 
| text/x-diff | diff patch | 
| text/x-dylan | dylan | 
| text/x-eiffel | e eiffel | 
| text/x-elisp | el elisp | 
| text/x-fortran | f fortran | 
| text/x-haskell | haskell hs | 
| text/x-idl | ice idl | 
| text/x-inf | inf | 
| text/x-ini | cfg ini | 
| text/x-java | java | 
| text/x-ksh | ksh | 
| text/x-lua | lua | 
| text/x-m4 | m4 | 
| text/x-mail | mail | 
| text/x-makefile | GNUMakefile Makefile make makefile mk | 
| text/x-objc | m mm objc | 
| text/x-ocaml | ml mli ocaml | 
| text/x-pascal | pas pascal | 
| text/x-perl | PL perl pl pm | 
| text/x-php | php php3 php4 | 
| text/x-psp | psp | 
| text/x-pyrex | pyrex pyx | 
| text/x-python | py python | 
| text/x-rfc | rfc | 
| text/x-rst | rst | 
| text/x-ruby | rb ruby | 
| text/x-scheme | scheme scm | 
| text/x-sql | sql | 
| text/x-tcl | tcl | 
| text/x-tex | tex | 
| text/x-textile | textile txtl | 
| text/x-vba | bas vb vba | 
| text/x-verilog | v verilog | 
| text/x-vhdl | vhd vhdl | 
| text/x-zsh | zsh | 
| text/xml | xml | 
ハイライトパッケージがサポートする言語
このリストはほんの一例です:
| SilverCity | Enscript | Pygments | |
|---|---|---|---|
| Ada | ✓ | ||
| Asm | ✓ | ||
| Apache Conf | ✓ | ||
| ASP | ✓ | ✓ | |
| C | ✓ | ✓ | ✓ | 
| C# | ✓ (1) | ✓ | |
| C++ | ✓ | ✓ | ✓ | 
| Java | ✓ (2) | ✓ | ✓ | 
| Awk | ✓ | ||
| Boo | ✓ | ||
| CSS | ✓ | ✓ | |
| Python Doctests | ✓ | ||
| Diff | ✓ | ✓ | |
| Eiffel | ✓ | ||
| Elisp | ✓ | ||
| Fortran | ✓ (1) | ✓ | |
| Haskell | ✓ | ✓ | |
| Genshi | ✓ | ||
| HTML | ✓ | ✓ | ✓ | 
| IDL | ✓ | ||
| INI | ✓ | ||
| Javascript | ✓ | ✓ | ✓ | 
| Lua | ✓ | ||
| m4 | ✓ | ||
| Makefile | ✓ | ✓ | |
| Mako | ✓ | ||
| Matlab (3) | ✓ | ✓ | |
| Mygthy | ✓ | ||
| Objective-C | ✓ | ✓ | |
| OCaml | ✓ | ||
| Pascal | ✓ | ✓ | |
| Perl | ✓ | ✓ | ✓ | 
| PHP | ✓ | ✓ | |
| PSP | ✓ | ||
| Pyrex | ✓ | ||
| Python | ✓ | ✓ | ✓ | 
| Ruby | ✓ | ✓ (1) | ✓ | 
| Scheme | ✓ | ✓ | |
| Shell | ✓ | ✓ | |
| Smarty | ✓ | ||
| SQL | ✓ | ✓ | ✓ | 
| Troff | ✓ | ✓ | |
| TCL | ✓ | ||
| Tex | ✓ | ✓ | |
| Verilog | ✓ (2) | ✓ | |
| VHDL | ✓ | ||
| Visual Basic | ✓ | ✓ | |
| VRML | ✓ | ||
| XML | ✓ | ✓ | 
(1) Enscript のパッケージには含まれていません。 以下のハイライトルールを追加することが可能です。 Ruby, C#, Fortran 90x/2003
(2) Silvercity 0.9.7 は 2006-11-23 にリリースされました。
(3) デフォルトで、 .m ファイルは Objective-C のファイルだと解釈されます。 .m ファイルを MATLAB ファイルとして扱うためには、 "text/matlab:m" を trac.ini の [mimeviewer] セクション 内、 "mime_map" の設定に追加してください。
その他のソフトウェア
- GNU Enscript -- http://directory.fsf.org/GNU/enscript.html
 - GNU Enscript for Windows -- http://gnuwin32.sourceforge.net/packages/enscript.htm
 - SilverCity -- http://silvercity.sf.net/
 - Pygments -- http://pygments.org/
 
See also: WikiProcessors, WikiFormatting, TracWiki, TracBrowser
