Skip to content

Commit 3f6142c

Browse files
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 <noreply@anthropic.com>
1 parent 50db5a5 commit 3f6142c

7 files changed

Lines changed: 38 additions & 2 deletions

File tree

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ All changes included in 1.9:
5252
- Two-column layout now uses `set page(columns:)` instead of `columns()` function, fixing compatibility with landscape sections.
5353
- Title block now properly spans both columns in multi-column layouts.
5454
- ([#13870](https://github.com/quarto-dev/quarto-cli/issues/13870)): Add support for `alt` attribute on cross-referenced equations for improved accessibility. (author: @mcanouil)
55+
- ([#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.
5556

5657
### `pdf`
5758

src/resources/filters/quarto-post/typst-brand-yaml.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,17 @@ function render_typst_brand_yaml()
320320
imageFilename = imageFilename and imageFilename:gsub('\\_', '_')
321321
else
322322
-- backslashes need to be doubled for Windows
323+
-- Only apply project offset for brand logo paths (project-relative).
324+
-- Extension-resolved paths (containing _extensions or starting with ..)
325+
-- are already input-relative and should not have the offset applied.
326+
-- See #13745 for the same pattern applied to font-paths.
323327
if imageFilename[1] ~= "/" and _quarto.projectOffset() ~= "." then
324-
local offset = _quarto.projectOffset()
325-
imageFilename = pandoc.path.join({offset, imageFilename})
328+
local is_extension_path = string.find(imageFilename, "_extensions") or
329+
string.sub(imageFilename, 1, 2) == ".."
330+
if not is_extension_path then
331+
local offset = _quarto.projectOffset()
332+
imageFilename = pandoc.path.join({offset, imageFilename})
333+
end
326334
end
327335
imageFilename = string.gsub(imageFilename, '\\', '\\\\')
328336
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
**/*.quarto_ipynb
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: Issue Extension
2+
author: Test
3+
version: "1.0.0"
4+
quarto-required: ">=1.3.0"
5+
contributes:
6+
formats:
7+
typst:
8+
logo: quarto-icon.svg
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project:
2+
title: "Extension Logo Test"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "Extension Logo Test"
3+
format: issue-typst
4+
_quarto:
5+
tests:
6+
typst:
7+
ensureTypstFileRegexMatches:
8+
-
9+
- 'image\("\.\./(_extensions|_extensions)(/|\\\\)issue(/|\\\\)quarto-icon\.svg"'
10+
-
11+
- 'image\("\.\./\.\./(_extensions|_extensions)'
12+
---
13+
14+
This is a test document that uses a Typst format extension with a logo.

0 commit comments

Comments
 (0)