Skip to content

Conversation

@gordonwoodhull
Copy link
Contributor

Summary

  • Fixes extension logo paths being incorrectly double-prefixed with project offset when rendering from subdirectories
  • Extension-resolved paths (containing _extensions or starting with ..) are already input-relative and should not have projectOffset() applied
  • Adds test case verifying extension logos work correctly from subdirectories

Problem

When using a custom Typst format extension with a logo, rendering from a subdirectory fails:

metadata
  logo: ../_extensions/issue/quarto-icon.svg  # correct input-relative path

error: failed to load file (access denied)
    image("../../_extensions/issue/quarto-icon.svg")  # incorrectly double-prefixed
    = hint: cannot read file outside of project root

The bug was introduced in commit 533784522 which added projectOffset() to logo paths for brand.yml support, but incorrectly applied it to all logo paths including extension-resolved ones.

Solution

In src/resources/filters/quarto-post/typst-brand-yaml.lua, detect extension-resolved paths and skip the project offset:

if imageFilename[1] ~= "/" and _quarto.projectOffset() ~= "." then
  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

This is the same pattern used in PR #13902 for font-paths.

Related

Fixes #13917

Test plan

  • New smoke test in tests/docs/smoke-all/typst/extension-logo/ verifies correct path in generated .typ file
  • CI tests pass

🤖 Generated with Claude Code

…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>
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Jan 21, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 23, 2026

FWI, the issue does not seem limited to logo, other resources are impacted.

I updated my reprex:

git clone --filter=blob:none --sparse https://github.com/mcanouil/quarto-issues-experiments.git
cd quarto-issues-experiments
git sparse-checkout set quarto-cli-13917

Extensions resources should never have ../ prepended to them.
Extensions are at the root and it seems --root is set to _quarto.yml location when sent to typst, so the paths have no reasons to get project offset when in a project and when Quarto extensions resources from my understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resource path resolution broken in Typst format extension

4 participants