Description of problem: I have "enable_syntax_coloration = 1", but I'm not seeing any color highlighting. There isn't any exception raised, I get the view of the code, but it's just not highlighted. I've tried running pygmentize on the command line, dumping out an html file and that works fine. I've been trying to pinpoint what's happening, but haven't had much luck. Version-Release number of selected component (if applicable): viewvc-1.1.1-1.fc11 python-pygments-1.0-4.fc11 How reproducible: always Steps to Reproduce: 1. "enable_syntax_coloration = 1" in viewvc.conf 2. code isn't colored/highlighted. Actual results: no color highlighting. Expected results: color highlighting.
Created attachment 355711 [details] my viewvc config - slightly edited
What kind of file are you trying to see coloured? There is only a limited number of lexers shipped with python-pygments in Fedora. For instance, I can see SQL and XML coloured, but not C.
Which is actually surprising, because C lexer is included. Hmm, maybe something to do with mime types...
Ahh, you're right. I had never tried anything other than C code. I do see color for some CSS files I have checked in, which are shown in the interface as mime type text/css. The C code is shown as mime type text/plain.
Are you sure there is a "limited" number of lexers in fedora? pygmentize -L dumps quite a lot of lexers to me? Anyway, thanks for the mime_type hint... I've hacked this in temporarily for now to get color (this logic seems more sane to me, but i don't know the code at all): --- viewvc.py.orig 2009-07-30 22:11:36.000000000 -0400 +++ viewvc.py 2009-07-30 22:10:01.000000000 -0400 @@ -1363,10 +1363,10 @@ get_lexer_for_mimetype, \ get_lexer_for_filename try: - lexer = get_lexer_for_mimetype(mime_type) + lexer = get_lexer_for_filename(filename) except ClassNotFound: try: - lexer = get_lexer_for_filename(filename) + lexer = get_lexer_for_mimetype(mime_type) except ClassNotFound: use_pygments = 0 except ImportError:
> Are you sure there is a "limited" number of lexers in fedora? pygmentize -L dumps quite a lot of lexers to me? No, I thought something was missed, because I didn't see a C lexer there at first. It is in the compiled lexers collection. Red herring, sorry. Maybe we can do that path to try the lexer for mime_type first and if that's not found try for filename?
> Maybe we can do that path to try the lexer for mime_type first and if that's > not found try for filename? I think you may have misread the diff... that is exactly what the code does now. That's the problem though (at least I think), viewvc first decides, prior to these calls, that the mimetype for *.c files is text/plain, so calling get_lexer_for_mimetype() first chooses the pygments "text" lexer and goes on its merry way... which I guess is no color when it comes to highlighting, at least for C files. So I just swapped the calls, so that pygments figures it out by by filename itself. It does seems better to me to let pygments do the figuring out. Now, I don't really know going forward what the right thing to do would be. Ultimately anything that gets me color that "just works" out of the box would be the goal.
Ah, yeah. You are right, of course. Sorry :-(
Question: if you put mimetypes.conf from bug #514909 in /etc/viewvc, is this patch still required?
It depends. :) If you put the default mimetypes.conf in /etc/viewvc, you still need the patch, because the default conf file is empty and viewvc still "misrecognizes" .c files as the wrong mimetype... no highlighting. But if add the line: text/x-csrc c viewvc will then start highlighting .c files... without the patch. Personally, though, I don't particularly like that solution. While it would avoid patching the source, one would then presumably go through all the lexers and extensions supported by pygments, test to see if viewvc detects the mimetype "correctly", and if not, add the "correct" mimetype/extension to mimetypes.conf. That doesn't strike me as what a site-specific mimetypes.conf was made for. Plus, as pygments supports more lexers over time, you'd have to continually update this file to match.
I'd just like reiterate, that patch was just a quick hack to make highlighting work for me here right now... it might be worth seeing what upstream thinks?
Yeah, that sucks. They should just ship the file filled with whatever lexers support. Anyway, thanks for letting me know.
OK. Sorry, all this is taking so long. Don't have much time these days...
No worries. I'm in no rush. all the necessary info is here, so if people need to get it working they can help themselves. :)
viewvc-1.1.1-2.fc11 has been submitted as an update for Fedora 11. http://admin.fedoraproject.org/updates/viewvc-1.1.1-2.fc11
viewvc-1.1.1-2.fc11 has been pushed to the Fedora 11 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update viewvc'. You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-8481
viewvc-1.1.2-1.fc11 has been submitted as an update for Fedora 11. http://admin.fedoraproject.org/updates/viewvc-1.1.2-1.fc11
viewvc-1.1.2-2.fc11 has been pushed to the Fedora 11 stable repository. If problems still persist, please make note of it in this bug report.