summaryrefslogtreecommitdiff
path: root/pygments/lexers/shell.py
diff options
context:
space:
mode:
authorJesse Tan <jessetan@users.noreply.github.com>2021-06-04 22:15:50 +0200
committerGitHub <noreply@github.com>2021-06-04 22:15:50 +0200
commitd228fc74c8ec6189202afd8c7ebfa9c8d12c9f5a (patch)
treefd3178d54757bb66329e0e531813644315fe6b8a /pygments/lexers/shell.py
parent3e9fe3a99ae3f4250e1d3788f5f3b4cc0c21e6ac (diff)
downloadpygments-git-d228fc74c8ec6189202afd8c7ebfa9c8d12c9f5a.tar.gz
Correctly highlight multiline console input, even without PS2 prompt (#1833)
Diffstat (limited to 'pygments/lexers/shell.py')
-rw-r--r--pygments/lexers/shell.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py
index 5539e812..099782a0 100644
--- a/pygments/lexers/shell.py
+++ b/pygments/lexers/shell.py
@@ -192,10 +192,13 @@ class ShellSessionBaseLexer(Lexer):
[(0, Generic.Prompt, m.group(1))]))
curcode += m.group(2)
backslash_continuation = curcode.endswith('\\\n')
- elif line.startswith(self._ps2) and backslash_continuation:
- insertions.append((len(curcode),
- [(0, Generic.Prompt, line[:len(self._ps2)])]))
- curcode += line[len(self._ps2):]
+ elif backslash_continuation:
+ if line.startswith(self._ps2):
+ insertions.append((len(curcode),
+ [(0, Generic.Prompt, line[:len(self._ps2)])]))
+ curcode += line[len(self._ps2):]
+ else:
+ curcode += line
backslash_continuation = curcode.endswith('\\\n')
else:
if insertions: