Skip to content

EmbedAPI: clean images (src) properly from inside a tooltip #9337

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

Merged
merged 3 commits into from
Jun 16, 2022

Conversation

humitos
Copy link
Member

@humitos humitos commented Jun 15, 2022

When returning the content to be injected in a tooltip, besides cleaning the
a.href we are also cleaning the img.src to make them absolute and render the
images properly.

Working example

Screenshot_2022-06-15_16-16-39

See readthedocs/sphinx-hoverxref#200

humitos added 2 commits June 15, 2022 16:19
- rename `clean_links` as `clean_references`
- rename `URLData.href` as `URLData.ref`

This is done because this function will clean `a.href` and also `img.src` now.
When returning the content to be injected in a tooltip, besides cleaning the
`a.href` we are also cleaning the `img.src` to make them absolute and render the
images properly.

See readthedocs/sphinx-hoverxref#200
@humitos humitos requested a review from a team as a code owner June 15, 2022 14:23
@humitos humitos requested a review from benjaoming June 15, 2022 14:23
@humitos humitos changed the title EmbedAPI: clean images (src) properly from inside a tooltip EmbedAPI: clean images (src) properly from inside a tooltip Jun 15, 2022
@humitos humitos requested a review from ericholscher June 15, 2022 14:23
These `src=` fields are not cleaned by `clean_references`.
"""
Rewrite (internal) links to make them absolute.
Rewrite (internal) links (href) and images (src) to make them absolute.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's other external things we want to be rewriting here as well?

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source is one example, perhaps.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #9344 to track this and improve the API with other cases that may require rewriting the HTML content.

@humitos humitos merged commit ee18557 into main Jun 16, 2022
@humitos humitos deleted the humitos/embed-api-links branch June 16, 2022 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants