Add support for single quotes and fix edge cases that cause duplicate attributes and incorrect ordering.