From f536475f6fa1ae15b59de8cbef53944d905d79e6 2013-12-16 23:25:24
From: chebee7i <chebee7i@gmail.com>
Date: 2013-12-16 23:25:24
Subject: [PATCH] Clean up aliases for lexers.

---

diff --git a/IPython/nbconvert/utils/lexers.py b/IPython/nbconvert/utils/lexers.py
index 2ab470b..8967d2f 100644
--- a/IPython/nbconvert/utils/lexers.py
+++ b/IPython/nbconvert/utils/lexers.py
@@ -83,7 +83,7 @@ def build_ipy_lexer(python3):
         PyLexer = PythonLexer
         clsname = 'IPythonLexer'
         name = 'IPython'
-        aliases = ['ipython']
+        aliases = ['ipython2', 'ipython']
         doc = """IPython Lexer"""
 
     tokens = PyLexer.tokens.copy()
@@ -169,6 +169,10 @@ class IPythonTracebackLexer(DelegatingLexer):
 
     def __init__(self, **options):
         self.python3 = get_bool_opt(options, 'python3', False)
+        if self.python3:
+            self.aliases = ['ipythontb3']
+        else:
+            self.aliases = ['ipythontb2', 'ipythontb']
 
         if self.python3:
             IPyLexer = IPython3Lexer
@@ -255,6 +259,10 @@ class IPythonConsoleLexer(Lexer):
 
         """
         self.python3 = get_bool_opt(options, 'python3', False)
+        if self.python3:
+            self.aliases = ['ipythoncon3']
+        else:
+            self.aliases = ['ipythoncon2', 'ipythoncon']
 
         in1_regex = options.get('in1_regex', self.in1_regex)
         in2_regex = options.get('in2_regex', self.in2_regex)
@@ -479,6 +487,11 @@ class IPyLexer(Lexer):
 
     def __init__(self, **options):
         self.python3 = get_bool_opt(options, 'python3', False)
+        if self.python3:
+            self.aliases = ['ipy3']
+        else:
+            self.aliases = ['ipy2', 'ipy']
+
         Lexer.__init__(self, **options)
 
         self.IPythonLexer = IPythonLexer(**options)
diff --git a/IPython/sphinxext/ipython_console_highlighting.py b/IPython/sphinxext/ipython_console_highlighting.py
index 9bfd378..c385fb6 100644
--- a/IPython/sphinxext/ipython_console_highlighting.py
+++ b/IPython/sphinxext/ipython_console_highlighting.py
@@ -19,9 +19,9 @@ def setup(app):
 # Alternatively, we could register the lexer with pygments instead. This would
 # require using setuptools entrypoints: http://pygments.org/docs/plugins
 
-ipy = IPyLexer(python3=False)
+ipy2 = IPyLexer(python3=False)
 ipy3 = IPyLexer(python3=True)
-ipy3.aliases = ['ipy3']
 
-highlighting.lexers['ipython'] = ipy
+highlighting.lexers['ipython'] = ipy2
+highlighting.lexers['ipython2'] = ipy2
 highlighting.lexers['ipython3'] = ipy3