summaryrefslogtreecommitdiff
path: root/pygments/lexers/functional.py
diff options
context:
space:
mode:
authorAlexei Sholik <alcosholik@gmail.com>2014-06-05 19:30:06 +0300
committerAlexei Sholik <alcosholik@gmail.com>2014-06-05 19:30:06 +0300
commit1eab0e634018f922599e76a636719995fefd48cf (patch)
tree6038212dc7152023af434b704e02e8fa55d7c839 /pygments/lexers/functional.py
parente471b92d4f147f31849b6deb7d925dd7b37890b5 (diff)
downloadpygments-1eab0e634018f922599e76a636719995fefd48cf.tar.gz
Update ElixirConsoleLexer and add example file
Diffstat (limited to 'pygments/lexers/functional.py')
-rw-r--r--pygments/lexers/functional.py12
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