Skip to content

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Aug 26, 2025

This breaks a huge number of tests because any relative logo paths now get a leading slash.

Implements the messy but narrow change of prepending a slash to any logo paths only if the input document is not in the project directory. (If we don't know, we also prepend.)

@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Aug 26, 2025

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

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@gordonwoodhull gordonwoodhull force-pushed the bugfix/11982 branch 2 times, most recently from 7f51644 to b2973b4 Compare August 28, 2025 20:08
@gordonwoodhull gordonwoodhull marked this pull request as ready for review August 28, 2025 20:08
fixes #11982
navbar and sidebar always prepended a slash and still do
(the input document location is not known when they are initialized)

the other formats must call logoAddLeadingSlashes after resolveLogo
this compares the directory of the input and the project directory
if they are different and the path is not an URL, prepend a slash
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Aug 28, 2025

It's messier code but safer to only prepend a slash when the document is not in the project directory, so I've implemented a shared helper function logoAddLeadingSlashes() and call it each place we call resolveLogo().

Where we know the input document directory we can compare it with the project directory, and only add the slash if they differ.

There are two places we don't know the input document directory:

  • navbar/sidebar: these always prepended the slash, and still do
  • the brand shortcode: that information is not available here, so it always prepends the slash

I changed the tests accordingly for the shortcode (for HTML it gets transformed to ./ in a post-processor).

Typst is the only remaining format suffering from

and this is because the typst brand logo bypasses Markdown and paths don't get transformed by project-paths.lua so I'm going to see if I can change that.

(The brand logo shortcode does work in Typst.)

@gordonwoodhull
Copy link
Contributor Author

I'm going to go ahead and merge this, since the Typst problem is unrelated.

@gordonwoodhull gordonwoodhull merged commit 605263d into main Aug 28, 2025
51 checks passed
@gordonwoodhull gordonwoodhull deleted the bugfix/11982 branch August 28, 2025 21:02
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.

Brand: logo paths are resolved incorrectly for documents in sub directories

3 participants