Opened 20 years ago
Closed 18 years ago
#636 closed enhancement (wontfix)
Trac support for a SilverCity module
Reported by: | Owned by: | Christian Boos | |
---|---|---|---|
Priority: | lowest | Milestone: | |
Component: | wiki system | Version: | 0.7.1 |
Severity: | normal | Keywords: | csharp silvercity syntax coloring |
Cc: | aj@…, David_Chilton@…, junkmail.joe@…, rhind@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I've put together the modifications necessary to highlight C# code with Trac using SilverCity. I figured I'd submit them, in case you all say fit to use it. :)
Anyhow, directions are as follows:
trac/Wiki.py needs an update on line 34 to include the hash symbol in the regex.
processor_re = re.compile('#\!([a-zA-Z#]+)')
MIME_MAP in trac/Mimeview.py gets two new entries:
'c#':'text/x-csharp', 'cs':'text/x-csharp',
trac/mimeviewers/silvercity.py has a few changes:
supported_types gets a new entry:
(1, 'text/x-csharp'),
as does type_lang:
'text/x-csharp':['CSharp'],
The site-packages/SilverCity directory gets a new file: CSharp.py. This file has been attached.
Finally, site-packages/SilverCity/Keywords.py gets a new entry:
csharp_keywords = \ "bool break case catch char class const continue "\ "default delete do double else enum explicit export extern false float for foreach "\ "friend goto if inline in int interface long mutable namespace new operator private protected public "\ "register return sealed short signed sizeof static string struct switch "\ "this throw true try typedef typeid typename union unsigned using "\ "virtual void volatile while"
And that should do it. Trac can now syntax-color .cs files, as well as code blocks marked with #!cs or #!c#
See it in action here (source file), or here (inline code block).
Attachments (1)
Change History (24)
by , 20 years ago
comment:1 by , 20 years ago
Oops - and one more addition.
site-packages/SilverCity/LanguageInfo.py contains method do_registration() on line 114. This method needs a line added to it, as well:
import CSharp
comment:2 by , 20 years ago
Milestone: | → 0.8 |
---|
Looks good, but I think we should use #!csharp
instead of #!c#
. One hash-symbol is enough, it's confusing at it is already.
comment:3 by , 20 years ago
Milestone: | 0.8 → 0.9 |
---|
Has CSharp.py been included into the upstream version of silvercity yet? I guess there is no point in modifying trac until that happens, right?
comment:4 by , 20 years ago
Cc: | added |
---|
I would love to see C# syntax support by default in trac. I'm having trouble getting it to work by following the instructions (HACK) above.
It doesn't look like much is happening on silvercity so I'm worried that this will drop out of sight (already milestone 0.9). I'm not a python guy, but if I can do anything to make it happen, let me know.
comment:5 by , 20 years ago
I would also like to see C# syntax by default in 0.8, but since that version is just about ready for release, I will wait. I will try the hack above in the meantime.
comment:6 by , 20 years ago
Cc: | added |
---|
I found that to get the inline code coloring to work in Trac 0.8 I had to make a few changes to WikiFormatter.py.
I added:
'cs':csharp_processor, 'csharp':csharp_processor,
to the list of builtin processors on line 323 and
def csharp_processor(hdf,text,env): return env.mimeview.display(text, 'text/x-csharp') }}} some where before that, with the definitions of the processors I also ignored the change to add the hash symbol to the regex string, following jonas' suggestion of useing csharp instead of c#
comment:7 by , 20 years ago
oops forgot to put a new line after the code block, Wiki doesn't like that
also add:
def csharp_processor(hdf,text,env): return env.mimeview.display(text, 'text/x-csharp')
with the definitions of the processors
I also ignored the change to add the hash symbol to the regex string, following jonas' suggestion of useing csharp instead of c#
comment:9 by , 20 years ago
Some of those keywords you supplied are not keywords in csharp. Also there is some keywords that are not included in your list.
C# Keywords
abstract | event | new | struct |
as | explicit | null | switch |
base | extern | object | this |
bool | false | operator | throw |
break | finally | out | true |
byte | fixed | override | try |
case | float | params | typeof |
catch | for | private | uint |
char | foreach | protected | ulong |
checked | goto | public | unchecked |
class | if | readonly | unsafe |
const | implicit | ref | ushort |
continue | in | return | using |
decimal | int | sbyte | virtual |
default | interface | sealed | volatile |
delegate | internal | short | void |
do | is | sizeof | while |
double | lock | stackalloc | |
else | long | static | |
enum | namespace | string |
comment:11 by , 19 years ago
Cc: | added |
---|
This would be very nice. It seems that the changes suggested are a bit out-dated so I hope the Trac team could find time to do this one.
comment:12 by , 19 years ago
Spoke too soon! Ignorning the part about process_re
and the regex and just doing everything else works. I guess I wonder why this doesn't become part of the Trac main code, but I can't complain since it isn't that hard … and .Net development isn't probably as popular.
comment:13 by , 19 years ago
I found out trac 0.9b1 only requires the following changes to support c# highlighting:
- Add the following entry to types in ./mimeview/silvercity.py
'text/x-csharp':['CSharp'],
- Add the following entry to MIME_MAP in ./mimeview/api.py
'c#':'text/x-csharp', 'cs':'text/x-csharp',
- Changes to SilverCity site package described in above comments
comment:14 by , 19 years ago
I don't understand, why hasn't this made it to the main development tree? it's pretty trivial, at the very least a c++ lexer could be applied to c# source files, I'll put up a request at silvercity as well.
comment:15 by , 19 years ago
The changes Eric Moret described above could be done in the future by customizing the TracIni, like suggested in #2874.
Modifying the ./mimeview/silvercity.py and ./mimeview/api.py source files is probably a bad idea at this point, since this would imply that SilverCity supports C# out of the box, which is apparently not the case.
It would also help if someone prepares a new C# support patch for SilverCity (the attachment:CSharp.py seems to have a number of flaws, according to the comments above).
comment:16 by , 19 years ago
Cc: | added |
---|
comment:17 by , 19 years ago
Owner: | changed from | to
---|
comment:18 by , 18 years ago
#2874 is now fixed. I leave this open until someone provides a good CSharp.py implementation.
comment:19 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I've added a request for this on SilverCity's tracker, so if changes need to be made on SilverCity's side please add them here: http://sourceforge.net/tracker/index.php?func=detail&aid=1523628&group_id=45693&atid=443741
I'm closing this ticket since I don't see a reason to keep this open unless there's upstream support for the language. I've requested that the SilverCity devs reopen this ticket when C# support is added and at that time we can support it in Trac.
comment:20 by , 18 years ago
Milestone: | → 0.11 |
---|---|
Resolution: | wontfix |
Status: | closed → reopened |
I understand why the ticket was closed because SilverCity needs to implement csharp highlighting before Trac can use it.
But, it looks like SilverCity is being replaced by Genshi. So, my thinking is, we can reopen this ticket and mark it for milestone:0.11.
Does a ticket need to be opened on the Genshi project, instead? Or both?
comment:21 by , 18 years ago
Milestone: | 0.11 |
---|---|
Resolution: | → wontfix |
Status: | reopened → closed |
No, there's a misunderstanding here: Genshi has nothing to do with syntax highlighting.
If you're interested in progress related to TracSyntaxColoring, I'd suggest that you keep an eye on #366, as Colorer supports C# highlighting out of the box.
comment:22 by , 18 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
I've added this patch to SilverCity svn. It will be available when SilverCity 0.98 is released.
Any testing would be appreciated: svn co https://svn.sourceforge.net/svnroot/silvercity silvercity
You have to move the trunk/scintilla directory into trunk/silvercity for setup.py to work
comment:23 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
If SilverCity 0.9.8 will support C#, all the better. However, this is not Trac's primary concern, as we focus now on Pygments as our default highlighting engine for 0.11, and Pygments has C# support. See TracSyntaxColoring.
CSharp.py file for SilverCity syntax coloring of C# files.