improve whitespace handling and markdown