Skip to content

Handle relative links in <source srcset> #2976

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

laymonage
Copy link

@laymonage laymonage commented Jul 10, 2025

I tried this locally and it seems to work. Fixes #2975.

Before

image

After

image


if (token.text.startsWith("<source ", pos)) {
data.pos += 8;
return checkAttribute(data, "srcset");
Copy link
Author

Choose a reason for hiding this comment

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

The <source> tag supports:

Ideally we should support both, but I'm not familiar with how these functions work in the context of the parser. It seems that it mutates the data as it gets passed around, so I'm not sure how safe it is to e.g. store the original pos and call checkAttribute for src with the original pos after checking for srcset.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, the amount of random state that this code needs to parse around is very unfortunate; it's gotten worse since the original implementation because markdown is special... I think that should be fine here; but I really need to revisit this at some point.

Unfortunately, doing that isn't good enough. srcset isn't just one src, it's a potentially comma separated list with additional metadata (spec)

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.

Relative links to images via <picture> <source srcset> do not work
2 participants