major refactoring in markdownUtils