wiki:TracSyntaxColoring

Version 2 (modified by trac, 16 years ago) (diff)

--

ソースコードのシンタックスカラーリング

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 TypesWikiProcessors
application/msworddoc dot
application/pdfpdf
application/postscriptpostscript ps
application/rss+xmlrss
application/rtfrtf
application/x-befungebefunge
application/x-brainfuckbf brainfuck
application/x-clojureclj clojure
application/x-coldfusioncfm
application/x-cshcsh tcsh
application/x-cythoncython pyx
application/x-dos-batchbat
application/x-evoqueevoque
application/x-gooddata-maqlmaql
application/x-httpd-php5html+php
application/x-hybrishy hybris
application/x-jinjadjango jinja
application/x-jspjsp
application/x-kidgenshi kid xml+genshi xml+kid
application/x-lualua
application/x-makomako
application/x-masonmason
application/x-myghtymyghty
application/x-perlperl pl
application/x-pygments-tokensraw
application/x-pythonpy python
application/x-python3py3 python3
application/x-rubyduby rb ruby
application/x-ruby-templatingerb
application/x-schemescheme scm
application/x-shell-sessionconsole
application/x-shellscriptbash ksh sh
application/x-smartysmarty
application/x-spitfirecheetah spitfire
application/x-sspssp
application/x-tcltcl
application/x-troffroff troff
application/x-yamlyml
application/xhtml+xmlhtml
application/xml+evoquexml+evoque
application/xml+jinjaxml+django xml+jinja
application/xml+makoxml+mako
application/xml+myghtyxml+myghty
application/xml+phpxml+php
application/xml+rubyxml+erb xml+ruby
application/xml+smartyxml+smarty
application/xml+spitfirexml+cheetah xml+spitfire
application/xml+velocityxml+velocity
application/xqueryxquery xqy
application/xsl+xmlxsl
application/xslt+xmlxml xslt
image/svg+xmlsvg
image/x-iconico
model/vrmlvrml wrl
text/Rr s splus
text/actionscriptactionscript actionscript3 as as3
text/coffeescriptcoffee-script coffeescript
text/csscss
text/css+genshicss+genshi css+genshitext
text/css+jinjacss+django css+jinja
text/css+makocss+mako
text/css+myghtycss+myghty
text/css+phpcss+php
text/css+rubycss+erb css+ruby
text/css+smartycss+smarty
text/gettextpo pot
text/haxehaXe hx
text/htmlhtm
text/html+evoquehtml+evoque
text/html+genshihtml+genshi html+kid
text/html+jinjahtml+django html+jinja
text/html+makohtml+mako
text/html+myghtyhtml+myghty
text/html+rubyhtml+erb html+ruby rhtml
text/html+smartyhtml+smarty
text/html+spitfirehtml+cheetah html+spitfire
text/html+velocityhtml+velocity
text/javascriptjavascript js
text/javascript+genshijavascript+genshi javascript+genshitext js+genshi js+genshitext
text/javascript+jinjajavascript+django javascript+jinja js+django js+jinja
text/javascript+makojavascript+mako js+mako
text/javascript+mygthyjavascript+myghty js+myghty
text/javascript+phpjavascript+php js+php
text/javascript+rubyjavascript+erb javascript+ruby js+erb js+ruby
text/javascript+smartyjavascript+smarty js+smarty
text/javascript+spitfirejavascript+cheetah javascript+spitfire js+cheetah js+spitfire
text/matlabmatlab octave
text/plainAUTHORS COPYING ChangeLog INSTALL README RELEASE TXT text txt
text/prs.fallenstein.rstrest restructuredtext rst
text/troffgroff man nroff
text/x-abapabap
text/x-adaada ada95ada2005 adb ads
text/x-apacheconfaconf apache apacheconf
text/x-asmasm
text/x-aspasp
text/x-asymptoteasy asymptote
text/x-autohotkeyahk
text/x-awkawk
text/x-bbcodebbcode
text/x-bmxblitzmax bmax
text/x-booboo
text/x-c++hdrH HH c++hdr hh hpp
text/x-c++srcC C++ CC c++ c++src cc cpp
text/x-c-objdumpc-objdump
text/x-chdrchdr h
text/x-cmakecmake
text/x-common-lispcl common-lisp
text/x-cpp-objdumpc++-objdumb cpp-objdump cxx-objdump
text/x-csharpC# c# cs csharp
text/x-csrcc csrc xs
text/x-d-objdumpd-objdump
text/x-diffpatch
text/x-dsrcd
text/x-dylandylan
text/x-eiffele eiffel
text/x-elispel elisp
text/x-erl-shellsessionerl
text/x-erlangerlang
text/x-factorfactor
text/x-felixfelix flx
text/x-fortranf fortran
text/x-gasgas
text/x-genshigenshitext
text/x-gherkinCucumber Gherkin cucumber gherkin
text/x-glslsrcglsl
text/x-gnuplotgnuplot
text/x-gooddata-clgooddata-cl
text/x-gosrcgo
text/x-hamlHAML haml
text/x-haskellhaskell hs
text/x-idlice idl
text/x-infinf
text/x-inicfg ini
text/x-iokesrcik ioke
text/x-iosrcio
text/x-irclogirc
text/x-jadeJADE jade
text/x-javajava
text/x-java-propertiesproperties
text/x-jbstDuel Engine Duel View JBST JsonML+BST duel jbst
text/x-latexlatex tex
text/x-lighttpd-conflighttpd lighty
text/x-literate-haskelllhs literate-haskell
text/x-llvmllvm
text/x-logtalklogtalk
text/x-m4m4
text/x-mailmail
text/x-makefileGNUMakefile Makefile bsdmake make makefile mf mk
text/x-minidsrcminid
text/x-modelicamodelica
text/x-modula2m2 modula2
text/x-moocodemoocode
text/x-mysqlmysql
text/x-nasmnasm
text/x-newspeaknewspeak
text/x-nginx-confnginx
text/x-objcm mm
text/x-objdumpobjdump
text/x-objective-cobj-c objc objective-c objectivec
text/x-objective-jobj-j objective-j objectivej objj
text/x-ocamlml mli ocaml
text/x-oocooc
text/x-pascaldelphi objectpascal pas pascal
text/x-patchdiff udiff
text/x-perlPL pm
text/x-phpphp php3 php4 php5
text/x-povraypov
text/x-prologprolog
text/x-psppsp
text/x-pyrexpyrex
text/x-python-doctestpycon
text/x-python-tracebackpytb
text/x-python3-tracebackpy3tb
text/x-rebolrebol
text/x-rfcrfc
text/x-ruby-shellsessionirb rbcon
text/x-sassSASS sass
text/x-scalascala
text/x-scamlSCAML scaml
text/x-scssscss
text/x-smalltalksmalltalk squeak
text/x-sqlsql
text/x-sqlite3-consolesqlite3
text/x-squidconfsquid squid.conf squidconf
text/x-textiletextile txtl
text/x-trac-wikimoin trac-wiki
text/x-valavala vapi
text/x-vbabas vb vb.net vba vbnet
text/x-verilogv verilog
text/x-vhdlvhd vhdl
text/x-vimvim
text/x-yamlyaml
text/x-zshzsh

ハイライトパッケージがサポートする言語

このリストはほんの一例です:

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" の設定に追加してください。

その他のソフトウェア


See also: WikiProcessors, WikiFormatting, TracWiki, TracBrowser