refactored markdown parser