code: def read_math_env(src, expr):
      r
      content = src.forward_until(lambda s: s == expr.end)
      if not src.startswith(expr.end):
          end = src.peek()
          explanation = 'Instead got %s' % end if end else 'Reached end of file.'
          raise EOFError('Expecting %s. %s' % (expr.end, explanation))
      else:
          src.forward(1)
      expr.append(content)
      return expr
docs: r"""Read the environment from buffer.
  
      Advances the buffer until right after the end of the environment. Adds
      parsed content to the expression automatically.
  
      :param Buffer src: a buffer of tokens
      :param TexExpr expr: expression for the environment
      :rtype: TexExpr