pygments using

9 views
Skip to first unread message

Link

unread,
Nov 19, 2008, 10:12:28 PM11/19/08
to Trac Users
Hi, I have a problem of using pygments to make syntax highlight in
trac.
I am using trac 0.11.2.1, pygments 0.11.1
I install pygments this way:
---------------------------------------------------------------------------------------------------------------------------------
tar zxvf Pygments-0.11.1.tar.gz.gz
cd Pygments-0.11.1
python setup.py build
python setup.py install
---------------------------------------------------------------------------------------------------------------------------------

And I make a global configuration of trac to use pygments, here is
some sections of my trac.ini file in my project trac sub directory:

-------------------------------------------------------------------------------------------------------------------------------
[inherit]
file = /usr/local/share/trac/conf/trac.ini
plugins_dir = /usr/local/share/trac/plugins
templates_dir = /usr/local/share/trac/templates

[mimeviewer]
enscript_modes = text/x-dylan:dylan:4
enscript_path = enscript
max_preview_size = 262144
mime_map = text/x-dylan:dylan,text/x-idl:ice,text/x-ada:ads:adb, text/
x-java:java, text/x-chdr:h, text/x-csrc:c, text/x-c++hdrh:h, text/x-c+
+src:cpp, text/x-csharp:cs, text/x-python:py
php_path = php
silvercity_modes =
pygments_default_type = trac
pygments_modes = text/x-java:java:7, text/x-chdr:h:7, text/x-csrc:c:7,
text/x-c++hdrh:h:7, text/x-c++src:cpp:7, text/x-csharp:cs:7, text/x-
python:py:7
tab_width = 8
----------------------------------------------------------------------------------------------------------------------------------

and in the file /usr/local/share/trac/conf/trac.ini, I add components
section like this:

----------------------------------------------------------------------------------------------------------------------------------
[components]
tracpygments.* = enabled
----------------------------------------------------------------------------------------------------------------------------------

I restart apache server, and browse source in trac, but here is no
syntax colour at all. On top of the source code trac show, there is a
message like this:

--------------------------------------------------------------------------------------------------------------------------
Revision 2, 10.2 KB (checked in by user, ** hours ago)

* Property svn:mime-type set to text/plain
---------------------------------------------------------------------------------------------------------------------------


I use Eclipse as my IDE and Subversion to add source code to the svn
server. It seems that Subversion plugin of Eclipse had set the
snv:mime-type ??

Any one could give me some help of this problem? Thank you.

Link

unread,
Nov 20, 2008, 9:47:44 PM11/20/08
to Trac Users
Answer my own question:
Since I'm sure that the pygments components is installed corrected --
for I can see it in the Admin page's plugin section.
And as I note, every Java source code file has a message on top of the
source view page.


--------------------------------------------------------------------------------------------------------------------------
Revision 2, 10.2 KB (checked in by user, ** hours ago)

* Property svn:mime-type set to text/plain
---------------------------------------------------------------------------------------------------------------------------

I try to update configuration in trac.ini file:
-------------------------------------------------------------------------------------------------------------------------
pygments_modes = text/x-java:java:7, text/x-chdr:h:7, text/x-csrc:c:7,
text/x-c++hdrh:h:7, text/x-c++src:cpp:7, text/x-csharp:cs:7, text/x-
python:py:7
---------------------------------------------------------------------------------------------------------------------------
change "text/x-java:java:7" to "text/plain:java:7", this told pygments
to render text/plain file using java render.
And I got the syntax highlight in the source view page.

I use Eclipse as my IDE and Subversion to add source code to the svn
server. It seems that Subversion plugin of Eclipse had set the
snv:mime-type ?? Or do anyone know how to set the svn:mime-type
property as I need?

eldo...@gmail.com

unread,
Dec 11, 2008, 8:19:59 AM12/11/08
to Trac Users


On 21 нояб, 04:47, Link <bmlin...@gmail.com> wrote:
> Answer my own question:
> Since I'm sure that thepygmentscomponents is installed corrected --
Hi, had the same problem
But i found decision.
In Eclipse go to the Window->Prefences->Team->SVN -> Properties
configuration
and change the following settings:
File name template: *.java

svn:mime-type=text/x-java

In this part you can add any svn options for the specific file types.
This is works for me.
(But it's work only when file is added)
P.S. Sorry for my bad english
Reply all
Reply to author
Forward
0 new messages