diff options
-rw-r--r-- | pygments/formatters/html.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index 368d65a2..d87349f7 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -389,7 +389,8 @@ class HtmlFormatter(Formatter): for part in parts[:-1]: if line: if lspan != cspan: - line += '</span>' + cspan + part + (cspan and '</span>') + '\n' + line += (lspan and '</span>') + cspan + part + \ + (cspan and '</span>') + '\n' else: # both are the same line += part + (lspan and '</span>') + '\n' yield 1, line @@ -399,12 +400,13 @@ class HtmlFormatter(Formatter): # for the last line if line: if lspan != cspan: - line += '</span>' + cspan + parts[-1] + line += (lspan and '</span>') + cspan + parts[-1] lspan = cspan else: line += parts[-1] else: line = cspan + parts[-1] + lspan = cspan if line: yield 1, line + (lspan and '</span>') + '\n' |