diff options
Diffstat (limited to 'pygments/formatters/html.py')
-rw-r--r-- | pygments/formatters/html.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index 791f749a..d9e68a99 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -879,8 +879,12 @@ class HtmlFormatter(Formatter): for part in parts[:-1]: if line: if lspan != cspan: - line.extend(((lspan and '</span>'), cspan, part, - (cspan and '</span>'), lsep)) + # If part is empty (i.e. it was a newline), just close + if part: + line.extend(((lspan and '</span>'), cspan, part, + (cspan and '</span>'), lsep)) + else: + line.extend(((lspan and '</span>'), lsep)) else: # both are the same line.extend((part, (lspan and '</span>'), lsep)) yield 1, ''.join(line) |