Generalise text function to accept any span.