diff options
Diffstat (limited to 'pygments')
-rw-r--r-- | pygments/lexers/functional.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py index 889e82a2..000be337 100644 --- a/pygments/lexers/functional.py +++ b/pygments/lexers/functional.py @@ -3407,22 +3407,25 @@ class ElixirConsoleLexer(Lexer): aliases = ['iex'] mimetypes = ['text/x-elixir-shellsession'] - _prompt_re = re.compile('(iex|\.{3})> ') + _prompt_re = re.compile('(iex|\.{3})(\(\d+\))?> ') def get_tokens_unprocessed(self, text): exlexer = ElixirLexer(**self.options) curcode = '' + in_error = False insertions = [] for match in line_re.finditer(text): line = match.group() if line.startswith(u'** '): + in_error = True insertions.append((len(curcode), [(0, Generic.Error, line[:-1])])) curcode += line[-1:] else: m = self._prompt_re.match(line) if m is not None: + in_error = False end = m.end() insertions.append((len(curcode), [(0, Generic.Prompt, line[:end])])) @@ -3430,14 +3433,15 @@ class ElixirConsoleLexer(Lexer): else: if curcode: for item in do_insertions(insertions, - exlexer.get_tokens_unprocessed(curcode)): + exlexer.get_tokens_unprocessed(curcode)): yield item curcode = '' insertions = [] - yield match.start(), Generic.Output, line + token = Generic.Error if in_error else Generic.Output + yield match.start(), token, line if curcode: for item in do_insertions(insertions, - exlexer.get_tokens_unprocessed(curcode)): + exlexer.get_tokens_unprocessed(curcode)): yield item |