Hacker News new | ask | show | jobs
by o_____________o 1321 days ago
Cool!

How does it identify elements to anchor to, and what happens when the original text changes?

1 comments

If you're asking how the "Highlights" feature works, its using something called text fragments.

When the original text changes then the highlight is dead. Meaning you can still discuss it, but it will no longer be highlighted in the window.

You can read more about text fragments here - https://web.dev/text-fragments/

That seems like it would be a problem for something like a documentation site, where even small changes to the text would break the entire highlight. Maybe you can implement something via diff to maintain a fuzzier anchor.