The conversion pipeline
Text is processed left to right in a fixed order: lowercase everything, fold runs of whitespace (spaces, tabs, newlines) into one separator, delete punctuation and symbols, merge any separators that ended up adjacent, then trim the ends. Only letters, digits, and the separator itself survive, which is why the output always looks uniform regardless of how messy the input was.