Open isovector opened 5 years ago
Actually, I think this might be mostly my fault. Here's one of the environments I was trying to expand:
\begin{code}
main :: IO ()
main = do
bool <- read
withSomeSBool (toSBool bool) $ !\annotate{1}!
\(_ :: SBool b) -> !\annotate{2}!
runLogging @b program !\annotate{3}!
\end{code}
which is a \VerbatimEnvironment
in latex. I hadn't added it to the list of verbatim environments in hatex---which meant a lot of backtracking was going into this, even though it could never succeed.
What is the result if you use the following parser configuration?
ParserConf { verbatimEnvironments = ["verbatim", "code"] }
The problem might be with the \(_ :: SBool b)
bit. The parser might think \(
is the beginning of a mathematical expression.
It works as expected with the given ParserConf
.
Great! I'm glad that worked for you.
Is the example code above enough to break the parser using default configuration?
The example code above does break the parser as expected. However, in long documents, this broken parser seems to result in the backtracking issue described above---it will keep consuming input outside of the code
environment trying to fix the parse.
parseLaTeX
performs exponential amounts of work in the number of environments. I have two files,book2.txt
andbook3.txt
which are roughly the same size in bytes, but the latter has ~3x as many environments.book2.txt
parses quickly, but I haven't been patient enough to getbook3.txt
to.The
shiatsu
program below is doing nothing more than reading the file and callingparseLaTeX
.Here's the profile information