Don't throw an exception for invalid tag names

I simply changed tokenizer to consume only valid tag name characters and added `try-catch` block to the tree builder just to be sure.