code: def read(tex):
      
      if isinstance(tex, str):
          tex = tex
      else:
          tex = ''.join(itertools.chain(*tex))
      buf, children = Buffer(tokenize(tex)), []
      while buf.hasNext():
          content = read_tex(buf)
          if content is not None:
              children.append(content)
      return TexEnv('[tex]', children), tex
docs: Read and parse all LaTeX source
  
      :param Union[str,iterable] tex: LaTeX source
      :return TexEnv: the global environment