diff --git a/news/changelog-1.12.md b/news/changelog-1.12.md index 862d32b463f..d895ffb5722 100644 --- a/news/changelog-1.12.md +++ b/news/changelog-1.12.md @@ -17,6 +17,10 @@ All changes included in 1.12: - ([#14783](https://github.com/quarto-dev/quarto-cli/issues/14783)): Fix `quarto preview` ignoring project metadata contributed by an extension, such as `brand`. Contributed project metadata now applies to every command that builds a project context, `quarto inspect` included. (author: @mcanouil) +## Extensions + +- ([#15063](https://github.com/quarto-dev/quarto-cli/issues/15063)): Fix a format extension's own `language` file stopping the render with a "does not exist" error, and its `metadata-files` being ignored. Both now resolve relative to the extension's directory, and per-language files such as `_language-fr.yml` load beside the `language` file. (author: @mcanouil) + ## Other fixes and improvements - ([#14822](https://github.com/quarto-dev/quarto-cli/issues/14822)): Translate the `tools-share`, `tools-download`, and `skip-to-content` language keys in Greek. (author: @sogav21) diff --git a/src/command/render/render-contexts.ts b/src/command/render/render-contexts.ts index a7c227f28ee..470de3a1b59 100644 --- a/src/command/render/render-contexts.ts +++ b/src/command/render/render-contexts.ts @@ -717,9 +717,11 @@ const readExtensionFormat = async ( extensionMetadata[kExtensionName] = extensionMetadata[kExtensionName] || effectiveExtension; + // resolveExtensionPaths made the extension paths relative to the + // document, so the document is the base, not the extension directory const formats = await resolveFormatsFromMetadata( extensionMetadata, - extension.path, + file, [formatDesc.baseFormat], ); diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063-project/.gitignore b/tests/docs/smoke-all/2026/11/03/issue-15063-project/.gitignore new file mode 100644 index 00000000000..ad293093b07 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063-project/.gitignore @@ -0,0 +1,2 @@ +/.quarto/ +**/*.quarto_ipynb diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_extension.yml b/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_extension.yml new file mode 100644 index 00000000000..a2af6c7a08c --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_extension.yml @@ -0,0 +1,7 @@ +title: Language file +author: Quarto Dev Team +version: 1.0.0 +contributes: + formats: + html: + language: _language.yml diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_language-fr.yml b/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_language-fr.yml new file mode 100644 index 00000000000..dca666edd51 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_language-fr.yml @@ -0,0 +1 @@ +toc-title-document: "Sommaire de l extension" diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_language.yml b/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_language.yml new file mode 100644 index 00000000000..e86622bd2fa --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063-project/_extensions/langfile/_language.yml @@ -0,0 +1 @@ +toc-title-document: "Contents from the extension" diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063-project/_quarto.yml b/tests/docs/smoke-all/2026/11/03/issue-15063-project/_quarto.yml new file mode 100644 index 00000000000..b8bae5830fa --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063-project/_quarto.yml @@ -0,0 +1,2 @@ +project: + type: default diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063-project/chapters/nested.qmd b/tests/docs/smoke-all/2026/11/03/issue-15063-project/chapters/nested.qmd new file mode 100644 index 00000000000..a6b0b23867e --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063-project/chapters/nested.qmd @@ -0,0 +1,18 @@ +--- +title: "A document in a project subdirectory reads the language file of a root extension" +format: langfile-html +toc: true +_quarto: + tests: + langfile-html: + ensureFileRegexMatches: + - ['

Contents from the extension

'] + - [] +--- + +## Section + +This document is in a subdirectory of the project, and the `langfile` extension is at the root of the project. +The path to the language file of the extension starts with `../`. +Before the fix, this case worked by chance, because the wrong base directory and the `../` offset cancelled each other out. +This test makes sure that the case continues to work. diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063-project/index.qmd b/tests/docs/smoke-all/2026/11/03/issue-15063-project/index.qmd new file mode 100644 index 00000000000..54152ad8111 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063-project/index.qmd @@ -0,0 +1,17 @@ +--- +title: "A format extension at the project root reads its own language file" +format: langfile-html +toc: true +_quarto: + tests: + langfile-html: + ensureFileRegexMatches: + - ['

Contents from the extension

'] + - [] +--- + +## Section + +This document is at the root of a project, and the `langfile` extension is in the `_extensions/` directory of the project. +Before the fix, Quarto looked for the language file in `_extensions/_extensions/langfile/` and the render stopped. +The table of contents must show the title from the language file of the extension. diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/acme/orgfile/_extension.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/acme/orgfile/_extension.yml new file mode 100644 index 00000000000..a27151dd34a --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/acme/orgfile/_extension.yml @@ -0,0 +1,7 @@ +title: Language file in an organisation +author: Quarto Dev Team +version: 1.0.0 +contributes: + formats: + html: + language: _language.yml diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/acme/orgfile/_language.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/acme/orgfile/_language.yml new file mode 100644 index 00000000000..dacdc22e456 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/acme/orgfile/_language.yml @@ -0,0 +1 @@ +toc-title-document: "Contents from the organisation extension" diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_extension.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_extension.yml new file mode 100644 index 00000000000..a2af6c7a08c --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_extension.yml @@ -0,0 +1,7 @@ +title: Language file +author: Quarto Dev Team +version: 1.0.0 +contributes: + formats: + html: + language: _language.yml diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_language-fr.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_language-fr.yml new file mode 100644 index 00000000000..dca666edd51 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_language-fr.yml @@ -0,0 +1 @@ +toc-title-document: "Sommaire de l extension" diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_language.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_language.yml new file mode 100644 index 00000000000..e86622bd2fa --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/langfile/_language.yml @@ -0,0 +1 @@ +toc-title-document: "Contents from the extension" diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/metafile/_extension.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/metafile/_extension.yml new file mode 100644 index 00000000000..8d58c0a6268 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/metafile/_extension.yml @@ -0,0 +1,8 @@ +title: Metadata file +author: Quarto Dev Team +version: 1.0.0 +contributes: + formats: + html: + metadata-files: + - _metadata-extra.yml diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/metafile/_metadata-extra.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/metafile/_metadata-extra.yml new file mode 100644 index 00000000000..f82cea52e2d --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/metafile/_metadata-extra.yml @@ -0,0 +1 @@ +toc-title: "Contents from the extension metadata file" diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/_extension.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/_extension.yml new file mode 100644 index 00000000000..29e925d11ec --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/_extension.yml @@ -0,0 +1,7 @@ +title: Language file in a subfolder +author: Quarto Dev Team +version: 1.0.0 +contributes: + formats: + html: + language: i18n/strings.yml diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/i18n/strings-fr.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/i18n/strings-fr.yml new file mode 100644 index 00000000000..6ed60167a0c --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/i18n/strings-fr.yml @@ -0,0 +1 @@ +toc-title-document: "Sommaire du sous-dossier" diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/i18n/strings.yml b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/i18n/strings.yml new file mode 100644 index 00000000000..b9b96d0c273 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/_extensions/subdirfile/i18n/strings.yml @@ -0,0 +1 @@ +toc-title-document: "Contents from the extension subfolder" diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-fr.qmd b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-fr.qmd new file mode 100644 index 00000000000..02c48ebb93c --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-fr.qmd @@ -0,0 +1,18 @@ +--- +title: "A format extension reads the per-language file beside its language file" +format: langfile-html +toc: true +lang: fr +_quarto: + tests: + langfile-html: + ensureFileRegexMatches: + - ['

Sommaire de l extension

'] + - ['Contents from the extension'] +--- + +## Section + +The `langfile` extension has a `_language-fr.yml` file next to its `_language.yml` file. +With `lang: fr`, Quarto must load the French file. +Its title replaces the English title of the extension and the built-in French title of Quarto. diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-metadata-files.qmd b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-metadata-files.qmd new file mode 100644 index 00000000000..6a7fe473fe1 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-metadata-files.qmd @@ -0,0 +1,17 @@ +--- +title: "A format extension reads its own metadata files" +format: metafile-html +toc: true +_quarto: + tests: + metafile-html: + ensureFileRegexMatches: + - ['

Contents from the extension metadata file

'] + - [] +--- + +## Section + +The `metafile` extension sets `metadata-files` for its HTML format, and the file sets `toc-title`. +Before the fix, Quarto looked for the file in the wrong directory and ignored it without a message. +The table of contents must show the title from this file. diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-org.qmd b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-org.qmd new file mode 100644 index 00000000000..2d793f1c732 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-org.qmd @@ -0,0 +1,17 @@ +--- +title: "An extension under an organisation directory reads its own language file" +format: orgfile-html +toc: true +_quarto: + tests: + orgfile-html: + ensureFileRegexMatches: + - ['

Contents from the organisation extension

'] + - [] +--- + +## Section + +The `orgfile` extension is in an organisation directory, `_extensions/acme/orgfile/`. +Before the fix, Quarto looked for the language file in `_extensions/acme/_extensions/acme/orgfile/`. +The table of contents must show the title from the language file of the extension. diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-override.qmd b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-override.qmd new file mode 100644 index 00000000000..5638be17919 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-override.qmd @@ -0,0 +1,19 @@ +--- +title: "The document language overrides the extension language file" +format: langfile-html +toc: true +language: + toc-title-document: "Contents from the document" +_quarto: + tests: + langfile-html: + ensureFileRegexMatches: + - ['

Contents from the document

'] + - ['Contents from the extension'] +--- + +## Section + +The document sets `toc-title-document` under `language`. +The `langfile` extension sets the same key in its language file. +The value of the document must replace the value of the extension. diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-subdir-fr.qmd b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-subdir-fr.qmd new file mode 100644 index 00000000000..c9fc069dc8b --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063-subdir-fr.qmd @@ -0,0 +1,18 @@ +--- +title: "The per-language file beside a language file in a subfolder is found" +format: subdirfile-html +toc: true +lang: fr +_quarto: + tests: + subdirfile-html: + ensureFileRegexMatches: + - ['

Sommaire du sous-dossier

'] + - ['Contents from the extension subfolder'] +--- + +## Section + +The `subdirfile` extension keeps its language files in the `i18n/` subfolder. +Quarto must find `i18n/strings.yml`, and then load `i18n/strings-fr.yml` next to it for `lang: fr`. +The table of contents must show the French title, not the English title. diff --git a/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063.qmd b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063.qmd new file mode 100644 index 00000000000..f90bc5b2282 --- /dev/null +++ b/tests/docs/smoke-all/2026/11/03/issue-15063/issue-15063.qmd @@ -0,0 +1,17 @@ +--- +title: "A format extension reads its own language file" +format: langfile-html +toc: true +_quarto: + tests: + langfile-html: + ensureFileRegexMatches: + - ['

Contents from the extension

'] + - [] +--- + +## Section + +The `langfile` extension sets `language: _language.yml` for its HTML format. +Before the fix, Quarto looked for this file in `_extensions/_extensions/langfile/` and the render stopped. +The table of contents must show the title from the language file of the extension.