Refactor highlighting

Extract some of the common logic from the renderers.