refactor generate_markup