Fixed pandoc version detection.

This should make the version detection of pandoc more robust. It should fix issue #6240.