R Under development (unstable) (2025-02-18 r87748 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # parseLatex bug fixes. These are all bugs in > # tools::parseLatex in R 4.4.2, but not in this package > > library(parseLatex) > > # Uncomment this to see the issues > # parseLatex <- tools::parseLatex > > # 1. Syntax error in tools > parseLatex("\\begin{document} \\end{document} \\begin{foo}") \begin{document} \end{document} > > > # 2. Syntax error in tools > parseLatex("\\begin{foo}\\end{foo}") \begin{foo}\end{foo} > > # 3. Accepted without error by tools -- we want an error > stopifnot(inherits( + try(parseLatex("\\begin{foo} abc \\end{bar}")), + "try-error")) Error in parseLatex("\\begin{foo} abc \\end{bar}") : Parse error at 1:25: \begin{foo} at 1:1 ended by \end{bar} > > # 4. Syntax error in tools > parseLatex("\\Sexpr{ 1 + {1} }") \Sexpr{ 1 + {1} } > > if (! identical(parseLatex, tools::parseLatex)) { + # 5. causes crash in tools. We just want an error. + stopifnot(inherits( + try(parseLatex("{")), + "try-error")) + } Error in parseLatex("{") : Parse error at 1:2: unexpected END_OF_INPUT '{' at 1:1 is still open > > # 6. Syntax errors in tools > parseLatex("\\newenvironment{bea}{\\begin{eqnarray*}}{\\end{eqnarray*}}") \newenvironment{bea}{\begin{eqnarray*}}{\end{eqnarray*}} > parseLatex("\\newcommand{\\bea}{\\begin{eqnarray*}}") \newcommand{\bea}{\begin{eqnarray*}} > parseLatex("\\def\\bea{\\begin{eqnarray*}}") \def\bea{\begin{eqnarray*}} > > # 7. Syntax error in tools > parseLatex("$a$$b$") $a$$b$ > > # 8. Syntax error in tools > > parseLatex("\\let\\bea{\\begin{eqnarray*}}") \let\bea{\begin{eqnarray*}} > > # 9. Accepted in tools > > stopifnot(inherits( + try(parseLatex("\\Sexpr }")), + "try-error")) Error in parseLatex("\\Sexpr }") : Parse error at 1:1: unexpected '}' '\Sexpr' has no argument > > proc.time() user system elapsed 0.21 0.04 0.23