Improve markup detection, fixes #4695

If file extension isn't given in lower case markup fails.
Avoid this by downcasing before comparing with supported extensions.