How to remove attachment ambiguity?
You might want to add as well as or but also before "spaces":
Punctuation marks other than hyphens, as well as spaces around punctuation marks that are replaced by underscores, and spaces between initials are removed.
or
Punctuation marks other than hyphens, but also spaces around punctuation marks that are replaced by underscores, and spaces between initials are removed.