Opened 19 years ago
Closed 19 years ago
#2723 closed enhancement (duplicate)
C# syntax highlighting
Reported by: | Owned by: | Jonas Borgström | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | version control/browser | Version: | 0.9.3 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Would be good if Trac supported C# source highlighting. I guess that's the only major format missing.
Attachments (1)
Change History (6)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Thanks, I got it working fairly easy on my testing/experimental Track installation (sample). It obviously lacks some C#-specific keywords (set, get, internal, delegate) but I guess the keywords can be fairly easily added to SilverCity.
I'm going to play with this a bit since I want to get some GLib-specific keywords (gint32, gint64, gfloat) in C-syntax as well. Hopefully we can push it upstream.
comment:3 by , 19 years ago
I'm attaching a patch against SilverCity-0.9.6 that adds support for full C# highlighting without altering the C++/C module/keywords. I duplicated the lexer/keywords table of the CPP module and tweaked it reflect the C# specifics.
by , 19 years ago
Attachment: | silvercity_cs.patch added |
---|
SilverCity 0.9.6 patch to add support for C# syntax highlighting
comment:4 by , 19 years ago
Ah, forgot to add - the new module is called CS. It needs to be enabled in trunk/trac/mimeview/silvercity.py with something like:
types = { ... ... 'text/x-c#src':['CS'], ... ... }
comment:5 by , 19 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
We are using SilverCity for highlighting, and after some research on the matter it seems that the highlighter actually supports C# - or rather the C/C++ formatter also supports C# syntax.
The .cs ending is also used for the Trac templating system (ClearSilver) that currently it not in the map. It will change from no formatting to C# formatting, and it actually picks up on some keywords and string formatting that makes it OK (but by no means complete…)
For us C# is more important as well, so a solution is to make changes in trunk/trac/mimeview/api.py as follows:
Either you can put the dictionary items right into the MIME_MAP, or put the code above into the file after the definition of MIME_MAP, or (as I have done to leave the Trac code intact) in something that executes as part of a custom plugin or similar in
__init__.py
or a file that it imports (needfrom trac.mimeview.api import MIME_MAP
before the code above if you do this).As you can see we have also added some other common ASP.Net endings that all get rendered relatively OK through default SilverCity install.