class_docstr: An IPython console lexer for IPython code-blocks and doctests, such as:
  
  .. code-block:: rst
  
      .. code-block:: ipythonconsole
  
          In [1]: a = 'foo'
  
          In [2]: a
          Out[2]: 'foo'
  
          In [3]: print(a)
          foo
  
  
  Support is also provided for IPython exceptions:
  
  .. code-block:: rst
  
      .. code-block:: ipythonconsole
  
          In [1]: raise Exception
          Traceback (most recent call last):
          ...
          Exception
docstr: Parses the line and returns a 3-tuple: (mode, code, insertion).
  
  `mode` is the next mode (or state) of the lexer, and is always equal
  to 'input', 'output', or 'tb'.
  
  `code` is a portion of the line that should be added to the buffer
  corresponding to the next mode and eventually lexed by another lexer.
  For example, `code` could be Python code if `mode` were 'input'.
  
  `insertion` is a 3-tuple (index, token, text) representing an
  unprocessed "token" that will be inserted into the stream of tokens
  that are created from the buffer once we change modes. This is usually
  the input or output prompt.
  
  In general, the next mode depends on current mode and on the contents
  of `line`.
docstr_tok: ["Parses","the","line","and","returns","a","3-tuple",":","(","mode",",","code",",","insertion",")",".","`","mode","`","is","the","next","mode","(","or","state",")","of","the","lexer",",","and","is","always","equal","to","'input","'",",","'output","'",",","or","'tb","'",".","`","code","`","is","a","portion","of","the","line","that","should","be","added","to","the","buffer","corresponding","to","the","next","mode","and","eventually","lexed","by","another","lexer",".","For","example",",","`","code","`","could","be","Python","code","if","`","mode","`","were","'input","'",".","`","insertion","`","is","a","3-tuple","(","index",",","token",",","text",")","representing","an","unprocessed","``","token","''","that","will","be","inserted","into","the","stream","of","tokens","that","are","created","from","the","buffer","once","we","change","modes",".","This","is","usually","the","input","or","output","prompt",".","In","general",",","the","next","mode","depends","on","current","mode","and","on","the","contents","of","`","line","`","."]
code: def get_mci(self, line):
      """
      Parses the line and returns a 3-tuple: (mode, code, insertion).
  
      `mode` is the next mode (or state) of the lexer, and is always equal
      to 'input', 'output', or 'tb'.
  
      `code` is a portion of the line that should be added to the buffer
      corresponding to the next mode and eventually lexed by another lexer.
      For example, `code` could be Python code if `mode` were 'input'.
  
      `insertion` is a 3-tuple (index, token, text) representing an
      unprocessed "token" that will be inserted into the stream of tokens
      that are created from the buffer once we change modes. This is usually
      the input or output prompt.
  
      In general, the next mode depends on current mode and on the contents
      of `line`.
  
      """
      # To reduce the number of regex match checks, we have multiple
      # 'if' blocks instead of 'if-elif' blocks.
  
      # Check for possible end of input
      in2_match = self.in2_regex.match(line)
      in2_match_rstrip = self.in2_regex_rstrip.match(line)
      if (
          in2_match and in2_match.group().rstrip() == line.rstrip()
      ) or in2_match_rstrip:
          end_input = True
      else:
          end_input = False
      if end_input and self.mode != "tb":
          # Only look for an end of input when not in tb mode.
          # An ellipsis could appear within the traceback.
          mode = "output"
          code = ""
          insertion = (0, Generic.Prompt, line)
          return mode, code, insertion
  
      # Check for output prompt
      out_match = self.out_regex.match(line)
      out_match_rstrip = self.out_regex_rstrip.match(line)
      if out_match or out_match_rstrip:
          mode = "output"
          if out_match:
              idx = out_match.end()
          else:
              idx = out_match_rstrip.end()
          code = line[idx:]
          # Use the 'heading' token for output.  We cannot use Generic.Error
          # since it would conflict with exceptions.
          insertion = (0, Generic.Heading, line[:idx])
          return mode, code, insertion
  
      # Check for input or continuation prompt (non stripped version)
      in1_match = self.in1_regex.match(line)
      if in1_match or (in2_match and self.mode != "tb"):
          # New input or when not in tb, continued input.
          # We do not check for continued input when in tb since it is
          # allowable to replace a long stack with an ellipsis.
          mode = "input"
          if in1_match:
              idx = in1_match.end()
          else:  # in2_match
              idx = in2_match.end()
          code = line[idx:]
          insertion = (0, Generic.Prompt, line[:idx])
          return mode, code, insertion
  
      # Check for input or continuation prompt (stripped version)
      in1_match_rstrip = self.in1_regex_rstrip.match(line)
      if in1_match_rstrip or (in2_match_rstrip and self.mode != "tb"):
          # New input or when not in tb, continued input.
          # We do not check for continued input when in tb since it is
          # allowable to replace a long stack with an ellipsis.
          mode = "input"
          if in1_match_rstrip:
              idx = in1_match_rstrip.end()
          else:  # in2_match
              idx = in2_match_rstrip.end()
          code = line[idx:]
          insertion = (0, Generic.Prompt, line[:idx])
          return mode, code, insertion
  
      # Check for traceback
      if self.ipytb_start.match(line):
          mode = "tb"
          code = line
          insertion = None
          return mode, code, insertion
  
      # All other stuff...
      if self.mode in ("input", "output"):
          # We assume all other text is output. Multiline input that
          # does not use the continuation marker cannot be detected.
          # For example, the 3 in the following is clearly output:
          #
          #    In [1]: print 3
          #    3
          #
          # But the following second line is part of the input:
          #
          #    In [2]: while True:
          #        print True
          #
          # In both cases, the 2nd line will be 'output'.
          #
          mode = "output"
      else:
          mode = "tb"
  
      code = line
      insertion = None
  
      return mode, code, insertion
  
imports: import re
  from pygments.lexers import BashLexer, HtmlLexer, JavascriptLexer, RubyLexer, PerlLexer, PythonLexer, Python3Lexer, TexLexer
  from pygments.lexer import Lexer, DelegatingLexer, RegexLexer, do_insertions, bygroups, using
  from pygments.token import Generic, Keyword, Literal, Name, Operator, Other, Text, Error
  from pygments.util import get_bool_opt
label_desc: Use image node_id 4 for calling the IPythonConsoleLexer obj's underlying member method code with example usage: obj.get_mci(line) and returns: mode,  code,  insertion, mode,  code,  insertion, mode,  code,  insertion, mode,  code,  insertion, mode,  code,  insertion, mode,  code,  insertion