-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] Use logo url as is to allow for web urls. #661
Conversation
`logo_url` can sometimes be a fully qualified URL starting in Sphinx 4. Adding the `_static` prefix breaks logos that are URLs.
Thanks for submitting your first pull request! You are awesome! 🤗 |
Thanks for the PR - one question, won't this break local paths because we're removing the |
@choldgraf the HTML builder handles this in Sphinx 4+ master: https://github.com/sphinx-doc/sphinx/blob/master/sphinx/builders/html/__init__.py#L1254-L1255 |
@@ -5,7 +5,7 @@ | |||
{% set logo_url=logo %} | |||
{% endif %} | |||
{% if logo_url %} | |||
<img src="{{ pathto('_static/' + logo_url, 1) }}" class="logo" alt="logo"> | |||
<img src="{{ logo_url|e }}" class="logo" alt="logo"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being escaped? Isn't it an already-encoded URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pradyunsg I don't think that's guaranteed since the logo_url
value comes from the user in conf.py and the code I linked to above doesn't seem to be escaping anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct and I have to go fix something in Furo. :)
x-ref pradyunsg/furo#253 where I'd discovered this as well. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for this fix and for linking to the sphinx code where this is now handled! :-)
Thanks for the quick reviews @choldgraf and @pradyunsg, when do you guys think this will be released in a new version? |
There's a release candidate out now and this will make it into the next RC i think |
@fenil/@choldgraf The master version of sphinx-book-theme doesn't use the sidebar-logo.htm anymore, but instead the navbar-logo.html from the pydata theme. That version does check that the if the string is an URL, but if not it prepends A workaround is to specify the logo using the PyData logo config (light and dark theme). I guess that prevents sphinx from also prepending the
|
@melund it sounds like maybe this same fix needs to be made in navbar-logo.html as well? |
logo_url
can sometimes be a fully qualified URL starting in Sphinx 4.Adding the
_static
prefix breaks logos that are URLs.