fix bugs and add markdown type recognition