diff options
author | Georg Brandl <georg@python.org> | 2016-02-02 12:53:04 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2016-02-02 12:53:04 +0100 |
commit | 1796e45b8a13444664389e3fe86aab520b4ebecf (patch) | |
tree | b34ebaafb9f229e94798fb6a733823a50bcb2284 | |
parent | 37d2f0ab87220f2e15b9553501721e21e5356fe1 (diff) | |
download | pygments-1796e45b8a13444664389e3fe86aab520b4ebecf.tar.gz |
Fixed HTML formatter output with leading empty lines (closes #1111)
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | pygments/formatters/html.py | 4 |
2 files changed, 4 insertions, 1 deletions
@@ -12,6 +12,7 @@ Version 2.1.1 (in development) - Fixed Jython compatibility (#1205) +- Fixed HTML formatter output with leading empty lines (#1111) - Fixed image formatter font searching on Macs (#1188) - Fixed Python curly-brace string interpolation highlighting (PR#544) - Fixed Julia string interpolation (#1170) diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index a0087515..2c6bb19e 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -702,7 +702,9 @@ class HtmlFormatter(Formatter): if self.filename: yield 0, ('<span class="filename">' + self.filename + '</span>') - yield 0, ('<pre' + (style and ' style="%s"' % style) + '>') + # the empty span here is to keep leading empty lines from being + # ignored by HTML parsers + yield 0, ('<pre' + (style and ' style="%s"' % style) + '><span></span>') for tup in inner: yield tup yield 0, '</pre>' |