diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index be96d684a8..4b9ca3a3ea 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -42,6 +42,7 @@ All changes included in 1.9: - ([#10291](https://github.com/quarto-dev/quarto-cli/issues/10291)): Fix detection of babel hyphenation warnings with straight-quote format instead of backtick-quote format. - ([rstudio/tinytex-releases#49](https://github.com/rstudio/tinytex-releases/issues/49)): Fix detection of LuaTeX-ja missing file errors by matching both "File" and "file" in error messages. +- ([#13667](https://github.com/quarto-dev/quarto-cli/issues/13667)): Fix LaTeX compilation error with Python error output containing caret characters. ## Projects diff --git a/src/resources/filters/quarto-post/latex.lua b/src/resources/filters/quarto-post/latex.lua index e08a4c83d1..11f18f296f 100644 --- a/src/resources/filters/quarto-post/latex.lua +++ b/src/resources/filters/quarto-post/latex.lua @@ -602,7 +602,7 @@ function render_latex_fixups() -- obtained by a local call to uuid and removing dashes local uuid = "edbdf4a3bc424f5b8ac0e95c92ef5015" - return line:gsub("[\\]", uuid):gsub("([{}$%&%_])", "\\%1"):gsub("[%^]", "\\textasciicaret{}"):gsub("[~]", "\\textasciitilde{}"):gsub(uuid, "\\textbackslash{}") + return line:gsub("[\\]", uuid):gsub("([{}$%&%_])", "\\%1"):gsub("[%^]", "\\textasciicircum{}"):gsub("[~]", "\\textasciitilde{}"):gsub(uuid, "\\textbackslash{}") end if code.text:match("\027%[[0-9;]+m") and #code.classes == 0 then local lines = split(code.text, "\n") diff --git a/tests/docs/smoke-all/2025/11/12/issue-13667.qmd b/tests/docs/smoke-all/2025/11/12/issue-13667.qmd new file mode 100644 index 0000000000..9c0ca40df4 --- /dev/null +++ b/tests/docs/smoke-all/2025/11/12/issue-13667.qmd @@ -0,0 +1,33 @@ +--- +title: "Python syntax error with caret (#13667)" +format: pdf +keep-tex: true +_quarto: + tests: + pdf: + ensureLatexFileRegexMatches: + - ['\\textasciicircum\{\}'] + - ['\\textasciicaret\{\}'] +--- + +::: {.cell execution_count=1} +``` {.python .cell-code} +def my_func(a=10, b): + print(a) + print(b) + +my_func(5) +``` + +::: {.cell-output .cell-output-error} +``` +SyntaxError: parameter without a default follows parameter with a default (1331601683.py, line 1) + Cell In[2], line 1 + def my_func(a=10, b): + ^ +SyntaxError: parameter without a default follows parameter with a default +``` +::: +::: + +