Mechanistic study on the Knorr pyrazole synthesis-thioester generation reaction