By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,172 Members | 727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,172 IT Pros & Developers. It's quick & easy.

Python2Html regex question

P: n/a
Hello

I've been using the Html Formatter at
http://www.manoli.net/csharpformat to format c# code (paste your code
into the box, click the button and get html/css). Is there anything
similar for Python code, does anyone know?

Either way, the (c#) source is available for the above formatter and it
looks like it would be straightforward to create a Python formatter by
extending a base class and providing the following three things:

1) a list of python keywords
2) a regex to match python comments
3) a regex to match python strings

Even my limited talents can handle the first, can anyone help me with
2) and 3)?

C# uses '@' where Python uses 'r' as a 'raw-input' prefix for regex's,
but I'm assuming the expressions themselves are the same in both
languages?

Thanks in advance.

Aug 30 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
[Gerard Flanagan wrote]
I've been using the Html Formatter at
http://www.manoli.net/csharpformat to format c# code (paste your code
into the box, click the button and get html/css). Is there anything
similar for Python code, does anyone know?


Checkout SilverCity:
http://silvercity.sourceforge.net/

As a CGI script:
http://www.sweetapp.com/cgi-bin/cgi-styler-form.py

Cheers,
Trent

--
Trent Mick
Tr****@ActiveState.com
Aug 30 '05 #2

P: n/a
Perfect.

Thanks Trent.

Gerard

Aug 30 '05 #3

P: n/a
Gerard Flanagan wrote:
Either way, the (c#) source is available for the above formatter and it
looks like it would be straightforward to create a Python formatter by
extending a base class and providing the following three things:

1) a list of python keywords
import keyword
print keyword.kwlist
2) a regex to match python comments
import tokenize
print tokenize.Comment
3) a regex to match python strings


import tokenize
print tokenize.String
print tokenize.Triple

</F>

Aug 30 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.