From 3f6142c200ef3940c0426cfca1e460c4e3cc877c Mon Sep 17 00:00:00 2001 From: Gordon Woodhull Date: Wed, 21 Jan 2026 16:45:03 -0500 Subject: [PATCH] claude: Fix Typst extension logo path resolution in subdirectories (#13917) Extension-resolved logo paths (containing _extensions or starting with ..) are already relative to the input document and should not have the project offset applied. This fixes rendering Typst format extensions with logos when the document is in a project subdirectory. The same pattern was applied to font-paths in #13745 / PR #13902. Co-Authored-By: Claude Opus 4.5 --- news/changelog-1.9.md | 1 + .../filters/quarto-post/typst-brand-yaml.lua | 12 ++++++++++-- .../docs/smoke-all/typst/extension-logo/.gitignore | 2 ++ .../_extensions/issue/_extension.yml | 8 ++++++++ .../_extensions/issue/quarto-icon.svg | 1 + .../smoke-all/typst/extension-logo/_quarto.yml | 2 ++ .../typst/extension-logo/sub/template.qmd | 14 ++++++++++++++ 7 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/docs/smoke-all/typst/extension-logo/.gitignore create mode 100644 tests/docs/smoke-all/typst/extension-logo/_extensions/issue/_extension.yml create mode 100644 tests/docs/smoke-all/typst/extension-logo/_extensions/issue/quarto-icon.svg create mode 100644 tests/docs/smoke-all/typst/extension-logo/_quarto.yml create mode 100644 tests/docs/smoke-all/typst/extension-logo/sub/template.qmd diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 10d7f15b4e2..2304f100621 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -52,6 +52,7 @@ All changes included in 1.9: - Two-column layout now uses `set page(columns:)` instead of `columns()` function, fixing compatibility with landscape sections. - Title block now properly spans both columns in multi-column layouts. - ([#13870](https://github.com/quarto-dev/quarto-cli/issues/13870)): Add support for `alt` attribute on cross-referenced equations for improved accessibility. (author: @mcanouil) +- ([#13917](https://github.com/quarto-dev/quarto-cli/issues/13917)): Fix resource path resolution for Typst format extensions when document is in a project subdirectory. Extension-resolved paths are now correctly detected and not double-prefixed with the project offset. ### `pdf` diff --git a/src/resources/filters/quarto-post/typst-brand-yaml.lua b/src/resources/filters/quarto-post/typst-brand-yaml.lua index f23190d727c..5fb1da437e3 100644 --- a/src/resources/filters/quarto-post/typst-brand-yaml.lua +++ b/src/resources/filters/quarto-post/typst-brand-yaml.lua @@ -320,9 +320,17 @@ function render_typst_brand_yaml() imageFilename = imageFilename and imageFilename:gsub('\\_', '_') else -- backslashes need to be doubled for Windows + -- Only apply project offset for brand logo paths (project-relative). + -- Extension-resolved paths (containing _extensions or starting with ..) + -- are already input-relative and should not have the offset applied. + -- See #13745 for the same pattern applied to font-paths. if imageFilename[1] ~= "/" and _quarto.projectOffset() ~= "." then - local offset = _quarto.projectOffset() - imageFilename = pandoc.path.join({offset, imageFilename}) + local is_extension_path = string.find(imageFilename, "_extensions") or + string.sub(imageFilename, 1, 2) == ".." + if not is_extension_path then + local offset = _quarto.projectOffset() + imageFilename = pandoc.path.join({offset, imageFilename}) + end end imageFilename = string.gsub(imageFilename, '\\', '\\\\') end diff --git a/tests/docs/smoke-all/typst/extension-logo/.gitignore b/tests/docs/smoke-all/typst/extension-logo/.gitignore new file mode 100644 index 00000000000..ad293093b07 --- /dev/null +++ b/tests/docs/smoke-all/typst/extension-logo/.gitignore @@ -0,0 +1,2 @@ +/.quarto/ +**/*.quarto_ipynb diff --git a/tests/docs/smoke-all/typst/extension-logo/_extensions/issue/_extension.yml b/tests/docs/smoke-all/typst/extension-logo/_extensions/issue/_extension.yml new file mode 100644 index 00000000000..e3ad0e2b01d --- /dev/null +++ b/tests/docs/smoke-all/typst/extension-logo/_extensions/issue/_extension.yml @@ -0,0 +1,8 @@ +title: Issue Extension +author: Test +version: "1.0.0" +quarto-required: ">=1.3.0" +contributes: + formats: + typst: + logo: quarto-icon.svg diff --git a/tests/docs/smoke-all/typst/extension-logo/_extensions/issue/quarto-icon.svg b/tests/docs/smoke-all/typst/extension-logo/_extensions/issue/quarto-icon.svg new file mode 100644 index 00000000000..6cded214279 --- /dev/null +++ b/tests/docs/smoke-all/typst/extension-logo/_extensions/issue/quarto-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/docs/smoke-all/typst/extension-logo/_quarto.yml b/tests/docs/smoke-all/typst/extension-logo/_quarto.yml new file mode 100644 index 00000000000..3f61fada83a --- /dev/null +++ b/tests/docs/smoke-all/typst/extension-logo/_quarto.yml @@ -0,0 +1,2 @@ +project: + title: "Extension Logo Test" diff --git a/tests/docs/smoke-all/typst/extension-logo/sub/template.qmd b/tests/docs/smoke-all/typst/extension-logo/sub/template.qmd new file mode 100644 index 00000000000..10c5bad4c5f --- /dev/null +++ b/tests/docs/smoke-all/typst/extension-logo/sub/template.qmd @@ -0,0 +1,14 @@ +--- +title: "Extension Logo Test" +format: issue-typst +_quarto: + tests: + typst: + ensureTypstFileRegexMatches: + - + - 'image\("\.\./(_extensions|_extensions)(/|\\\\)issue(/|\\\\)quarto-icon\.svg"' + - + - 'image\("\.\./\.\./(_extensions|_extensions)' +--- + +This is a test document that uses a Typst format extension with a logo.