From: Fred L. D. <fd...@us...> - 2002-03-26 05:18:18
|
Update of /cvsroot/ht2html/ht2html In directory usw-pr-cvs1:/tmp/cvs-serv27851 Modified Files: Skeleton.py Log Message: Change some of the mechanics of how style information is added to the page, allowing use of both inline style information and an external stylesheet. Index: Skeleton.py =================================================================== RCS file: /cvsroot/ht2html/ht2html/Skeleton.py,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -d -r2.2 -r2.3 *** Skeleton.py 26 Mar 2002 04:25:36 -0000 2.2 --- Skeleton.py 26 Mar 2002 05:18:15 -0000 2.3 *************** *** 127,131 **** def get_banner_attributes(self): """Return extra attributes for the TABLE in the banner.""" ! return 'CELLSPACING=0 CELLPADDING=2' def get_charset(self): --- 127,131 ---- def get_banner_attributes(self): """Return extra attributes for the TABLE in the banner.""" ! return 'CELLSPACING="0" CELLPADDING="2"' def get_charset(self): *************** *** 134,137 **** --- 134,141 ---- # Style sheets + def get_stylesheet(self): + """Return filename of CSS stylesheet.""" + return None + def get_style(self): """Return the style sheet for this document""" *************** *** 250,256 **** <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=%(charset)s"> %(meta)s - <style type="text/css"> %(style)s - </style> </HEAD>''' % {'title' : self.get_title(), 'headers': self.get_headers(), --- 254,258 ---- *************** *** 259,264 **** 'version': __version__, 'charset': self.get_charset(), ! 'style' : self.get_style() } def __start_body(self): --- 261,289 ---- 'version': __version__, 'charset': self.get_charset(), ! 'style' : self.__do_styles() } + + def __do_styles(self): + # assemble all the style information we have to produce the + # appropriate LINK and STYLE elements + stylesheet = self.get_stylesheet() + localstyle = self.get_style() + s = '' + if stylesheet and stylesheet.strip(): + s = '<LINK REL="STYLESHEET" HREF="%s" TYPE="text/css">' \ + % stylesheet.strip() + if localstyle and localstyle.strip(): + localstyle = localstyle.strip() + if not localstyle.startswith("<!--"): + # XXX should check the HTML version we're trying to produce + fmt = '<STYLE TYPE="text/css">\n<!--\n%s\n-->\n</STYLE>' + else: + fmt = '<STYLE TYPE="text/css">\n%s\n</STYLE>' + localstyle = fmt % localstyle + if stylesheet: + s = s + "\n" + localstyle + else: + s = localstyle + return s def __start_body(self): |