code: def tostring(self, inject):
          
          injected_parts = ''
          for part in self.parts:
              injected = part.tostring(inject)
              tei_tag = next(
                  (attribute for attribute in part.attributes if attribute.key == "tei-tag"), None)
              if tei_tag and tei_tag.text == "w" and injected_parts:
                  # make sure words can be tokenized correctly
                  if injected_parts and injected_parts[-1] != ' ':
                      injected_parts += ' '
                  injected_parts += injected.strip() + ' '
              else:
                  injected_parts += injected
  
          return inject(self, injected_parts)
docs: Convert an element to a single string and allow the passed inject method to place content before any
          element.