From b42af9469f0a24d270cb03c098912b7b47ec0bf1 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 27 Aug 2024 14:23:28 +0200 Subject: [PATCH 1/6] Remove unused line should have been removed in 4ec65172fd8dc2eeae10736a03e7d18537a8a7d3 --- src/command/render/latexmk/pdf.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/command/render/latexmk/pdf.ts b/src/command/render/latexmk/pdf.ts index 52062aa3f1e..6e8078da5a5 100644 --- a/src/command/render/latexmk/pdf.ts +++ b/src/command/render/latexmk/pdf.ts @@ -205,8 +205,6 @@ async function initialCompileLatex( packagesUpdated = true; } - const logText = Deno.readTextFileSync(response.log); - // Try to find and install packages const packagesInstalled = await findAndInstallPackages( pkgMgr, From c543de678674cb753cca75e4c8b3688f9cbbf69a Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 27 Aug 2024 14:45:17 +0200 Subject: [PATCH 2/6] latex - don't fail on hyphenation installation --- src/command/render/latexmk/pdf.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/command/render/latexmk/pdf.ts b/src/command/render/latexmk/pdf.ts index 6e8078da5a5..a7b984d6526 100644 --- a/src/command/render/latexmk/pdf.ts +++ b/src/command/render/latexmk/pdf.ts @@ -180,13 +180,21 @@ async function initialCompileLatex( const logText = Deno.readTextFileSync(response.log); const missingHyphenationFile = findMissingHyphenationFiles(logText); if (missingHyphenationFile) { - if (await pkgMgr.installPackages([missingHyphenationFile])) { - // We installed hyphenation files, retry - continue; - } else { - writeError("missing hyphenation file", "", response.log); - return Promise.reject(); + // try to install it, unless auto install is opted out + if (pkgMgr.autoInstall) { + logProgress("Installing missing hyphenation file..."); + if (await pkgMgr.installPackages([missingHyphenationFile])) { + // We installed hyphenation files, retry + continue; + } else { + logProgress("Installing missing hyphenation file failed."); + } } + // Let's just through a warning, but it may not be fatal for the compilation + // and we can end normally + warning( + `Possibly missing hyphenation file: '${missingHyphenationFile}'. See more in logfile (by setting 'latex-clean: false').\n`, + ); } } else if (pkgMgr.autoInstall) { // try autoinstalling From 7b5c2477d12c84a0ddc9ca11e6b492cdac21f616 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 27 Aug 2024 14:51:51 +0200 Subject: [PATCH 3/6] latex - chinese-hans hyphenation package does not exists. Don't try to install it closes #10291 - Quarto v1.5 installs a nonexistent package `hyphen-chinese-hans` when compiling PDF --- src/command/render/latexmk/parse-error.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/command/render/latexmk/parse-error.ts b/src/command/render/latexmk/parse-error.ts index 98206453a1b..13bf469a2a0 100644 --- a/src/command/render/latexmk/parse-error.ts +++ b/src/command/render/latexmk/parse-error.ts @@ -111,6 +111,14 @@ const resolvingMatchers = [ export function findMissingHyphenationFiles(logText: string) { //ngerman gets special cased const filterLang = (lang: string) => { + // It seems some languages have no hyphenation files, so we just filter them out + // e.g. `lang: zh` has no hyphenation files + // https://github.com/quarto-dev/quarto-cli/issues/10291 + const noHyphen = ["chinese-hans"]; + if (noHyphen.includes(lang)) { + return; + } + // NOTE Although the names of the corresponding lfd files match those in this list, // there are some exceptions, particularly in German and Serbian. So, ngerman is // called here german, which is the name in the CLDR and, actually, the most logical. From 321d4d096ee95555475cb7b554422f1142be05a0 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 27 Aug 2024 15:00:15 +0200 Subject: [PATCH 4/6] latex - add chinese as another exception without hyphen package --- src/command/render/latexmk/parse-error.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/render/latexmk/parse-error.ts b/src/command/render/latexmk/parse-error.ts index 13bf469a2a0..654bb1f287b 100644 --- a/src/command/render/latexmk/parse-error.ts +++ b/src/command/render/latexmk/parse-error.ts @@ -114,7 +114,7 @@ export function findMissingHyphenationFiles(logText: string) { // It seems some languages have no hyphenation files, so we just filter them out // e.g. `lang: zh` has no hyphenation files // https://github.com/quarto-dev/quarto-cli/issues/10291 - const noHyphen = ["chinese-hans"]; + const noHyphen = ["chinese-hans", "chinese"]; if (noHyphen.includes(lang)) { return; } From d35cfb16468671e8e39f286abe1a290fdf7c5a06 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 27 Aug 2024 16:05:09 +0200 Subject: [PATCH 5/6] Add a changelog entry [skip ci] --- news/changelog-1.6.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/news/changelog-1.6.md b/news/changelog-1.6.md index 4d67dcd5c22..4bdf6eb5142 100644 --- a/news/changelog-1.6.md +++ b/news/changelog-1.6.md @@ -5,7 +5,7 @@ All changes included in 1.6: - ([#10039](https://github.com/quarto-dev/quarto-cli/issues/10039)): `quarto inspect` properly handles `!expr` tag in metadata. - ([#10188](https://github.com/quarto-dev/quarto-cli/issues/10188)): `quarto inspect` properly resolves includes across subdirectory boundaries. -## Lua filters +## Lua Filters - ([#10004](https://github.com/quarto-dev/quarto-cli/issues/10004)): Resolve callout titles, theorem names, and `code-summary` content through `quarto_ast_pipeline()` and `process_shortcodes()`. - ([#10196](https://github.com/quarto-dev/quarto-cli/issues/10196)): Protect against nil values in `float.caption_long`. @@ -23,6 +23,13 @@ All changes included in 1.6: - ([#10217](https://github.com/quarto-dev/quarto-cli/issues/10217)): Explicitly compute units for image dimensions in `typst` format when they're not given. - ([#10212](https://github.com/quarto-dev/quarto-cli/issues/10212)): Moves Pandoc variables to the function declaration for the default template. +## `latex` and `pdf` Format + +- ([#10291](https://github.com/quarto-dev/quarto-cli/issues/10291)): Several improvement regarding Quarto LaTeX engine behavior for missing hyphenation log message: + - `latex-auto-install: false` now correctly opt out any missing hyphenation packages detection and installation. Only a warning will be thrown if any detected in the log. + - For default behavior (`latex-auto-install: true`), detection is still happening and missing packages are installed automatically. If it fails, Quarto does not fail anymore as PDF rendering as succeeded already. Only a warning will be thrown to log the installation failure. + - Log message about hyphenation package missing for `chinese` or `chinese-hans` languages are now ignored. + ## Projects - ([#10268](https://github.com/quarto-dev/quarto-cli/issues/10268)]): `quarto create` supports opening project in Positron, in addition to VS Code and RStudio IDE. From ab5ccecf1a0fde2563db5d58e4533327192d1044 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 30 Aug 2024 11:09:37 +0200 Subject: [PATCH 6/6] Add some tests for hyphenation auto install or not --- .../10291/latex-hyphen-lang-es-no-install.qmd | 26 +++++++++++++++++++ .../2024/08/30/10291/latex-hyphen-lang-es.qmd | 21 +++++++++++++++ .../2024/08/30/10291/latex-hyphen-lang-zh.qmd | 9 +++++++ 3 files changed, 56 insertions(+) create mode 100644 tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd create mode 100644 tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es.qmd create mode 100644 tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-zh.qmd 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 new file mode 100644 index 00000000000..fe651943a8c --- /dev/null +++ b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es-no-install.qmd @@ -0,0 +1,26 @@ +--- +format: pdf +lang: es +latex-auto-install: false +_quarto: + tests: + pdf: + noErrors: true + printsMessage: + - WARN + - 'missing hyphenation.*hyphen-spanish' +--- + +```{r} +#| include: false + +# 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") + tinytex::tlmgr_remove("hyphen-spanish") +} +``` + +# Hola ! + +automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente \ No newline at end of file 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 new file mode 100644 index 00000000000..89bafffd58b --- /dev/null +++ b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-es.qmd @@ -0,0 +1,21 @@ +--- +format: pdf +lang: es +_quarto: + tests: + pdf: null +--- + +```{r} +#| include: false + +# 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") +} +``` + +# Hola ! + +automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente \ No newline at end of file diff --git a/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-zh.qmd b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-zh.qmd new file mode 100644 index 00000000000..37e7de4108f --- /dev/null +++ b/tests/docs/smoke-all/2024/08/30/10291/latex-hyphen-lang-zh.qmd @@ -0,0 +1,9 @@ +--- +format: pdf +lang: zh +_quarto: + tests: + pdf: null +--- + +# 范叶亮 \ No newline at end of file