Probing the mechanism for graphene nanoribbon formation on gold surfaces through X-ray spectroscopy