From 035f645f3555bb570e0b5cb74239b930e6dafa2a Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 4 Nov 2025 15:13:48 +0100 Subject: [PATCH 1/6] Fix babel error issue when lang: en is passed, babel-english needs to be installed. This follows up fix on tinytex R package too about new error handling cause is new pandoc way to setup babel, and maybe new babel error in log --- src/command/render/latexmk/parse-error.ts | 6 ++++++ tests/docs/smoke-all/2025/11/04/13633.qmd | 20 ++++++++++++++++++++ tests/unit/latexmk/parse-error.test.ts | 1 + 3 files changed, 27 insertions(+) create mode 100644 tests/docs/smoke-all/2025/11/04/13633.qmd diff --git a/src/command/render/latexmk/parse-error.ts b/src/command/render/latexmk/parse-error.ts index ee99c76330..55061b2f96 100644 --- a/src/command/render/latexmk/parse-error.ts +++ b/src/command/render/latexmk/parse-error.ts @@ -283,6 +283,12 @@ const packageMatchers = [ { regex: /.*! LaTeX Error: File [`']([^']+)' not found.*/g }, { regex: /.* [fF]ile ['`]?([^' ]+)'? not found.*/g }, { regex: /.*the language definition file ([^\s]*).*/g }, + { + regex: /.*! Package babel Error: Unknown option [`']([^'`]+)'[.].*/g, + filter: (match: string, _text: string) => { + return `${match}.ldf`; + }, + }, { regex: /.* \\(file ([^)]+)\\): cannot open .*/g }, { regex: /.*file [`']([^']+)' .*is missing.*/g }, { regex: /.*! CTeX fontset [`']([^']+)' is unavailable.*/g }, diff --git a/tests/docs/smoke-all/2025/11/04/13633.qmd b/tests/docs/smoke-all/2025/11/04/13633.qmd new file mode 100644 index 0000000000..b89c6e3826 --- /dev/null +++ b/tests/docs/smoke-all/2025/11/04/13633.qmd @@ -0,0 +1,20 @@ +--- +title: "Babel English Auto-Install (#13633)" +format: pdf +lang: en +_quarto: + tests: + pdf: null +--- + +```{r} +#| include: false + +# Remove babel-english package to test auto-installation +if (tinytex::check_installed("babel-english")) { + message("Removing 'babel-english' package for the render") + tinytex::tlmgr_remove("babel-english") +} +``` + +This document tests that Quarto correctly detects and auto-installs babel-english when rendering with `lang: en`. diff --git a/tests/unit/latexmk/parse-error.test.ts b/tests/unit/latexmk/parse-error.test.ts index 3a34e4f8f3..2538b99a1d 100644 --- a/tests/unit/latexmk/parse-error.test.ts +++ b/tests/unit/latexmk/parse-error.test.ts @@ -42,6 +42,7 @@ unitTest("Detect missing files with `findMissingFontsAndPackages`", async () => (babel) There is a locale ini file for this language. (babel) If it’s the main language, try adding \`provide=*' (babel) to the babel package options.`, "ngerman.ldf") + assertFound("! Package babel Error: Unknown option 'english'.", "english.ldf"); assertFound("!pdfTeX error: pdflatex (file 8r.enc): cannot open encoding file for reading", "8r.enc"); assertFound("! CTeX fontset `fandol' is unavailable in current mode", "fandol"); assertFound("! CTeX fontset 'fandol' is unavailable in current mode", "fandol"); From 2695e26d8b404157b7dfbb7caa8688651b0327b6 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 4 Nov 2025 15:18:17 +0100 Subject: [PATCH 2/6] Add to changelog --- news/changelog-1.9.md | 1 + 1 file changed, 1 insertion(+) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index f5953cd508..b684e92e1f 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -37,6 +37,7 @@ All changes included in 1.9: ### `pdf` +- ([#13633](https://github.com/quarto-dev/quarto-cli/issues/13633)): Fix detection and auto-installation of babel language packages from newer error format that doesn't explicitly mention `.ldf` filename. - ([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. ## Projects From c92ec40a66d67132b3df055eec43b11221598a37 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 4 Nov 2025 16:15:46 +0100 Subject: [PATCH 3/6] Revert "tests - adapt as Pandoc 3.6.3 brings improved babel support" This reverts commit 7cd89061cd80c575afced2a589640cc43fddfc18. --- .../2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd index 294d822314..fe651943a8 100644 --- a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd +++ b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd @@ -1,11 +1,14 @@ --- format: pdf -# new babel support in Pandoc 3.6.3 solves missing package when specific lang is used. lang: es latex-auto-install: false _quarto: tests: - pdf: default + pdf: + noErrors: true + printsMessage: + - WARN + - 'missing hyphenation.*hyphen-spanish' --- ```{r} From 499be6ba6651b101e0f6f25e9dc3e82125784fe3 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 4 Nov 2025 19:34:37 +0100 Subject: [PATCH 4/6] Fix babel hyphenation warning detection with straight quotes (#10291) Updated regex to accept both backtick-quote (`Spanish') and straight-quote ('Spanish') formats for detecting missing hyphenation packages. Added unit tests and modified smoke-all tests to skip package removal on CI. --- news/changelog-1.9.md | 1 + src/command/render/latexmk/parse-error.ts | 2 +- .../10291/latex-hyphen-lang-es-no-install.qmd | 9 ++- .../2024/08/30/10291/latex-hyphen-lang-es.qmd | 7 +++ tests/docs/smoke-all/2025/11/04/13633.qmd | 2 + tests/unit/latexmk/parse-error.test.ts | 62 ++++++++++++++++++- 6 files changed, 78 insertions(+), 5 deletions(-) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index b684e92e1f..dba66965c2 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -37,6 +37,7 @@ All changes included in 1.9: ### `pdf` +- ([#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. - ([#13633](https://github.com/quarto-dev/quarto-cli/issues/13633)): Fix detection and auto-installation of babel language packages from newer error format that doesn't explicitly mention `.ldf` filename. - ([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. diff --git a/src/command/render/latexmk/parse-error.ts b/src/command/render/latexmk/parse-error.ts index 55061b2f96..02a5b1b87d 100644 --- a/src/command/render/latexmk/parse-error.ts +++ b/src/command/render/latexmk/parse-error.ts @@ -133,7 +133,7 @@ export function findMissingHyphenationFiles(logText: string) { const babelWarningRegex = /^Package babel Warning:/m; const hasWarning = logText.match(babelWarningRegex); if (hasWarning) { - const languageRegex = /^\(babel\).* language `(\S+)'.*$/m; + const languageRegex = /^\(babel\).* language [`'](\S+)[`'].*$/m; const languageMatch = logText.match(languageRegex); if (languageMatch) { return filterLang(languageMatch[1]); diff --git a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd index fe651943a8..a05b0a6b80 100644 --- a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd +++ b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd @@ -3,14 +3,17 @@ format: pdf lang: es latex-auto-install: false _quarto: + tests-on-ci: false tests: pdf: - noErrors: true + shouldError: true printsMessage: - - WARN - - 'missing hyphenation.*hyphen-spanish' + level: INFO + regex: "Unknown option 'spanish'" --- +** This test is to be run manually as we don't want to uninstall and reinstall package in CI** + ```{r} #| include: false diff --git a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es.qmd b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es.qmd index 89bafffd58..ce1b6b6670 100644 --- a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es.qmd +++ b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es.qmd @@ -6,14 +6,21 @@ _quarto: pdf: null --- +**Only remove package on CI** ```{r} +#| eval: !expr isFALSE(as.logical(Sys.getenv("CI", "false"))) #| include: false +#| messages: "NA" # Remove the hyphen package for spanish if (tinytex::check_installed("hyphen-spanish")) { message("Removing 'hyphen-spanish' package for the render") tinytex::tlmgr_remove("hyphen-spanish") } +if (tinytex::check_installed("babel-spanish")) { + message("Removing 'babel-spanish' package for the render") + tinytex::tlmgr_remove("babel-spanish") +} ``` # Hola ! diff --git a/tests/docs/smoke-all/2025/11/04/13633.qmd b/tests/docs/smoke-all/2025/11/04/13633.qmd index b89c6e3826..24685a399b 100644 --- a/tests/docs/smoke-all/2025/11/04/13633.qmd +++ b/tests/docs/smoke-all/2025/11/04/13633.qmd @@ -8,7 +8,9 @@ _quarto: --- ```{r} +#| eval: !expr isFALSE(as.logical(Sys.getenv("CI", "false"))) #| include: false +#| messages: "NA" # Remove babel-english package to test auto-installation if (tinytex::check_installed("babel-english")) { diff --git a/tests/unit/latexmk/parse-error.test.ts b/tests/unit/latexmk/parse-error.test.ts index 2538b99a1d..7ad40b854b 100644 --- a/tests/unit/latexmk/parse-error.test.ts +++ b/tests/unit/latexmk/parse-error.test.ts @@ -5,7 +5,7 @@ * */ -import { findMissingFontsAndPackages } from "../../../src/command/render/latexmk/parse-error.ts" +import { findMissingFontsAndPackages, findMissingHyphenationFiles } from "../../../src/command/render/latexmk/parse-error.ts" import { unitTest } from "../../test.ts"; import { assert } from "testing/asserts"; @@ -43,6 +43,9 @@ unitTest("Detect missing files with `findMissingFontsAndPackages`", async () => (babel) If it’s the main language, try adding \`provide=*' (babel) to the babel package options.`, "ngerman.ldf") assertFound("! Package babel Error: Unknown option 'english'.", "english.ldf"); + assertFound(`! Package babel Error: Unknown option 'ngerman'. +(babel) Suggested actions: +(babel) * Make sure you haven't misspelled it`, "ngerman.ldf"); assertFound("!pdfTeX error: pdflatex (file 8r.enc): cannot open encoding file for reading", "8r.enc"); assertFound("! CTeX fontset `fandol' is unavailable in current mode", "fandol"); assertFound("! CTeX fontset 'fandol' is unavailable in current mode", "fandol"); @@ -71,4 +74,61 @@ unitTest("Detect missing files with `findMissingFontsAndPackages`", async () => assertFound("No file LGRcmr.fd. ! LaTeX Error: This NFSS system isn't set up properly.", "lgrcmr.fd"); },{ cwd: () => "unit/latexmk/" +}) + +unitTest("Detect missing hyphenation with babel warnings", async () => { + // Test backtick-quote format (old format) + const logWithBacktick = `Package babel Warning: No hyphenation patterns were preloaded for +(babel) the language \`Spanish' into the format. +(babel) Please, configure your TeX system to add them and +(babel) rebuild the format. Now I will use the patterns +(babel) preloaded for \\language=0 instead on input line 51.`; + assert( + findMissingHyphenationFiles(logWithBacktick) === "hyphen-spanish", + "Should detect hyphen-spanish from backtick-quote format" + ); + + // Test straight-quote format (new format - the bug we're fixing) + const logWithStraightQuotes = `Package babel Warning: No hyphenation patterns were preloaded for +(babel) the language 'Spanish' into the format. +(babel) Please, configure your TeX system to add them and +(babel) rebuild the format. Now I will use the patterns +(babel) preloaded for \\language=0 instead on input line 51.`; + assert( + findMissingHyphenationFiles(logWithStraightQuotes) === "hyphen-spanish", + "Should detect hyphen-spanish from straight-quote format" + ); + + // Test ngerman special case (should return hyphen-german, not hyphen-ngerman) + const logGerman = `Package babel Warning: No hyphenation patterns were preloaded for +(babel) the language 'ngerman' into the format.`; + assert( + findMissingHyphenationFiles(logGerman) === "hyphen-german", + "Should map ngerman to hyphen-german" + ); + + // Test Chinese - no hyphen package exists + const logChinese = `Package babel Warning: No hyphenation patterns were preloaded for +(babel) the language 'chinese' into the format.`; + assert( + findMissingHyphenationFiles(logChinese) === undefined, + "Should return undefined for Chinese (no hyphen package)" + ); + + // Test alternative Info pattern (issue #10291) + const logInfoChinese = `Package babel Info: Hyphen rules for 'chinese-hans' set to \\l@nil +(babel) (\\language10). Reported on input line 143.`; + assert( + findMissingHyphenationFiles(logInfoChinese) === undefined, + "Should return undefined for chinese-hans via Info pattern" + ); + + // Test no warning present + const logNoWarning = "Some other log text without babel warnings"; + assert( + findMissingHyphenationFiles(logNoWarning) === undefined, + "Should return undefined when no babel warning present" + ); +}, { + cwd: () => "unit/latexmk/" }) \ No newline at end of file From 3687a4dd372127e322b152a33ded34da526b50af Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 5 Nov 2025 10:33:26 +0100 Subject: [PATCH 5/6] Correct fix fo the test when no auto install --- .../2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd index a05b0a6b80..ef95719fb8 100644 --- a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd +++ b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd @@ -6,17 +6,17 @@ _quarto: tests-on-ci: false tests: pdf: - shouldError: true + noErrors: true printsMessage: - level: INFO - regex: "Unknown option 'spanish'" + level: WARN + regex: "Possibly missing hyphenation" --- ** This test is to be run manually as we don't want to uninstall and reinstall package in CI** ```{r} #| include: false - +#| messages: 'NA' # Remove the hyphen package for spanish so that the test is meaningful if (tinytex::check_installed("hyphen-spanish")) { message("Removing 'hyphen-spanish' package for the render") From b1e3e16f6abb20d7e0fd50728ee711c3870cc620 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 5 Nov 2025 10:51:31 +0100 Subject: [PATCH 6/6] Move changelog item to Regression part --- news/changelog-1.9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index dba66965c2..36e401833d 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -6,6 +6,7 @@ All changes included in 1.9: - ([#13441](https://github.com/quarto-dev/quarto-cli/pull/13441)): Catch `undefined` exceptions in Pandoc failure to avoid spurious error message. - ([#13046](https://github.com/quarto-dev/quarto-cli/issues/13046)): Use new url for multiplex socket.io server as default for `format: revealjs` and `revealjs.multiplex: true`. - ([#13506](https://github.com/quarto-dev/quarto-cli/issues/13506)): Fix navbar active state detection when sidebar has no logo configured. Prevents empty logo links from interfering with navigation highlighting. +- ([#13633](https://github.com/quarto-dev/quarto-cli/issues/13633)): Fix detection and auto-installation of babel language packages from newer error format that doesn't explicitly mention `.ldf` filename. ## Dependencies @@ -38,7 +39,6 @@ All changes included in 1.9: ### `pdf` - ([#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. -- ([#13633](https://github.com/quarto-dev/quarto-cli/issues/13633)): Fix detection and auto-installation of babel language packages from newer error format that doesn't explicitly mention `.ldf` filename. - ([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. ## Projects