Add logic so that valid a tags are not stripped by WordFilter

I do not have any documents with these Toc anchors so I have not yet been able to confirm that the original purpose of this code still works. However, it is causing totally valid and unrelated links and anchors to be stripped, and I have confirmed that this change stops that behavior.