You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a feature request for text fragment URL support with Hypothesis.
Text fragment URL is an extension to URL scheme which allows to attach a text to an URL hash so that when a user clicks on the URL the attached text appears as highlighted and the window scrolls to the highlighted text.
The syntax of text fragment URL is as follow: #:~:text=[prefix-,]textStart[,textEnd][,-suffix] and matches the Hypothesis one for the TextQuoteSelector annotation except it contains an optional textEnd parameter.
Generating a text fragment is not easy, as you can see when testing by using the Copy link to highlight capability with Chrome: depending on the position of the selection, the text fragment can be completely different from another one close to it. There's a text-fragment-polyfill which gives an idea of how complicated it is, by handling different cases based on the HTML element e.g.
The text-fragment-polyfill generates a text fragment hash based on a window.selection - I can't seem to find a way to generate a text fragment URL using solely Hypothesis TextQuoteSelectorprefix, exact and suffix text parts that would match the result of the polyfill.
So it would make sense to generate the text fragment URL with the client bookmarklet at the same moment the user highlights the text and creates an annotation.
The annotation object would contain a new field with the hash text fragment.
And on Hypothesis pages, the resource URL would contain the text fragment hash in it so that when the user clicks on it, highlights would be displayed on the opened page immediately without requiring to load the client bookmarklet.
It's possible to attach multiple text fragments to an hash URL by separating them with an ampersand character &, so when clicking on a resource URL the user can see all of their highlights at once.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is a feature request for text fragment URL support with Hypothesis.
Text fragment URL is an extension to URL scheme which allows to attach a text to an URL hash so that when a user clicks on the URL the attached text appears as highlighted and the window scrolls to the highlighted text.
The syntax of text fragment URL is as follow:
#:~:text=[prefix-,]textStart[,textEnd][,-suffix]
and matches the Hypothesis one for theTextQuoteSelector
annotation except it contains an optionaltextEnd
parameter.Generating a text fragment is not easy, as you can see when testing by using the
Copy link to highlight
capability with Chrome: depending on the position of the selection, the text fragment can be completely different from another one close to it. There's a text-fragment-polyfill which gives an idea of how complicated it is, by handling different cases based on the HTML element e.g.The
text-fragment-polyfill
generates a text fragment hash based on awindow.selection
- I can't seem to find a way to generate a text fragment URL using solely HypothesisTextQuoteSelector
prefix
,exact
andsuffix
text parts that would match the result of the polyfill.So it would make sense to generate the text fragment URL with the client bookmarklet at the same moment the user highlights the text and creates an annotation.
The
annotation
object would contain a new field with the hash text fragment.And on Hypothesis pages, the resource URL would contain the text fragment hash in it so that when the user clicks on it, highlights would be displayed on the opened page immediately without requiring to load the client bookmarklet.
It's possible to attach multiple text fragments to an hash URL by separating them with an ampersand character
&
, so when clicking on a resource URL the user can see all of their highlights at once.Beta Was this translation helpful? Give feedback.
All reactions