wiki:TracSyntaxColoring

Version 2 (modified by trac, 12 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/json-objectjson json-object
application/ld+jsonjson-ld jsonld
application/msworddoc
application/pdfpdf
application/pgp-signatureasc pem
application/postscriptpostscr postscript ps
application/rss+xmlrss
application/rtfrtf
application/sparql-querysparql
application/vnd.wolfram.mathematica.packagemathematica mma nb
application/x-awkawk gawk mawk nawk
application/x-befungebefunge
application/x-brainfuckbf brainfuck
application/x-coldfusioncfm
application/x-cshcsh tcsh
application/x-dos-batchbat batch cmd dos dosbatch winbatch
application/x-eclecl
application/x-evoqueevoque
application/x-fantomfan
application/x-fishfish fishshell
application/x-forthforth
application/x-jinjadjango jinja
application/x-jspjsp
application/x-kidgenshi kid xml+genshi xml+kid
application/x-makomako
application/x-masonmason
application/x-myghtymyghty
application/x-openscadopenscad
application/x-phphtml+php
application/x-pypylogpypy pypylog
application/x-qt.qbs+qmlqbs qml
application/x-ruby-templatingerb
application/x-shell-sessionconsole shell-session
application/x-smartysmarty
application/x-spitfirecheetah spitfire
application/x-sspssp
application/x-tfhcl terraform tf
application/x-thriftthrift
application/x-troffroff troff
application/x-twigtwig
application/x-urbiscripturbiscript
application/x-www-form-urlencodedurlencoded
application/x-yamlyml
application/xml+evoquexml+evoque
application/xml+jinjaxml+django xml+jinja
application/xml+lassoxml+lasso
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/xml-dtddtd
application/xsl+xmlxsl
application/xslt+xmlxslt
application/yangyang
image/svg+xmlsvg
image/x-iconico
message/rfc822email eml
model/vrmlvrml wrl
multipart/relatedmime
text/basicbasic qbasic
text/coffeescriptcoffee coffee-script coffeescript
text/csscss
text/css+genshicss+genshi css+genshitext
text/css+jinjacss+django css+jinja
text/css+lassocss+lasso
text/css+makocss+mako
text/css+myghtycss+myghty
text/css+phpcss+php
text/css+rubycss+erb css+ruby
text/css+smartycss+smarty
text/dnszone
text/htmlhtm html
text/html+evoquehtml+evoque
text/html+genshihtml+genshi html+kid
text/html+jinjahtml+django html+jinja htmldjango
text/html+lassohtml+lasso
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 htmlcheetah
text/html+twightml+twig
text/html+velocityhtml+velocity
text/idlidl
text/ipfigor igorpro
text/jsgfjsgf
text/kalkal
text/limbolimbo
text/livescriptlive-script livescript
text/matlabmatlab
text/mcfunctionmcf mcfunction
text/mcschemamcschema
text/nclncl
text/octaveoctave
text/odinodin
text/plainAUTHORS COPYING ChangeLog INSTALL README RELEASE TXT text txt
text/ritarita
text/rslrsl
text/scilabscilab
text/shexshex shexc
text/smalismali
text/snbtsnbt
text/supercollidersc supercollider
text/swigswig
text/troffgroff man nroff
text/turtleturtle
text/uniconunicon
text/vnd.tiddlywikitid
text/wgslwgsl
text/x-abapabap
text/x-abnfabnf
text/x-actionscriptactionscript as
text/x-actionscript3actionscript3 as3
text/x-adaada ada2005 ada95 adb ads
text/x-agdaagda
text/x-alloyalloy
text/x-ambienttalkambienttalk ambienttalk/2 at
text/x-apacheconfaconf apache apacheconf
text/x-arduinoarduino
text/x-aspasp
text/x-aspectjaspectj
text/x-asymptoteasy asymptote
text/x-autohotkeyahk autohotkey
text/x-autoitautoit
text/x-bbb3d blitzbasic bplus
text/x-bbcodebbcode
text/x-bddbdd
text/x-berrybe berry
text/x-bibtexbib bibtex
text/x-blueprintblueprint
text/x-bmxblitzmax bmax
text/x-bnfbnf
text/x-booboo
text/x-cdevicetree dts
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-carboncarbon
text/x-cddlcddl
text/x-ceylonceylon
text/x-chaiscriptchai chaiscript
text/x-chdrchdr h
text/x-cirrucirru
text/x-clayclay
text/x-clojureclj clojure
text/x-clojurescriptcljs clojurescript
text/x-cmakecmake
text/x-cobolcobol
text/x-common-lispcl common-lisp lisp
text/x-component-pascalcomponentpascal cp
text/x-coqcoq
text/x-cplintcplint
text/x-cpp-objdumpc++-objdumb cpp-objdump cxx-objdump
text/x-crocsrccroc
text/x-cryptolcry cryptol
text/x-crystalcr crystal
text/x-csharpC# c# cs csharp
text/x-csrcc csrc xs
text/x-cudacu cuda
text/x-cythoncython pyrex pyx
text/x-d-objdumpd-objdump
text/x-dartdart
text/x-dasm16dasm16
text/x-dgdg
text/x-diffpatch
text/x-dockerfile-configdocker dockerfile
text/x-dsrcd
text/x-dylandylan
text/x-dylan-consoledylan-console dylan-repl
text/x-dylan-liddylan-lid lid
text/x-earl-greyearl-grey earlgrey eg
text/x-easytrieveeasytrieve
text/x-ebnfebnf
text/x-ecsrcec
text/x-eiffele eiffel
text/x-elispel elisp emacs emacs-lisp
text/x-elixirelixir ex exs
text/x-elixir-shellsessioniex
text/x-elmelm
text/x-elpielpi
text/x-erl-shellsessionerl
text/x-erlangerlang
text/x-ezhilezhil
text/x-factorfactor
text/x-fancysrcfancy fy
text/x-felixfelix flx
text/x-flatlineflatline
text/x-fortranf f90 fortran
text/x-freefemfreefem
text/x-fsharpf# fsharp
text/x-fstarfstar
text/x-futharkfuthark
text/x-gasasm gas
text/x-gdscriptgd gdscript
text/x-genshigenshitext
text/x-gettextpo pot
text/x-gherkincucumber gherkin
text/x-glslsrcglsl
text/x-gnuplotgnuplot
text/x-gooddata-clgooddata-cl
text/x-gooddata-maqlmaql
text/x-gosrcgo golang
text/x-gosugosu
text/x-gosu-templategst
text/x-graphvizdot graphviz
text/x-groovygroovy
text/x-hamlhaml
text/x-handlebars-templatehtml+handlebars
text/x-haskellhaskell hs
text/x-hlslhlsl
text/x-hsailhsa hsail
text/x-hxhaxe hx hxsl
text/x-hyhylang
text/x-hybrishy hybris
text/x-idlice
text/x-idrisidr idris
text/x-infinf
text/x-inicfg dosini ini
text/x-iokesrcik ioke
text/x-iosrcio
text/x-irclogirc
text/x-isabelleisabelle
text/x-jj
text/x-javajava
text/x-java-propertiesjproperties properties
text/x-javascriptjavascript js
text/x-javascript+genshijavascript+genshi javascript+genshitext js+genshi js+genshitext
text/x-javascript+jinjajavascript+django javascript+jinja js+django js+jinja
text/x-javascript+lassojavascript+lasso js+lasso
text/x-javascript+makojavascript+mako js+mako
text/x-javascript+myghtyjavascript+myghty js+myghty
text/x-javascript+phpjavascript+php js+php
text/x-javascript+rubyjavascript+erb javascript+ruby js+erb js+ruby
text/x-javascript+smartyjavascript+smarty js+smarty
text/x-javascript+spitfirejavascript+cheetah javascript+spitfire js+cheetah js+spitfire
text/x-jbstduel jbst jsonml+bst
text/x-jcljcl
text/x-jsltjslt
text/x-juliajl julia
text/x-juttlejuttle
text/x-kconfigkconfig kernel-config linux-config menuconfig
text/x-kokakoka
text/x-kotlinkotlin
text/x-lassolasso lassoscript
text/x-leanlean
text/x-less-cssless
text/x-lighttpd-conflighttpd lighty
text/x-literate-agdalagda literate-agda
text/x-literate-cryptollcry lcryptol literate-cryptol
text/x-literate-haskelllhaskell lhs literate-haskell
text/x-literate-idrislidr lidris literate-idris
text/x-llvmllvm
text/x-logoslogos
text/x-logtalklogtalk
text/x-lsllsl
text/x-lualua
text/x-m4m4
text/x-mailmail
text/x-makefileGNUMakefile Makefile bsdmake make makefile mf mk
text/x-markdownmarkdown md
text/x-maskmask
text/x-mesonmeson meson.build
text/x-minicriptminiscript ms
text/x-minidsrcminid
text/x-modelicamodelica
text/x-modula2m2 modula2
text/x-monkeymonkey
text/x-moocodemoo moocode
text/x-moonscriptmoon moonscript
text/x-mqlmq4 mq5 mql mql4 mql5
text/x-mysqlmysql
text/x-nasmnasm
text/x-nasm-objdumpobjdump-nasm
text/x-nemerlenemerle
text/x-nescsrcnesc
text/x-newlispnewlisp
text/x-newspeaknewspeak
text/x-nginx-confnginx nginx-conf
text/x-nimnim nimrod
text/x-nixnix nixos
text/x-nodejsreplnodejsrepl
text/x-nsisnsh nsi nsis
text/x-objcm mm
text/x-objdumpobjdump
text/x-objective-cobj-c objc objective-c objectivec
text/x-objective-c++obj-c++ objc++ objective-c++ objectivec++
text/x-objective-jobj-j objective-j objectivej objj
text/x-ocamlml mli ocaml
text/x-oocooc
text/x-opaopa
text/x-openedgeabl openedge progress
text/x-parasailparasail
text/x-pascaldelphi objectpascal pas pascal
text/x-patchdiff udiff
text/x-pawnpawn
text/x-pegpeg
text/x-perlPL perl pl pm
text/x-perl6perl6 pl6 raku
text/x-phixphix
text/x-phpphp php3 php4 php5
text/x-pigpig
text/x-pikepike
text/x-plpgsqlplpgsql
text/x-postgresqlpostgres postgresql
text/x-postgresql-explainpostgres-explain
text/x-postgresql-psqlpostgres-console postgresql-console psql
text/x-povraypov
text/x-powershellposh powershell ps1 psm1 pwsh
text/x-prologprolog
text/x-psppsp
text/x-ptxptx
text/x-pugjade pug
text/x-python-doctestpycon python-doctest
text/x-python2py2 python2
text/x-python2-tracebackpy2tb
text/x-python3py py3 python python3 sage
text/x-python3-tracebackpy3tb pytb
text/x-r-docrd
text/x-r-sourcer s splus
text/x-racketracket rkt
text/x-reasonmlreason reasonml
text/x-rebolrebol
text/x-red-systemred red/system
text/x-rexxarexx rexx
text/x-rfcrfc
text/x-rideride
text/x-robotframeworkrobotframework
text/x-rpm-specspec
text/x-rqlrql
text/x-rstrest restructuredtext rst
text/x-rubyduby rb ruby
text/x-ruby-shellsessionirb rbcon
text/x-rustrs rust
text/x-sarlsarl
text/x-sassas
text/x-sasssass
text/x-scalascala
text/x-scamlscaml
text/x-schemescheme scm
text/x-scssscss
text/x-sedgsed sed ssed
text/x-shellscriptbash ksh sh shell zsh
text/x-shenshen
text/x-slimslim
text/x-smalltalksmalltalk squeak st
text/x-snobolsnobol
text/x-sourcepawnsp
text/x-spicespice spicelang
text/x-sqlsql
text/x-sqlite3-consolesqlite3
text/x-squidconfsquid squid.conf squidconf
text/x-standardmlsml
text/x-statado stata
text/x-swiftswift
text/x-systemverilogsv systemverilog
text/x-tasmtasm
text/x-tcltcl
text/x-teatea
text/x-teratermmacroteraterm teratermmacro ttl
text/x-texlatex tex
text/x-textiletextile txtl
text/x-todotodotxt
text/x-trac-wikimoin trac-wiki
text/x-tsqlt-sql tsql
text/x-typescriptts typescript
text/x-typoscripttyposcript
text/x-uxntaltal uxntal
text/x-valavala vapi
text/x-vbabas vb vba
text/x-vbnetlobas oobas sobas vb.net vbnet
text/x-vclsnippetvclsnippet vclsnippets
text/x-vclsrcvcl
text/x-verifpalverifpal
text/x-verilogv verilog
text/x-vhdlvhd vhdl
text/x-vimvim
text/x-whileywhiley
text/x-wikimediawiki wikitext
text/x-windows-registryregistry
text/x-x10x10 xten
text/x-xtendxtend
text/x-yamlyaml
text/x-yaml+jinjasalt sls yaml+jinja
text/x-yarayar yara
text/xmlxml
text/xqueryxq xql xqm xquery xqy
text/zigzig

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

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

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

Note: See TracWiki for help on using the wiki.