Skip to content

Fix Typst extension logo paths in subdirectories by making brand paths project-absolute#14075

Merged
gordonwoodhull merged 4 commits intomainfrom
bugfix/13917b
Feb 20, 2026
Merged

Fix Typst extension logo paths in subdirectories by making brand paths project-absolute#14075
gordonwoodhull merged 4 commits intomainfrom
bugfix/13917b

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Feb 20, 2026

Replaces #13931 which would only make things more brittle.

The root cause was that we were using project-relative paths for brand logo paths, and then attempting to correct them to document-relative paths. And we ended up correcting logos specified in extension, project, or in the document itself.

Instead, we can use project-absolute paths for brand logo paths. We only do this for Typst to keep the change minimal -- but there do seem to be related bugs in dashboard and revealjs which might need a similar fix.

The important lesson is that when dealing with relative paths that may come from multiple locations, you must resolve the path either relative to the document or project-absolute, before it gets merged with any other source. (The situation in q2 is somewhat better because we will use !path to tag paths, but the principle remains.)

Summary

  • Transform brand logo paths to project-absolute (/-prefixed) before merging with document logo metadata via resolveLogo, so brand paths resolve correctly via Typst --root while document-sourced paths remain input-relative
  • Remove the fragile projectOffset() hack from typst-brand-yaml.lua that indiscriminately prepended ../ to all logo paths
  • Add 5 new tests covering logo path resolution from different sources (brand, _quarto.yml, front matter, _metadata.yml, extension) in subdirectories

Closes #13917.

Test plan

  • 5 new typst/logo-path/ tests pass (from-brand, from-quarto-yml, from-frontmatter, from-metadata-yml, from-extension)
  • All 28 brand/logo/ tests with Typst regexes pass
  • All 11 typst/brand-yaml/logo/ tests pass
  • HTML/dashboard/revealjs formats unaffected (verified via multi-format tests like default-logo.qmd)

🤖 Generated with Claude Code

@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Feb 20, 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.

@gordonwoodhull gordonwoodhull changed the title Fix Typst brand logo paths for subdirectory documents Fix Typst extension logo paths in subdirectories by making brand paths project-absolute Feb 20, 2026
gordonwoodhull and others added 4 commits February 20, 2026 13:12
Transform brand logo paths to project-absolute (with / prefix) before
merging with document logo metadata via resolveLogo. This ensures brand
paths resolve correctly via Typst --root while document-sourced paths
remain input-relative.

Closes #13917.

Removes the projectOffset() hack from typst-brand-yaml.lua that was
indiscriminately prepending ../ to all logo paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move logos into images/ subdirectories so path resolution tests exercise
multi-component paths. Nest the _metadata.yml test document one level
deeper (sub/deep/doc.qmd) to test parent-directory metadata inheritance.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Brand logo paths in Typst image() calls now have a leading / since they
are resolved as project-absolute paths. Update all 29 affected test
regex patterns accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use (/|\\\\) instead of literal / in test regexes so they match both
Unix forward slashes and Windows backslashes in Typst output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gordonwoodhull gordonwoodhull merged commit fd2eafc into main Feb 20, 2026
51 checks passed
@gordonwoodhull gordonwoodhull deleted the bugfix/13917b branch February 20, 2026 18:41
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

2 participants

Comments