Refactored markdown rendering