The cleanOutput function is a recursive function used to sanitize output text so it can safely be shown to the browser.