Implemented #122 from @jacquelinewheeler.
Fixes leading and trailing whitespace breaking string measurement.