Skip to content

Conversation

@foolip
Copy link
Collaborator

@foolip foolip commented Mar 24, 2024

No description provided.

@@ -0,0 +1,7 @@
name: Scroll to text fragment
description: Scrolling to a text snippet given in a URL fragment such as `#:~:text=snippet`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reviewers, I don't love this description, but can't figure out how to write it in a style more similar to other descriptions. Naming the feature via the syntax is tricky here, and saying what the syntax does is also tricky. Something like this?

A URL fragment on the form #:~:text=snippet causes the page to scroll to the snippet of text, if found.

Copy link
Member

Choose a reason for hiding this comment

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

"fragment" in name reads as equivalent to "snippet" in description, but I think it's supported to refer to the segment of a URL named a fragment, so that's a bit confusing.

also, "scroll to" feels overspecific - the spec talks about "emphasizing" or "bringing to the user's attention"; I'm not sure we would call the id fragment of HTML "scroll to id fragment".

How about

name:  Link to text snippet
description: A URL fragment on the form `#:~:text=snippet` allows to link directly to the snippet of text, if found.

"Link to text snippet" could also be "Text snippet URL fragment", not sure how widely known the term "url fragment" is

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that "scroll to" isn't the whole story, as implemented in Chrome the text is also highlighted. I'm a bit wary of picking a name that's never been used before however. Both https://developer.mozilla.org/en-US/docs/Web/Text_fragments and https://web.dev/articles/text-fragments both call this "text fragments", perhaps that would be best?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

About the description, here's MDN:

Text fragments allow linking directly to a specific portion of text in a web document, without requiring the author to annotate it with an ID, using particular syntax in the URL fragment. Supporting browsers are free to choose how to draw attention to the linked text, e.g. with a color highlight and/or scrolling to the content on the page.

And here's web.dev:

Text Fragments let you specify a text snippet in the URL fragment. When navigating to a URL with such a text fragment, the browser can emphasize and/or bring it to the user's attention.

I'll try something...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried.

Copy link
Member

Choose a reason for hiding this comment

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

The new description looks good; I'm not convinced by the name - it feels too generic (although I appreciate the precedent set by MDN/web.dev)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree it's a bit generic, but what to call it? Link to text fragment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The "link to" feels a bit... extra. I don't think we would call the age-old #id syntax "Link to fragment identifier", it's a part of a URL so of course it can be linked.

@@ -0,0 +1,7 @@
name: Text fragments
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we want to honor the precedent of MDN with "text fragments", maybe we could add some specificity to the end:

Suggested change
name: Text fragments
name: Text fragments in URLs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, what about our principle of shortest plausible name?

Copy link
Collaborator

@Elchi3 Elchi3 Mar 25, 2024

Choose a reason for hiding this comment

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

"URL references for text fragments"?

Maybe it helps to think about a name for this feature when also thinking about how we used to only have links to ids before. I would have called that "URL references to fragment identifiers" and not just "Fragment identifiers", I assume.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just "fragment identifiers" is what I would call that actually. I remember that from https://www.w3.org/TR/media-frags/ where "media fragments" were defined.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, what about our principle of shortest plausible name?

I guess I thought the existing name wasn't completely credible. Over in #732 (comment) you seemed unimpressed with "text fragments" alone. 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I should have shut up 😆

"Text fragments" is a bit generic, but it is the best name I can come up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, let's merge this as written. If it ends up being too vague when it is presented to developers, I'm sure we'll get feedback about it.

@Elchi3
Copy link
Collaborator

Elchi3 commented Mar 25, 2024

There is also css.selectors.target-text but maybe you've excluded that on purpose and it will be part of a separate feature (and both would be part of a group)

@foolip
Copy link
Collaborator Author

foolip commented Mar 25, 2024

@Elchi3 I didn't know about ::target-text but think that should be part of this feature. I'll add it.

@@ -0,0 +1,7 @@
name: Text fragments
Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, let's merge this as written. If it ends up being too vague when it is presented to developers, I'm sure we'll get feedback about it.

@ddbeck ddbeck merged commit ac56762 into main Mar 27, 2024
@ddbeck ddbeck deleted the scroll-to-text-fragment branch March 27, 2024 12:18
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.

5 participants