[Trac] Creating a mimeviewer for php files
Clay Loveless
clay at killersoft.com
Wed Apr 6 13:03:08 EDT 2005
On 4/6/05 9:27 AM Pacific Time, Christian Boos (cboos at bct-technology.com)
wrote:
> The trick is to change the __init__.py file in the mimeviewers folder so
> that the php.py mime
> processor can be loaded.
>
> Anyway, that's now part of the trunk [1500].
> It works for me on Linux, but I suspect that it won't be the case on Windows
> (I don't have php on Windows).
Yeah, I tried playing around with __init__.py I'm running on Debian Linux,
and wasn't able to get the php.py file working. I think that's because of
the SilverCity issue ... Even when I put 'php' before 'silvercity' in
__init__.py, I still wind up with nothing. I even did a version with
'silvercity' removed entirely from __init__.py, and that didn't help either.
For the record, I did perform a 'python setup.py install' after each change
to the files in the mimeviewers directory. : )
>> The php.py file from ticket 984 seems to include code from the enscript.py
>> mimeviewer ... That seems like it shouldn't really be necessary, since "php
>> -s" puts out marked-up source by itself.
>>
>>
> The original patch used the 'Deuglifier' class, to replace font element
> with given color
> by span elements of the appropriate class. The color codes needed to be
> adapted
> for PHP. I'll put basic support for adaptation in place, but as I know
> nothing about PHP's
> syntax (<?flamewar echo "except it's ugly" :) ?>), it could need further
> adaptation.
Ah ... Well, if 'php -s' is a PHP5 executable, there's no need for that
munging, as syntax coloring in PHP5 is done with <span> tags instead of
<font> tags.
The point of doing this via php -s is that the highlighter doesn't need to
have any knowledge of PHP syntax. There are only 5 or so highlight colors
used by PHP's highlighter, so replacing those five specific font tags (from
PHP 4 output) should be all the knowledge needed.
There are a few 'xhtml_highlight' functions with string replacements to
convert PHP 4 highlight output to XHTML-friendly output here:
http://www.php.net/manual/en/function.highlight-string.php
I appreciate your efforts, Christian -- hope to be able to get something
working here. (Any idea how to remove the SilverCity installation? Pulling
the SilverCity directory out of my site-packages directory didn't do the
trick, I don't think.)
Thanks,
Clay
--
Killersoft.com
More information about the Trac
mailing list