diff options
author | Matthäus G. Chajdas <dev@anteru.net> | 2022-12-11 15:30:01 +0100 |
---|---|---|
committer | Matthäus G. Chajdas <dev@anteru.net> | 2022-12-11 15:30:01 +0100 |
commit | 6765ec070fd73ba7bfa5ea464d4e720e61599f3a (patch) | |
tree | d9d06d83434b56b761282ec4d92a68029c313d02 /pygments/formatters | |
parent | ba3a996637b87f22994da354f988a55ac88c7e6e (diff) | |
download | pygments-git-6765ec070fd73ba7bfa5ea464d4e720e61599f3a.tar.gz |
Simplify the condition.
Diffstat (limited to 'pygments/formatters')
-rw-r--r-- | pygments/formatters/html.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index d9e68a99..ee53f132 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -878,14 +878,12 @@ class HtmlFormatter(Formatter): # for all but the last line for part in parts[:-1]: if line: - if lspan != cspan: - # 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 + # Also check for part being non-empty, so we avoid creating + # empty <span> tags + if lspan != cspan and part: + line.extend(((lspan and '</span>'), cspan, part, + (cspan and '</span>'), lsep)) + else: # both are the same, or the current part was empty line.extend((part, (lspan and '</span>'), lsep)) yield 1, ''.join(line) line = [] |