Bug 62008568 - Fix replacement tags issues and add doctype replacement