Commits

Anonymous committed 29728c6

Fix #287 and add a note about how to circumvent the line number line height
problem in IE.

  • Participants
  • Parent commits fd4e3f8
  • Branches trunk

Comments (0)

Files changed (1)

pygments/formatters/html.py

     while fname is None:
         aname = '-' + ttype[-1] + aname
         ttype = ttype.parent
-        fname = STANDARD_TYPES.get(ttype, '')
+        fname = STANDARD_TYPES.get(ttype)
     return fname + aname
 
 
+CSSFILE_TEMPLATE = '''\
+td.linenos { background-color: #f0f0f0; padding-right: 10px; }
+span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
+pre { line-height: 125%; }
+%(styledefs)s
+'''
+
 DOC_HEADER = '''\
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
   <title>%(title)s</title>
   <meta http-equiv="content-type" content="text/html; charset=%(encoding)s">
   <style type="text/css">
-td.linenos { background-color: #f0f0f0; padding-right: 10px; }
-span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
-%(styledefs)s
+''' + CSSFILE_TEMPLATE + '''
   </style>
 </head>
 <body>
 
 '''
 
-
 DOC_HEADER_EXTERNALCSS = '''\
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
 '''
 
 
-CSSFILE_TEMPLATE = '''\
-td.linenos { background-color: #f0f0f0; padding-right: 10px; }
-%(styledefs)s
-'''
-
-
 class HtmlFormatter(Formatter):
     r"""
     Format tokens as HTML 4 ``<span>`` tags within a ``<pre>`` tag, wrapped
 
         The default value is ``False``, which means no line numbers at all.
 
+        **Note:** with the default ("table") line number mechanism, the line
+        numbers and code will have different line heights in Internet Explorer
+        unless you give the enclosing ``<pre>`` tags an explicit ``line-height``
+        CSS property (you get the default line spacing with ``line-height:
+        125%``).
+
     `linenostart`
         The line number for the first line (default: ``1``).
 
                   if cls and style]
         styles.sort()
         lines = ['%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:])
-                 for level, ttype, cls, style in styles]
+                 for (level, ttype, cls, style) in styles]
         if arg and not self.nobackground and \
            self.style.background_color is not None:
             text_style = ''