Fix: check that table row exists before trying to highlight
Created by: attfarhan
Fixes https://github.com/sourcegraph/sourcegraph/issues/2655.
When fetching highlighted code takes a long time, the HTML rows in search results do not immediately load. We assume that they would when we try to highlight the matches in a search result, so the search result page breaks. This fixes that, and adds some documentation because I always find this code a bit difficult to understand.