Hello all , I have just finished PySourceColor.py ver 1.9.6. I am near the end of this tool, and would appreciate a little bit of review. Please help me find the pesky little bugs that have escaped me. I had much difficulty getting linenumbers to work properly. If you see a simpler way to do linenumbers, by all means, please share.
Website: http://bellsouthpwp.net/m/e/mefjr75/ Here is the module docstring to start you off: """ ############################################################################# # PySourceColor.py ############################################################################# # A python source to colorized html/css/xhtml converter. # Hacked by M.E.Farmer Jr. 2004 # Python license ############################################################################# # Now supports two types of output markup: # - HTML markup does not create w3c valid html, but it works on every # browser i've tried so far. # (I.E.,Mozilla/Firefox,Opera,Konqueror,wxHTML). # - CSS markup is w3c validated html 4.01 strict, # but will not render correctly on all browsers. # - XHTML markup is w3c validated xhtml 1.0 strict, # like html 4.01, will not render correctly on all browsers. ############################################################################# # Features: # -Three types of markup: # html (default) # css/html 4.01 strict # xhtml 1.0 strict # # -Can tokenize and colorize: # 12 types of strings # 2 comment types # numbers # operators # brackets # math operators # class / name # def / name # decorator / name # keywords # arguments class/def/decorator # text # linenumbers # # -Eight colorschemes built-in: # null # mono # dark (default) # dark2 # lite # idle # viewcvs # pythonwin # # -Header and footer # set to '' for builtin header / footer # or give path to a file containing the html # you want added as header and footer # # -Linenumbers # Supports all styles. New token is called LINE. # Defaults to NAME if not defined # # Style options # -ALL markups support these text styles: # b = bold # i = italic # u = underline # -CSS and XHTML has limited support for borders: # HTML markup functions will ignore these. # Optional: Border color in RGB hex # Defaults to the text forecolor. # #rrggbb = border color # Optional: specify one type only # - = dashed # . = dotted # s = solid # d = double # g = groove # r = ridge # n = inset # o = outset # You can specify multiple sides, # they will all use the same style. # Optional: Default is full border. # v = bottom # < = left # > = right # ^ = top # NOTE: Specify the styles you want. # The markups will ignore unsupported styles # Also note not all browsers can show these options # # -All tokens default to NAME if not defined # so the only absolutely critical ones to define are: # NAME, ERRORTOKEN, PAGEBACKGROUND # ############################################################################# # Example usage: ############################################################################# # # import # import PySourceColor as psc # psc.convert('c:/Python22/PySourceColor.py', colors=psc.idle, show=1) #---------------------------------------------------------------------------- # # from module import * # from PySourceColor import * # convert('c:/Python22/Lib', colors=lite, markup="css", header='') #---------------------------------------------------------------------------- # # How to use a custom colorscheme, and most of the 'features' # # Warning this is an *ugly* colorscheme it is just an example # from PySourceColor import * # new = { # ERRORTOKEN: ('bui','#FF8080',''), # DECORATOR_NAME: ('s','#AACBBC',''), # DECORATOR: ('n','#333333',''), # NAME: ('t.<v','#1133AA','#DDFF22'), # NUMBER: ('','#236676','#FF5555'), # OPERATOR: ('b','#454567','#BBBB11'), # MATH_OPERATOR: ('','#935623','#423afb'), # BRACKETS: ('b','#ac34bf','#6457a5'), # COMMENT: ('t-#0022FF','#545366','#AABBFF'), # DOUBLECOMMENT: ('<l#553455','#553455','#FF00FF'), # CLASS_NAME: ('m^v-','#000000','#FFFFFF'), # DEF_NAME: ('l=<v','#897845','#000022'), # KEYWORD: ('.b','#345345','#FFFF22'), # SINGLEQUOTE: ('mn','#223344','#AADDCC'), # SINGLEQUOTE_R: ('','#344522',''), # SINGLEQUOTE_U: ('','#234234',''), # DOUBLEQUOTE: ('m#0022FF','#334421',''), # DOUBLEQUOTE_R: ('','#345345',''), # DOUBLEQUOTE_U: ('','#678673',''), # TRIPLESINGLEQUOTE: ('tv','#FFFFFF','#000000'), # TRIPLESINGLEQUOTE_R: ('tbu','#443256','#DDFFDA'), # TRIPLESINGLEQUOTE_U: ('','#423454','#DDFFDA'), # TRIPLEDOUBLEQUOTE: ('li#236fd3b<>','#000000','#FFFFFF'), # TRIPLEDOUBLEQUOTE_R: ('tub','#000000','#FFFFFF'), # TRIPLEDOUBLEQUOTE_U: ('-', '#CCAABB','#FFFAFF'), # LINE: ('ib-','#ff66aa','#7733FF'), # PAGEBACKGROUND: '#FFFAAA', # } # if __name__ == '__main__': # import sys # convert(sys.argv[1], './css.html',colors=new, # markup='css', show=1, linenumbers=1) # convert(sys.argv[1], './html.html',colors=new, # markup='html', show=1, linenumbers=1) ############################################################################# """ More details in the code. And for all the commandline junkies there is a commandline interface that covers every option. website: http://bellsouthpwp.net/m/e/mefjr75/ thank you for your time, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list