diff options
author | Jesse Tan <jessetan@users.noreply.github.com> | 2021-06-04 22:15:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-04 22:15:50 +0200 |
commit | d228fc74c8ec6189202afd8c7ebfa9c8d12c9f5a (patch) | |
tree | fd3178d54757bb66329e0e531813644315fe6b8a /pygments/lexers/shell.py | |
parent | 3e9fe3a99ae3f4250e1d3788f5f3b4cc0c21e6ac (diff) | |
download | pygments-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.py | 11 |
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: |