nytimes / Emphasis

Dynamic Deep-Linking and Highlighting
open.nytimes.com
576 stars 70 forks source link

Quoted text causes highlighting to become greedy #14

Open su opened 9 years ago

su commented 9 years ago

If you click to select a sentence that contains a quote, and that quote terminates the sentence, the highlighting process doesn't stop until it hits the end of a following "plain" sentence.

This case doesn't exist in the demo document, so we have to construct it.

Steps:

highlight-1

If we happen to have consecutive terminal quotes, the process repeats until a "plain" sentence is reached. Rearranging the demo document again:

highlight-2

su commented 9 years ago

I also just realized that the greediness goes in both directions. If you try to select the plain sentence, the highlighting will go past its beginning, to grab the preceding quote-containing sentence.