문제

I'd like to have Trac colorize my aspx files but I can't find a way to make it work. I can easily add a mime-type/extension mapping for most Pygments lexers, but the CSharpAspxLexer doesn't have an assigned mime type (see http://pygments.org/docs/lexers/#lexers-for-net-languages). I've tried a couple things but I don't see a way to connect the [mimeviewers] section to Pygments without a mime type. The CSharpLexer works automatically and looks great, but only for .cs files (as it should).

I'm using Mercurial as a repository so I can't set the mime type manually; that's not a good solution anyways. My Trac installation is in Windows. Any thoughts?

도움이 되었습니까?

해결책

I just render it as XML, and the same for a number of other similar files for typical Windows .Net development. My mapping looks like this:

[mimeviewer]
mime_map = text/xml:aspx:ascx:master:resx:config:sitemap:wsdl:disco:map:asmx:mxml:csproj, ...

However, I think you can also enable aspx via the pygments_modes setting (and you need to remove it from the mime_map):

[mimeviewer]
pygments_modes = text/plain:aspx-cs:7

To my knowledge that won't handle ascx and other (very) close relatives of aspx, so I don't use the setting as I find it better to render all variants using the same lexer. And also, I think the XML lexer works really well.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top