kevin91nl/text-highlighter

When highlighting a span that includes an existing highlight, duplicate text is inserted

Closed this issue · 5 comments

Before:
image

After highlighting "week. WidgetInc was founded by John Widgeton"
image

It appears to duplicate the pre-highlighted text and insert it following the newly-highlighted text (so "week", in this case). If you click on the new highlight and remove it, the duplicate text disappears too.

Looks like this is due to (partial) duplicate annotations existing. I can fix that by deduplicating them, but can't actually get it to change within the widget because Streamlit won't let me update the widget's value dynamically.

Thank you for sharing your findings. I tried to reproduce the issue, but I couldn't replicate it:
image

Removing and selecting the second near-duplicate text worked fine. Could you share other cases in which the error occurs?

Or is the issue that selecting a text inside a highlighted text is not working?

Hi, sorry about that, I may have been unclear.

In your example, if you highlight "Hello world!" at the start (so that it overlaps the "Hello" highlight, it will create duplicate text, which is my problem.

Ah, thank you for the clarification. It is resolved in the latest version of text-highlighter (pip install --upgrade text-highlighter).

In version 0.0.7 of text highlighter, one or multiple overlapping highlights will be deselected. This overcomes the issue with duplicated text and also works in scenarios for more than two overlapping highlights.

That's great, thank you! Really appreciate the fast response.