diff --git a/IPython/nbconvert/utils/lexers.py b/IPython/nbconvert/utils/lexers.py index e8e9290..9506d0a 100644 --- a/IPython/nbconvert/utils/lexers.py +++ b/IPython/nbconvert/utils/lexers.py @@ -53,11 +53,8 @@ ipython_tokens = [ (r'(%)(sx|sc|system)(.*)(\n)', bygroups(Operator, Keyword, using(BashLexer), Text)), (r'(%)(\w+)(.*\n)', bygroups(Operator, Keyword, Text)), - (r'^(!)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)), - (r'^(.+)(=)(\s*)(!)(.+)(\n)', bygroups( - # With the limited syntax allowed on the l.h.s. of a shell capture, - # we don't need to differentiate between Python 2 and 3. - using(Python3Lexer), Operator, Text, Operator, using(BashLexer), Text)), + (r'^(!!)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)), + (r'(!)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)), ] def build_ipy_lexer(python3): diff --git a/IPython/nbconvert/utils/tests/test_lexers.py b/IPython/nbconvert/utils/tests/test_lexers.py index 2cbc1cc..fa615a9 100644 --- a/IPython/nbconvert/utils/tests/test_lexers.py +++ b/IPython/nbconvert/utils/tests/test_lexers.py @@ -34,6 +34,12 @@ class TestLexers(TestsBase): ] self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + fragment_2 = '!' + fragment + tokens_2 = [ + (Token.Operator, '!!'), + ] + tokens[1:] + self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2))) + fragment_2 = 'x = ' + fragment tokens_2 = [ (Token.Name, 'x'),