hutchresearch / latex2speech

TeX2Speech is an application that turns LaTeX documents into spoken audio.
https://tex2speech-website.vercel.app/
MIT License
12 stars 5 forks source link

TexSoup Error I #88

Closed willsower closed 3 years ago

willsower commented 3 years ago

For aztec.tex file [found in Documentation/hundred_k_errors/, at the top of the file has all these dependencies before it starts \begin{document}

\documentclass[10pt,reqno]{amsart}
\addtolength {\textwidth} {.5in}
%\addtolength {\oddsidemargin} {-.3in}
%\addtolength {\evensidemargin} {-.3in}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{graphicx}
\theoremstyle{plain}
\newtheorem{Thm}{Theorem}
\newtheorem{Cor}[Thm]{Corollary}
\newtheorem{Main}{Main Theorem}
\newtheorem{Mres}{Main Result}
\newtheorem{\theMain}{}
\newtheorem{Lem}[Thm]{Lemma}
\newtheorem{Prob}{Problem}
\newtheorem{Prop}[Thm]{Proposition}
\theoremstyle{definition}
\newtheorem{Def}{Definition}
\theoremstyle{remark}
\newtheorem{notation}{Notation}
\renewcommand{\thenotation}{}
\def\determinant#1{\left|#1\right|}
\def\biggdet#1{\biggl|#1\biggr|}
\long\def\comment#1{\textsf{\em[#1]}}
\renewcommand{\datename}{Version of}
\newcommand{\ntt}{\normalfont\ttfamily}
\newcommand{\pkg}[1]{{\protect\ntt#1}}
\DeclareMathOperator{\sgn }{sgn }
\DeclareMathOperator{\card }{card }
\DeclareMathOperator{\len }{len }
\DeclareMathOperator{\minor }{minor}
\DeclareMathOperator{\kr }{kr}
\parindent=0in
\parskip=10pt

When I delete this at the top, the file runs (there are other bugs that are found in TexParser) but it won't even run TexParser with the dependencies/libraries above.

I have narrowed the potential palce of error:

  1. expand_doc_new_labels When using TexSoup here it errors, here is the part of the error log

    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/application.py", line 215, in handle_form
    file_links = start_polly(file_holder, bib_holder)
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/aws_polly_render.py", line 323, in start_polly
    expand_doc_new_labels(master[0])
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/expand_labels.py", line 101, in expand_doc_new_labels
    contents = replace_references(doc.read(), myHash)
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/expand_labels.py", line 72, in replace_references
    myDoc = TexSoup.TexSoup(str(contents))
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/__init__.py", line 87, in TexSoup
    parsed, src = read(tex_code, skip_envs=skip_envs, tolerance=tolerance)
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/tex.py", line 22, in read
    return TexEnv('[tex]', begin='', end='', contents=buf), tex
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/data.py", line 892, in __init__
    super().__init__(name, contents, args, preserve_whitespace, position)
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/data.py", line 641, in __init__
    self._contents = list(contents) or []
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 49, in read_tex
    yield read_expr(buf,
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 114, in read_expr
    return read_arg(src, c, tolerance=tolerance)
    File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 466, in read_arg
    raise TypeError(
  2. When I comment out the line of expanding labels, then the error occurs with expand_macros which ALSO uses TexSoup. Here is part of the error log with expand_labels commented out and it running and erroring at expand_macros.

  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/application.py", line 215, in handle_form
    file_links = start_polly(file_holder, bib_holder)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/aws_polly_render.py", line 327, in start_polly
    parsed_contents = start_conversion(tex_file.read())
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/aws_polly_render.py", line 300, in start_conversion
    parsed_contents = parser.parse(contents)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/conversion_parser.py", line 360, in parse
    doc = expand_doc_macros(doc)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/expand_macros.py", line 158, in expand_doc_macros
    doc = normalize_doc_macros(doc)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/expand_macros.py", line 149, in normalize_doc_macros
    return TexSoup.TexSoup(text)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/__init__.py", line 87, in TexSoup
    parsed, src = read(tex_code, skip_envs=skip_envs, tolerance=tolerance)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/tex.py", line 22, in read
    return TexEnv('[tex]', begin='', end='', contents=buf), tex
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/data.py", line 892, in __init__
    super().__init__(name, contents, args, preserve_whitespace, position)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/data.py", line 641, in __init__
    self._contents = list(contents) or []
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 49, in read_tex
    yield read_expr(buf,
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 95, in read_expr
    name, args = read_command(src, tolerance=tolerance, mode=mode)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 540, in read_command
    args = read_args(buf, n_required_args, n_optional_args,
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 347, in read_args
    n_required = read_arg_required(src, args, n_required, tolerance, mode)
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 417, in read_arg_required
    args.append(read_arg(
  File "/Users/taichen/Desktop/Tai/MyRepos/Tex2Speech/latex2speech/tex2speech/virt/lib/python3.8/site-packages/TexSoup/reader.py", line 466, in read_arg
    raise TypeError(
willsower commented 3 years ago

Working on this in other issues