Improve highlight API, fix an env-building bug, and finish TextFilter.

These are logically separate commits; I recommend reviewing them a commit at a time.