Closed cdrini closed 1 year ago
Would we be able to update this to allow whitespace-only TextNode
s if they are inside a display: inline
element ? White-space only display: inline
elements do affect the display/should be highlighted, and should not cause issues with table rows/lists/etc.
Eg. Change:
To:
// Note `span` is an array of adjacent TextNode.
// If these nodes are direct children of a `display: inline` element
// or if it's non-empty, we will wrap it with the highlight.
getComputedStyle(span[0].parentNode).display == 'inline' || span.some(node => !whitespace.test(node.data)),
This also appears to affect highlight code in various places:
highlightjs:
codemirror:
Works like a charm!
The Internet Archive bookreader has elements containing only whitespace inbetween words of their text layer.
Here is a sample line from https://archive.org/details/goodytwoshoes00newyiala/page/n5/mode/2up
It seems like this is the code where it happens:
https://github.com/hypothesis/client/blob/68e627e15e93f7b6ce2f0049359352acfc7f4482/src/annotator/highlighter.ts#L233-L256