]> granicus.if.org Git - python/commitdiff
Use new-style string formatting for the HTML template
authorRaymond Hettinger <python@rcn.com>
Tue, 3 Jul 2012 00:17:16 +0000 (17:17 -0700)
committerRaymond Hettinger <python@rcn.com>
Tue, 3 Jul 2012 00:17:16 +0000 (17:17 -0700)
Tools/scripts/pycolorize.py

index 3a9c95e275a83bf1845f82df9b805efdc5f7f2cf..7a177b925aa1b913036e98c504937bc94526209f 100755 (executable)
@@ -79,13 +79,13 @@ default_html = '''\
 <html>
 <head>
 <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
-<title> %s </title>
+<title> {title} </title>
 <style type="text/css">
-%s
+{css}
 </style>
 </head>
 <body>
-%s
+{body}
 </body>
 </html>
 '''
@@ -95,7 +95,7 @@ def build_page(source, title='python', css=default_css, html=default_html):
     css_str = '\n'.join(['%s %s' % item for item in css.items()])
     result = colorize(source)
     title = cgi.escape(title)
-    return html % (title, css_str, result)
+    return html.format(title=title, css=css_str, body=result)
 
 
 if __name__ == '__main__':