Commits

Konstantin Lopuhin committed d80bca3 Draft

change format, add info on the right

Comments (0)

Files changed (1)

pygments/formatters/html.py

                 pass
 
         self.heatmap = {}
-        for i, percent in enumerate(get_list_opt(options, 'heatmap', [])):
-            try:
-                self.heatmap[i] = float(percent) 
-            except ValueError:
-                pass
+        heatmap_list = get_list_opt(options, 'heatmap', [])
+        if heatmap_list:
+            base = heatmap_list[0]
+            for s in heatmap_list[1:]:
+                if ':' in s:
+                    lineno, percent = s.split(':')
+                    try:
+                        self.heatmap[int(lineno) - int(base)] = float(percent) 
+                    except ValueError:
+                        pass
 
         self._create_stylesheet()
 
                 yield t, value
             if i in self.heatmap:
                 percent = self.heatmap[i]
-                ratio = self.heatmap[i] / 100.0
+                ratio = percent / 100.0
                 r = 255
                 g = b = (1 - ratio) * 255
                 full_width = 'display:block; width:100%;'
                 style = ' style="%s background-color: #%x%x%x"' % (
                         full_width, r, g, b)
-                title = ' title="%s %%" ' % percent
-                yield 1, '<span%s%s>%s</span>' % (title, style, value)
+                info = '<span style="float:right;">%.2f %%</span>' % percent
+                yield 1, '<span%s>%s%s</span>' % (style, info, value)
             else:
                 yield 1, value