VirtualBox

源代码语法着色

Trac 支持在维基格式文本的维基处理器块中以及在仓库浏览器中对源代码进行特定语言的语法高亮显示。语法着色通过Pygments提供,该工具支持广泛的编程语言和其他结构化文本,并且受到积极支持。如果 Pygments 不可用,Trac 将以纯文本形式显示内容。

关于 Pygments

Pygments是一个纯Python实现的高亮库,速度非常快,易于扩展,并且文档齐全

Pygments 的默认样式可以在 trac.ini 的 mime-viewer 部分中指定。默认样式可以通过在首选项页面上设置一个样式偏好来覆盖。

Pygments 词法分析器选项可以作为 WikiProcessor 参数指定,默认值可以在环境配置中设置。

语法着色支持

支持的语言

当前支持的语言列表可以在支持的语言页面上找到。该列表代表 Pygments 最新版本中支持的语言,因此如果您安装的是旧版本,您的安装中实际支持的语言可能会有所不同。支持的词法分析器列表提供了关于默认 MIME 类型到关键字映射的额外信息。

通过mime_map设置,可以明确控制与WikiProcessor和文件扩展名关联的 MIME 类型。例如,默认情况下,.m文件被视为 Objective-C 文件。为了将.m文件视为 MATLAB 文件,请将text/matlab:m添加到[mimeviewer] mime_map选项中。

如果 MIME 类型属性(例如svn:mime-type)设置为text/plain,即使文件是已知类型(例如java),也不会进行着色。

直接渲染

富内容可以直接渲染,而不是进行语法高亮显示。这通常取决于您安装了哪些辅助包以及在您的设置中激活了哪些组件。例如,如果安装了docutils并且未禁用trac.mimeview.rst.ReStructuredTextRenderer,则text/x-rst文档将通过docutils渲染。否则,它将进行语法高亮显示。

同样,MIME 类型为text/x-trac-wiki的文档将使用 Trac 维基格式化程序渲染,除非trac.mimeview.api.WikiTextRenderer组件被禁用。如果您想确保 HTML 文档进行语法高亮显示而不是渲染,请使用text/xmlMIME 类型。

仅当在您的TracIni文件中启用了render_unsafe_html设置时,HTML 文档才会被直接渲染。请参阅[attachment] render_unsafe_content[browser] render_unsafe_content[wiki] render_unsafe_content。该设置存在于多个部分中,因为根据文档来源的不同,存在不同的安全问题。

已知 MIME 类型

MIME 类型Wiki处理器
application/atom+xmlxml
application/jsonjson
application/json-objectjson-object
application/kalkal
application/ld+jsonjson-ld jsonld
application/msworddoc dot
application/pdfpdf
application/postscriptpostscr postscript ps
application/rss+xmlrss
application/rtfrtf
application/sparql-querysparql
application/vnd.wolfram.cdfmathematica mma nb
application/x-awkawk gawk mawk nawk
application/x-befungebefunge
application/x-brainfuckbf brainfuck
application/x-chaiscriptchai chaiscript
application/x-clojureclj clojure
application/x-clojurescriptcljs clojurescript
application/x-coldfusioncfm
application/x-cshcsh tcsh
application/x-cythoncython pyrex pyx
application/x-dos-batchbat batch cmd dos dosbatch winbatch
application/x-eclecl
application/x-elispelisp emacs emacs-lisp
application/x-evoqueevoque
application/x-fantomfan
application/x-fishfish fishshell
application/x-forthforth
application/x-gooddata-maqlmaql
application/x-httpd-lasso[89]html+lasso
application/x-httpd-php5html+php
application/x-hyhylang
application/x-hybrishy hybris
application/x-jinjadjango jinja
application/x-jspjsp
application/x-juliajl julia
application/x-kidgenshi kid xml+genshi xml+kid
application/x-lualua
application/x-makomako
application/x-masonmason
application/x-moonscriptmoon moonscript
application/x-myghtymyghty
application/x-newlispnewlisp
application/x-openedgeabl openedge progress
application/x-perlperl pl
application/x-perl6perl6 pl6
application/x-pygments-tokensraw
application/x-pypylogpypy pypylog
application/x-python2py2 python2
application/x-python3py py3 python python3 sage
application/x-qt.qbs+qmlqbs qml
application/x-racketracket rkt
application/x-rubyduby rb ruby
application/x-ruby-templatingerb
application/x-sassas
application/x-schemescheme scm
application/x-sh-sessionconsole shell-session
application/x-shenshen
application/x-smartysmarty
application/x-spitfirecheetah spitfire
application/x-sspssp
application/x-standardmlsml
application/x-statado stata
application/x-tcltcl
application/x-terraformterraform tf
application/x-thriftthrift
application/x-troffroff troff
application/x-turtleturtle
application/x-twigtwig
application/x-urbiscripturbiscript
application/x-yamlyml
application/xhtml+xmlhtml
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/xqueryxq xql xqm xquery xqy
application/xsl+xmlxsl
application/xslt+xmlxslt
image/svg+xmlsvg
image/x-iconico
message/rfc822email eml
model/vrmlvrml wrl
multipart/alternativemime
text/actionscriptactionscript as
text/actionscript3actionscript3 as3
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/gettextpo pot
text/htmlhtm
text/html+evoquehtml+evoque
text/html+genshihtml+genshi html+kid
text/html+jinjahtml+django html+jinja htmldjango
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/infcfg dosini ini
text/ipfigor igorpro
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+lassojavascript+lasso js+lasso
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/jsgfjsgf
text/juttlejuttle
text/limbolimbo
text/livescriptlive-script livescript
text/matlabmatlab
text/nclncl
text/octaveoctave
text/odinodin
text/plainAUTHORS COPYING ChangeLog INSTALL README RELEASE TXT log text txt
text/prs.fallenstein.rstrest restructuredtext rst
text/rslrsl
text/rustrs rust
text/scilabscilab
text/shexshex shexc
text/smalismali
text/supercollidersc supercollider
text/swigswig
text/troffgroff man nroff
text/uniconunicon
text/x-abapabap
text/x-abnfabnf
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-bibtexbib bibtex
text/x-bmxblitzmax bmax
text/x-bnfbnf
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-ceylonceylon
text/x-chdrchdr h
text/x-cirrucirru
text/x-clayclay
text/x-cmakecmake
text/x-cobolcobol
text/x-common-lispcl common-lisp lisp
text/x-component-pascalcomponentpascal cp
text/x-coqcoq
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-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
text/x-elixirelixir ex exs
text/x-elixir-shellsessioniex
text/x-elmelm
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 fortran
text/x-freefemfreefem
text/x-fsharpf# fsharp
text/x-gasasm gas
text/x-genshigenshitext
text/x-gherkincucumber gherkin
text/x-glslsrcglsl
text/x-gnuplotgnuplot
text/x-gooddata-clgooddata-cl
text/x-gosrcgo
text/x-gosugosu
text/x-gosu-templategst
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-idlice
text/x-idrisidr idris
text/x-infinf
text/x-iokesrcik ioke
text/x-iosrcio
text/x-irclogirc
text/x-isabelleisabelle
text/x-jj
text/x-jadejade pug
text/x-javajava
text/x-java-propertiesjproperties properties
text/x-jbstduel jbst jsonml+bst
text/x-jcljcl
text/x-kconfigkconfig kernel-config linux-config menuconfig
text/x-kokakoka
text/x-kotlinkotlin
text/x-lassolasso lassoscript
text/x-latexlatex tex
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-m4m4
text/x-mailmail
text/x-makefileGNUMakefile Makefile bsdmake make makefile mf mk
text/x-markdownmd
text/x-maskmask
text/x-minidsrcminid
text/x-modelicamodelica
text/x-modula2m2 modula2
text/x-monkeymonkey
text/x-moocodemoo moocode
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-newspeaknewspeak
text/x-nginx-confnginx nginx-conf
text/x-nimnim nimrod
text/x-nixnix nixos
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-parasailparasail
text/x-pascaldelphi objectpascal pas pascal
text/x-patchdiff udiff
text/x-pawnpawn
text/x-perlPL pm
text/x-phpphp php3 php4 php5
text/x-pigpig
text/x-pikepike
text/x-plpgsqlplpgsql
text/x-postgresqlpostgres postgresql
text/x-postgresql-psqlpostgres-console postgresql-console psql
text/x-povraypov
text/x-powershellposh powershell ps1 psm1
text/x-prologprolog
text/x-psppsp
text/x-python-doctestpycon python-doctest
text/x-python2-tracebackpy2tb
text/x-python3-tracebackpy3tb pytb
text/x-r-docrd
text/x-r-profiler s splus
text/x-rebolrebol
text/x-red-systemred red/system
text/x-rexxarexx rexx
text/x-rfcrfc
text/x-robotframeworkrobotframework
text/x-rpm-specspec
text/x-rqlrql
text/x-ruby-shellsessionirb rbcon
text/x-sarlsarl
text/x-sasssass
text/x-scalascala
text/x-scamlscaml
text/x-scssscss
text/x-shellscriptbash ksh sh shell zsh
text/x-slimslim
text/x-slssalt sls yaml+jinja
text/x-smalltalksmalltalk squeak st
text/x-snobolsnobol
text/x-sourcepawnsp
text/x-sqlsql
text/x-sqlite3-consolesqlite3
text/x-squidconfsquid squid.conf squidconf
text/x-swiftswift
text/x-systemverilogsv systemverilog
text/x-tasmtasm
text/x-teatea
text/x-teratermmacroteraterm teratermmacro ttl
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-valavala vapi
text/x-vbabas vb vb.net vba vbnet
text/x-vclsnippetvclsnippet vclsnippets
text/x-vclsrcvcl
text/x-verilogv verilog
text/x-vhdlvhd vhdl
text/x-vimvim
text/x-whileywhiley
text/x-windows-registryregistry
text/x-x10x10 xten
text/x-xtendxtend
text/x-yamlyaml
text/zigzig


另请参阅:Wiki处理器维基格式Trac维基Trac浏览器

最后修改 2 年前 最后修改于 2023/06/02 上午 10:32:55
注意: 查看 TracWiki 获取使用维基的帮助。

© 2025 Oracle 支持 隐私 / 请勿出售我的信息 使用条款 商标政策 自动化访问礼仪