fix link and doctype handling