code: def read_tex(src):
      r
      c = next(src)
      if c.startswith('%'):
          return c
      elif c.startswith('$'):
          name = '$$' if c.startswith('$$') else '$'
          expr = TexEnv(name, [], nobegin=True)
          return read_math_env(src, expr)
      elif c.startswith('\[') or c.startswith("\("):
          if c.startswith('\['):
              name = 'displaymath'
              begin = '\['
              end = '\]'
          else:
              name = "math"
              begin = "\("
              end = "\)"
  
          expr = TexEnv(name, [], nobegin=True, begin=begin, end=end)
          return read_math_env(src, expr)
      elif c.startswith('\\'):
          command = TokenWithPosition(c[1:], src.position)
          if command == 'item':
              contents, arg = read_item(src)
              mode, expr = 'command', TexCmd(command, contents, arg)
          elif command == 'begin':
              mode, expr, _ = 'begin', TexEnv(src.peek(1)), src.forward(3)
          else:
              mode, expr = 'command', TexCmd(command)
  
          expr.args = read_args(src, expr.args)
  
          if mode == 'begin':
              read_env(src, expr)
          return expr
      if c in ARG_START_TOKENS:
          return read_arg(src, c)
      return c
docs: r"""Read next expression from buffer
  
      :param Buffer src: a buffer of tokens