fixed span highlighting bug

Previously temrinal punctuation characers on input that were not analysed
as belonging to leaf nodes were dropped from the highlighted string.