Mimeview and troff

0 views
Skip to first unread message

Tim Hatch

unread,
Dec 12, 2006, 12:06:02 AM12/12/06
to Trac Development
I'm still a bit shaky on exactly what to call these files, but I've
gathered the roff, troff, groff, and nroff all pretty much refer to the
same format (listed as application/x-troff in Trac). These include
manpage source, of which one file exists in the Trac source tree.

Its extension is not matched by the current trac/mimeview/api.py
(either of the two identical lines, hrmm), but extensions are specified
in the Pygments lexer for it (since
http://trac.pocoo.org/changeset/2424). Do you think it is feasible for
the renderer's lexers' extensions (which are admittedly in fnmatch
style) from Pygments to be overlaid to KNOWN_MIME_TYPES (or otherwise
made available to get_mimetype) at runtime?

I've patched get_mimetype to do this[1], but I'm slightly wary of
putting code to call Pygments in the core, even wrapped with a
try/catch block[2]. Opinions?

Tim

[1]: the fun part is...
from pygments import get_lexer_for_filename
mimetype = get_lexer_for_filename(filename).mimetypes[0]

[2]: if it finds the mimetype is not already in the mapping, it
probably needs to make sure something will be findable to render it
too, making this kind of messy for new mimetypes. Luckily this
particular one already exists.

Christian Boos

unread,
Dec 13, 2006, 2:40:45 AM12/13/06
to trac...@googlegroups.com
Tim Hatch wrote:
> ...

>
> I've patched get_mimetype to do this[1], but I'm slightly wary of
> putting code to call Pygments in the core, even wrapped with a
> try/catch block[2]. Opinions?
>

We need a IMimeTypeDetector interface/extension point for this.
... and we'd need the #3332 changes before that, I think, as there I've
refactored the mime detection code and put place holders for
IMimeTypeDetector and ICharsetDetector extension points, without
actually implementing those as I didn't want to overload the patch which
was already quite big...

I think it would be worth creating a branch for that, where we could
finish the work together.
Would you be interested?

Are the other committers OK for Tim getting a commit access?

-- Christian

Emmanuel Blot

unread,
Dec 13, 2006, 5:28:21 AM12/13/06
to trac...@googlegroups.com
> Are the other committers OK for Tim getting a commit access?
+1

--
Manu

Tim Hatch

unread,
Dec 13, 2006, 11:58:38 AM12/13/06
to Trac Development
> I think it would be worth creating a branch for that, where we could
> finish the work together.
> Would you be interested?

Yes, certainly.

Tim

Jonas Borgström

unread,
Dec 14, 2006, 1:21:50 PM12/14/06
to trac...@googlegroups.com
Christian Boos wrote:
>
> Are the other committers OK for Tim getting a commit access?

+1. I'll set it up.

Cheers,
Jonas

Reply all
Reply to author
Forward
0 new messages