diff options
author | Matth?us G. Chajdas <dev@anteru.net> | 2019-05-18 14:48:13 +0200 |
---|---|---|
committer | Matth?us G. Chajdas <dev@anteru.net> | 2019-05-18 14:48:13 +0200 |
commit | 52dd1cba99c9f4f3495ee1e9b93ee615b80ba880 (patch) | |
tree | 30190d633d594db970db477f0901352140e58564 | |
parent | cbb7c47271c2a93f1a7e9c94d769ad060d4fcb73 (diff) | |
download | pygments-52dd1cba99c9f4f3495ee1e9b93ee615b80ba880.tar.gz |
Don't emit a trailing newline in nowrap mode (fixes #1514.)
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | pygments/formatters/html.py | 8 |
2 files changed, 9 insertions, 1 deletions
@@ -19,6 +19,8 @@ Version 2.4.1 - Support CSS variables in stylesheets (PR#814) - Fix F# lexer name (PR#709) - Fix ``TerminalFormatter`` using bold for bright text (#1480) +- Don't emit a trailing newline in the HtmlFormatter when ``nowrap`` is set + (#1514) Version 2.4.0 ------------- diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index d65c09ce..54e7df0e 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -803,7 +803,13 @@ class HtmlFormatter(Formatter): # else we neither have to open a new span nor set lspan if line: - line.extend(((lspan and '</span>'), lsep)) + # If we're in nowrap mode, we try to make the output compact and + # omit the trailing newspace, this makes it easier to consume the + # HTML elsewhere + if self.nowrap: + line.append(lspan and '</span>') + else: + line.extend((lspan and '</span>', lsep)) yield 1, ''.join(line) def _lookup_ctag(self, token): |