Improved the markdown convert function