Refactor replace markup with macro